blob: 206fcb930a65a1e96574c2e90edf287d4daa8a41 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200223 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100225 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200226 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200227 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200228 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200231 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100232 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100233 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100234 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100235 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800236 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200237 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200238 ALC889A_INTEL,
239 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200242 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200244 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200245 ALC882_AUTO,
246 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247};
248
Kailang Yangdf694da2005-12-05 19:42:22 +0100249/* for GPIO Poll */
250#define GPIO_MASK 0x03
251
Takashi Iwai4a79ba342009-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
Takashi Iwai6c819492009-08-10 18:47:44 +0200261struct alc_mic_route {
262 hda_nid_t pin;
263 unsigned char mux_idx;
264 unsigned char amix_idx;
265};
266
267#define MUX_IDX_UNDEF ((unsigned char)-1)
268
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269struct alc_spec {
270 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100271 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100273 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100274 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Kailang Yangdf694da2005-12-05 19:42:22 +0100276 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200277 * don't forget NULL
278 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200279 */
280 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200282 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 struct hda_pcm_stream *stream_analog_playback;
284 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100285 struct hda_pcm_stream *stream_analog_alt_playback;
286 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200288 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 struct hda_pcm_stream *stream_digital_playback;
290 struct hda_pcm_stream *stream_digital_capture;
291
292 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200293 struct hda_multi_out multiout; /* playback set-up
294 * max_channels, dacs must be set
295 * dig_out_nid and hp_nid are optional
296 */
Takashi Iwai63300792008-01-24 15:31:36 +0100297 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100298 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100299 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301 /* capture */
302 unsigned int num_adc_nids;
303 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100304 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200305 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200308 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 const struct hda_input_mux *input_mux;
310 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200311 struct alc_mic_route ext_mic;
312 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
314 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100315 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200317 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200318 int const_channel_count;
319 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
321 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100322 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200323
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200324 /* dynamic controls, init_verbs and input_mux */
325 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200326 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200327 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200328 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200329 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
330 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100331
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100332 /* hooks */
333 void (*init_hook)(struct hda_codec *codec);
334 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
335
Takashi Iwai834be882006-03-01 14:16:17 +0100336 /* for pin sensing */
337 unsigned int sense_updated: 1;
338 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100339 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200340 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200341
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100342 /* other flags */
343 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba342009-04-22 16:31:35 +0200344 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100345
Takashi Iwai2134ea42008-01-10 16:53:55 +0100346 /* for virtual master */
347 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200348#ifdef CONFIG_SND_HDA_POWER_SAVE
349 struct hda_loopback_check loopback;
350#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200351
352 /* for PLL fix */
353 hda_nid_t pll_nid;
354 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100355};
356
357/*
358 * configuration template - to be copied to the spec instance
359 */
360struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200361 struct snd_kcontrol_new *mixers[5]; /* should be identical size
362 * with spec
363 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100364 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100365 const struct hda_verb *init_verbs[5];
366 unsigned int num_dacs;
367 hda_nid_t *dac_nids;
368 hda_nid_t dig_out_nid; /* optional */
369 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800370 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100371 unsigned int num_adc_nids;
372 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100373 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100374 hda_nid_t dig_in_nid;
375 unsigned int num_channel_mode;
376 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200377 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200378 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200379 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100380 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100381 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200382 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100383 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200384#ifdef CONFIG_SND_HDA_POWER_SAVE
385 struct hda_amp_list *loopbacks;
386#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387};
388
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
390/*
391 * input MUX handling
392 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200393static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
394 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395{
396 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
397 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200398 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
399 if (mux_idx >= spec->num_mux_defs)
400 mux_idx = 0;
401 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402}
403
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200404static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
405 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406{
407 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
408 struct alc_spec *spec = codec->spec;
409 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
410
411 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
412 return 0;
413}
414
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200415static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
416 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
419 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100420 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100422 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100423 hda_nid_t nid = spec->capsrc_nids ?
424 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200425 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
Takashi Iwaicd896c32008-11-18 12:36:33 +0100427 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
428 imux = &spec->input_mux[mux_idx];
429
Takashi Iwaia22d5432009-07-27 12:54:26 +0200430 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200431 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100432 /* Matrix-mixer style (e.g. ALC882) */
433 unsigned int *cur_val = &spec->cur_mux[adc_idx];
434 unsigned int i, idx;
435
436 idx = ucontrol->value.enumerated.item[0];
437 if (idx >= imux->num_items)
438 idx = imux->num_items - 1;
439 if (*cur_val == idx)
440 return 0;
441 for (i = 0; i < imux->num_items; i++) {
442 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
443 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
444 imux->items[i].index,
445 HDA_AMP_MUTE, v);
446 }
447 *cur_val = idx;
448 return 1;
449 } else {
450 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100451 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100452 &spec->cur_mux[adc_idx]);
453 }
454}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/*
457 * channel mode setting
458 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100464 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
465 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100473 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200474 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200475 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476}
477
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200478static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
479 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480{
481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
482 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200483 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
484 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200485 &spec->ext_channel_count);
486 if (err >= 0 && !spec->const_channel_count) {
487 spec->multiout.max_channels = spec->ext_channel_count;
488 if (spec->need_dac_fix)
489 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
490 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200491 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492}
493
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100495 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200496 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497 * being part of a format specifier. Maximum allowed length of a value is
498 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100499 *
500 * Note: some retasking pin complexes seem to ignore requests for input
501 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
502 * are requested. Therefore order this list so that this behaviour will not
503 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200504 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
505 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200506 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100507static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100508 "Mic 50pc bias", "Mic 80pc bias",
509 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100510};
511static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100512 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100513};
514/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200515 * in the pin being assumed to be exclusively an input or an output pin. In
516 * addition, "input" pins may or may not process the mic bias option
517 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
518 * accept requests for bias as of chip versions up to March 2006) and/or
519 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100520 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200521#define ALC_PIN_DIR_IN 0x00
522#define ALC_PIN_DIR_OUT 0x01
523#define ALC_PIN_DIR_INOUT 0x02
524#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
525#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100526
Kailang Yangea1fb292008-08-26 12:58:38 +0200527/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100528 * For each direction the minimum and maximum values are given.
529 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200530static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 { 0, 2 }, /* ALC_PIN_DIR_IN */
532 { 3, 4 }, /* ALC_PIN_DIR_OUT */
533 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200534 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
535 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536};
537#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
538#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
539#define alc_pin_mode_n_items(_dir) \
540 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
541
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200542static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
543 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200544{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 unsigned int item_num = uinfo->value.enumerated.item;
546 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
547
548 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200549 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
551
552 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
553 item_num = alc_pin_mode_min(dir);
554 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200555 return 0;
556}
557
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200558static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
559 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200560{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100561 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
563 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200565 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200566 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
567 AC_VERB_GET_PIN_WIDGET_CONTROL,
568 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200569
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570 /* Find enumerated value for current pinctl setting */
571 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200572 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100573 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200574 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 return 0;
576}
577
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200578static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
579 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100580{
581 signed int change;
582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
583 hda_nid_t nid = kcontrol->private_value & 0xffff;
584 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
585 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200586 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
587 AC_VERB_GET_PIN_WIDGET_CONTROL,
588 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100589
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200590 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591 val = alc_pin_mode_min(dir);
592
593 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100594 if (change) {
595 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200596 snd_hda_codec_write_cache(codec, nid, 0,
597 AC_VERB_SET_PIN_WIDGET_CONTROL,
598 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100599
Kailang Yangea1fb292008-08-26 12:58:38 +0200600 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100601 * for the requested pin mode. Enum values of 2 or less are
602 * input modes.
603 *
604 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200605 * reduces noise slightly (particularly on input) so we'll
606 * do it. However, having both input and output buffers
607 * enabled simultaneously doesn't seem to be problematic if
608 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100609 */
610 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200611 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
612 HDA_AMP_MUTE, HDA_AMP_MUTE);
613 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
614 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100615 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200616 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
617 HDA_AMP_MUTE, HDA_AMP_MUTE);
618 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
619 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100620 }
621 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 return change;
623}
624
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100625#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 .info = alc_pin_mode_info, \
628 .get = alc_pin_mode_get, \
629 .put = alc_pin_mode_put, \
630 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100631
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100632/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
633 * together using a mask with more than one bit set. This control is
634 * currently used only by the ALC260 test model. At this stage they are not
635 * needed for any "production" models.
636 */
637#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200638#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200639
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200640static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100642{
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 hda_nid_t nid = kcontrol->private_value & 0xffff;
645 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
646 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200647 unsigned int val = snd_hda_codec_read(codec, nid, 0,
648 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100649
650 *valp = (val & mask) != 0;
651 return 0;
652}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200653static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100655{
656 signed int change;
657 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
658 hda_nid_t nid = kcontrol->private_value & 0xffff;
659 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
660 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200661 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
662 AC_VERB_GET_GPIO_DATA,
663 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100664
665 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200666 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
667 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100668 gpio_data &= ~mask;
669 else
670 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200671 snd_hda_codec_write_cache(codec, nid, 0,
672 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673
674 return change;
675}
676#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
677 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
678 .info = alc_gpio_data_info, \
679 .get = alc_gpio_data_get, \
680 .put = alc_gpio_data_put, \
681 .private_value = nid | (mask<<16) }
682#endif /* CONFIG_SND_DEBUG */
683
Jonathan Woithe92621f12006-02-28 11:47:47 +0100684/* A switch control to allow the enabling of the digital IO pins on the
685 * ALC260. This is incredibly simplistic; the intention of this control is
686 * to provide something in the test model allowing digital outputs to be
687 * identified if present. If models are found which can utilise these
688 * outputs a more complete mixer control can be devised for those models if
689 * necessary.
690 */
691#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200692#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200693
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
695 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100696{
697 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
698 hda_nid_t nid = kcontrol->private_value & 0xffff;
699 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
700 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200701 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100702 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703
704 *valp = (val & mask) != 0;
705 return 0;
706}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200707static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
708 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100709{
710 signed int change;
711 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
712 hda_nid_t nid = kcontrol->private_value & 0xffff;
713 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
714 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200715 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100716 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100718
719 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100721 if (val==0)
722 ctrl_data &= ~mask;
723 else
724 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200725 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
726 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100727
728 return change;
729}
730#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
731 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
732 .info = alc_spdif_ctrl_info, \
733 .get = alc_spdif_ctrl_get, \
734 .put = alc_spdif_ctrl_put, \
735 .private_value = nid | (mask<<16) }
736#endif /* CONFIG_SND_DEBUG */
737
Jonathan Woithef8225f62008-01-08 12:16:54 +0100738/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
739 * Again, this is only used in the ALC26x test models to help identify when
740 * the EAPD line must be asserted for features to work.
741 */
742#ifdef CONFIG_SND_DEBUG
743#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
744
745static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
746 struct snd_ctl_elem_value *ucontrol)
747{
748 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
749 hda_nid_t nid = kcontrol->private_value & 0xffff;
750 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
751 long *valp = ucontrol->value.integer.value;
752 unsigned int val = snd_hda_codec_read(codec, nid, 0,
753 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
754
755 *valp = (val & mask) != 0;
756 return 0;
757}
758
759static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
760 struct snd_ctl_elem_value *ucontrol)
761{
762 int change;
763 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
764 hda_nid_t nid = kcontrol->private_value & 0xffff;
765 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
766 long val = *ucontrol->value.integer.value;
767 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
768 AC_VERB_GET_EAPD_BTLENABLE,
769 0x00);
770
771 /* Set/unset the masked control bit(s) as needed */
772 change = (!val ? 0 : mask) != (ctrl_data & mask);
773 if (!val)
774 ctrl_data &= ~mask;
775 else
776 ctrl_data |= mask;
777 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
778 ctrl_data);
779
780 return change;
781}
782
783#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
784 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
785 .info = alc_eapd_ctrl_info, \
786 .get = alc_eapd_ctrl_get, \
787 .put = alc_eapd_ctrl_put, \
788 .private_value = nid | (mask<<16) }
789#endif /* CONFIG_SND_DEBUG */
790
Kailang Yangdf694da2005-12-05 19:42:22 +0100791/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100792 * set up the input pin config (depending on the given auto-pin type)
793 */
794static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
795 int auto_pin_type)
796{
797 unsigned int val = PIN_IN;
798
799 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
800 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100801 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100802 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
803 if (pincap & AC_PINCAP_VREF_80)
804 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200805 else if (pincap & AC_PINCAP_VREF_50)
806 val = PIN_VREF50;
807 else if (pincap & AC_PINCAP_VREF_100)
808 val = PIN_VREF100;
809 else if (pincap & AC_PINCAP_VREF_GRD)
810 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100811 }
812 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
813}
814
815/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100816 */
817static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
818{
819 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
820 return;
821 spec->mixers[spec->num_mixers++] = mix;
822}
823
824static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
825{
826 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
827 return;
828 spec->init_verbs[spec->num_init_verbs++] = verb;
829}
830
Takashi Iwaidaead532008-11-28 12:55:36 +0100831#ifdef CONFIG_PROC_FS
832/*
833 * hook for proc
834 */
835static void print_realtek_coef(struct snd_info_buffer *buffer,
836 struct hda_codec *codec, hda_nid_t nid)
837{
838 int coeff;
839
840 if (nid != 0x20)
841 return;
842 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
843 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
844 coeff = snd_hda_codec_read(codec, nid, 0,
845 AC_VERB_GET_COEF_INDEX, 0);
846 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
847}
848#else
849#define print_realtek_coef NULL
850#endif
851
Takashi Iwaid88897e2008-10-31 15:01:37 +0100852/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 * set up from the preset table
854 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200855static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200856 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100857{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200858 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100859 int i;
860
861 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100863 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200864 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
865 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100866 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200867
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->channel_mode = preset->channel_mode;
869 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200870 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200871 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872
Hector Martin3b315d72009-06-02 10:54:19 +0200873 if (preset->const_channel_count)
874 spec->multiout.max_channels = preset->const_channel_count;
875 else
876 spec->multiout.max_channels = spec->channel_mode[0].channels;
877 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878
879 spec->multiout.num_dacs = preset->num_dacs;
880 spec->multiout.dac_nids = preset->dac_nids;
881 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800882 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200884
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200886 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->input_mux = preset->input_mux;
889
890 spec->num_adc_nids = preset->num_adc_nids;
891 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100892 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100894
895 spec->unsol_event = preset->unsol_event;
896 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200897#ifdef CONFIG_SND_HDA_POWER_SAVE
898 spec->loopback.amplist = preset->loopbacks;
899#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200900
901 if (preset->setup)
902 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100903}
904
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200905/* Enable GPIO mask and set output */
906static struct hda_verb alc_gpio1_init_verbs[] = {
907 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
908 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
910 { }
911};
912
913static struct hda_verb alc_gpio2_init_verbs[] = {
914 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
915 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
917 { }
918};
919
Kailang Yangbdd148a2007-05-08 15:19:08 +0200920static struct hda_verb alc_gpio3_init_verbs[] = {
921 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
922 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
924 { }
925};
926
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200927/*
928 * Fix hardware PLL issue
929 * On some codecs, the analog PLL gating control must be off while
930 * the default value is 1.
931 */
932static void alc_fix_pll(struct hda_codec *codec)
933{
934 struct alc_spec *spec = codec->spec;
935 unsigned int val;
936
937 if (!spec->pll_nid)
938 return;
939 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
940 spec->pll_coef_idx);
941 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
942 AC_VERB_GET_PROC_COEF, 0);
943 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
944 spec->pll_coef_idx);
945 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
946 val & ~(1 << spec->pll_coef_bit));
947}
948
949static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
950 unsigned int coef_idx, unsigned int coef_bit)
951{
952 struct alc_spec *spec = codec->spec;
953 spec->pll_nid = nid;
954 spec->pll_coef_idx = coef_idx;
955 spec->pll_coef_bit = coef_bit;
956 alc_fix_pll(codec);
957}
958
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200959static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200960{
961 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200962 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200963 unsigned int nid = spec->autocfg.hp_pins[0];
964 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200965
Takashi Iwai261c2402009-06-25 08:13:40 +0200966 pincap = snd_hda_query_pin_caps(codec, nid);
967 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
968 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200970 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200971 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
972 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
973 nid = spec->autocfg.speaker_pins[i];
974 if (!nid)
975 break;
976 snd_hda_codec_write(codec, nid, 0,
977 AC_VERB_SET_PIN_WIDGET_CONTROL,
978 spec->jack_present ? 0 : PIN_OUT);
979 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200980}
981
Takashi Iwai6c819492009-08-10 18:47:44 +0200982static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
983 hda_nid_t nid)
984{
985 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
986 int i, nums;
987
988 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
989 for (i = 0; i < nums; i++)
990 if (conn[i] == nid)
991 return i;
992 return -1;
993}
994
Kailang Yang7fb0d782008-10-15 11:12:35 +0200995static void alc_mic_automute(struct hda_codec *codec)
996{
997 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200998 struct alc_mic_route *dead, *alive;
999 unsigned int present, type;
1000 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001001
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001002 if (!spec->auto_mic)
1003 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001004 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1005 return;
1006 if (snd_BUG_ON(!spec->adc_nids))
1007 return;
1008
1009 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1010
1011 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1012 AC_VERB_GET_PIN_SENSE, 0);
1013 present &= AC_PINSENSE_PRESENCE;
1014 if (present) {
1015 alive = &spec->ext_mic;
1016 dead = &spec->int_mic;
1017 } else {
1018 alive = &spec->int_mic;
1019 dead = &spec->ext_mic;
1020 }
1021
Takashi Iwai6c819492009-08-10 18:47:44 +02001022 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1023 if (type == AC_WID_AUD_MIX) {
1024 /* Matrix-mixer style (e.g. ALC882) */
1025 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1026 alive->mux_idx,
1027 HDA_AMP_MUTE, 0);
1028 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1029 dead->mux_idx,
1030 HDA_AMP_MUTE, HDA_AMP_MUTE);
1031 } else {
1032 /* MUX style (e.g. ALC880) */
1033 snd_hda_codec_write_cache(codec, cap_nid, 0,
1034 AC_VERB_SET_CONNECT_SEL,
1035 alive->mux_idx);
1036 }
1037
1038 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001039}
1040
Kailang Yangc9b58002007-10-16 14:30:01 +02001041/* unsolicited event for HP jack sensing */
1042static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1043{
1044 if (codec->vendor_id == 0x10ec0880)
1045 res >>= 28;
1046 else
1047 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001048 switch (res) {
1049 case ALC880_HP_EVENT:
1050 alc_automute_pin(codec);
1051 break;
1052 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001053 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001054 break;
1055 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056}
1057
1058static void alc_inithook(struct hda_codec *codec)
1059{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001060 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001061 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001062}
1063
Kailang Yangf9423e72008-05-27 12:32:25 +02001064/* additional initialization for ALC888 variants */
1065static void alc888_coef_init(struct hda_codec *codec)
1066{
1067 unsigned int tmp;
1068
1069 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1070 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1071 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001072 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001073 /* alc888S-VC */
1074 snd_hda_codec_read(codec, 0x20, 0,
1075 AC_VERB_SET_PROC_COEF, 0x830);
1076 else
1077 /* alc888-VB */
1078 snd_hda_codec_read(codec, 0x20, 0,
1079 AC_VERB_SET_PROC_COEF, 0x3030);
1080}
1081
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001082static void alc889_coef_init(struct hda_codec *codec)
1083{
1084 unsigned int tmp;
1085
1086 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1087 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1088 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1089 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1090}
1091
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001092static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001093{
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001094 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001096 switch (type) {
1097 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1099 break;
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001100 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001101 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1102 break;
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001103 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001104 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1105 break;
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001106 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001107 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001108 case 0x10ec0260:
1109 snd_hda_codec_write(codec, 0x0f, 0,
1110 AC_VERB_SET_EAPD_BTLENABLE, 2);
1111 snd_hda_codec_write(codec, 0x10, 0,
1112 AC_VERB_SET_EAPD_BTLENABLE, 2);
1113 break;
1114 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001115 case 0x10ec0267:
1116 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001117 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001118 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001119 case 0x10ec0660:
1120 case 0x10ec0662:
1121 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001122 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001123 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001124 snd_hda_codec_write(codec, 0x14, 0,
1125 AC_VERB_SET_EAPD_BTLENABLE, 2);
1126 snd_hda_codec_write(codec, 0x15, 0,
1127 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001128 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001129 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 switch (codec->vendor_id) {
1131 case 0x10ec0260:
1132 snd_hda_codec_write(codec, 0x1a, 0,
1133 AC_VERB_SET_COEF_INDEX, 7);
1134 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1135 AC_VERB_GET_PROC_COEF, 0);
1136 snd_hda_codec_write(codec, 0x1a, 0,
1137 AC_VERB_SET_COEF_INDEX, 7);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_PROC_COEF,
1140 tmp | 0x2010);
1141 break;
1142 case 0x10ec0262:
1143 case 0x10ec0880:
1144 case 0x10ec0882:
1145 case 0x10ec0883:
1146 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001147 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001148 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001149 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001150 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001151 case 0x10ec0888:
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001152 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001154 case 0x10ec0267:
1155 case 0x10ec0268:
1156 snd_hda_codec_write(codec, 0x20, 0,
1157 AC_VERB_SET_COEF_INDEX, 7);
1158 tmp = snd_hda_codec_read(codec, 0x20, 0,
1159 AC_VERB_GET_PROC_COEF, 0);
1160 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001161 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001162 snd_hda_codec_write(codec, 0x20, 0,
1163 AC_VERB_SET_PROC_COEF,
1164 tmp | 0x3000);
1165 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001166 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001167 break;
1168 }
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001169}
Kailang Yangea1fb292008-08-26 12:58:38 +02001170
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001171static void alc_init_auto_hp(struct hda_codec *codec)
1172{
1173 struct alc_spec *spec = codec->spec;
1174
1175 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001176 return;
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001177
Kailang Yangc9b58002007-10-16 14:30:01 +02001178 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001179 if (spec->autocfg.line_out_pins[0] &&
1180 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001181 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001182 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001183 else
1184 return;
1185 }
1186
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001187 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1188 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001189 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1190 AC_VERB_SET_UNSOLICITED_ENABLE,
1191 AC_USRSP_EN | ALC880_HP_EVENT);
1192 spec->unsol_event = alc_sku_unsol_event;
1193}
1194
Takashi Iwai6c819492009-08-10 18:47:44 +02001195static void alc_init_auto_mic(struct hda_codec *codec)
1196{
1197 struct alc_spec *spec = codec->spec;
1198 struct auto_pin_cfg *cfg = &spec->autocfg;
1199 hda_nid_t fixed, ext;
1200 int i;
1201
1202 /* there must be only two mic inputs exclusively */
1203 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1204 if (cfg->input_pins[i])
1205 return;
1206
1207 fixed = ext = 0;
1208 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1209 hda_nid_t nid = cfg->input_pins[i];
1210 unsigned int defcfg;
1211 if (!nid)
1212 return;
1213 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1214 switch (get_defcfg_connect(defcfg)) {
1215 case AC_JACK_PORT_FIXED:
1216 if (fixed)
1217 return; /* already occupied */
1218 fixed = nid;
1219 break;
1220 case AC_JACK_PORT_COMPLEX:
1221 if (ext)
1222 return; /* already occupied */
1223 ext = nid;
1224 break;
1225 default:
1226 return; /* invalid entry */
1227 }
1228 }
1229 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1230 return; /* no unsol support */
1231 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1232 ext, fixed);
1233 spec->ext_mic.pin = ext;
1234 spec->int_mic.pin = fixed;
1235 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1236 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1237 spec->auto_mic = 1;
1238 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1239 AC_VERB_SET_UNSOLICITED_ENABLE,
1240 AC_USRSP_EN | ALC880_MIC_EVENT);
1241 spec->unsol_event = alc_sku_unsol_event;
1242}
1243
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001244/* check subsystem ID and set up device-specific initialization;
1245 * return 1 if initialized, 0 if invalid SSID
1246 */
1247/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1248 * 31 ~ 16 : Manufacture ID
1249 * 15 ~ 8 : SKU ID
1250 * 7 ~ 0 : Assembly ID
1251 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1252 */
1253static int alc_subsystem_id(struct hda_codec *codec,
1254 hda_nid_t porta, hda_nid_t porte,
1255 hda_nid_t portd)
1256{
1257 unsigned int ass, tmp, i;
1258 unsigned nid;
1259 struct alc_spec *spec = codec->spec;
1260
1261 ass = codec->subsystem_id & 0xffff;
1262 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1263 goto do_sku;
1264
1265 /* invalid SSID, check the special NID pin defcfg instead */
1266 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001267 * 31~30 : port connectivity
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001268 * 29~21 : reserve
1269 * 20 : PCBEEP input
1270 * 19~16 : Check sum (15:1)
1271 * 15~1 : Custom
1272 * 0 : override
1273 */
1274 nid = 0x1d;
1275 if (codec->vendor_id == 0x10ec0260)
1276 nid = 0x17;
1277 ass = snd_hda_codec_get_pincfg(codec, nid);
1278 snd_printd("realtek: No valid SSID, "
1279 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001280 ass, nid);
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001281 if (!(ass & 1) && !(ass & 0x100000))
1282 return 0;
1283 if ((ass >> 30) != 1) /* no physical connection */
1284 return 0;
1285
1286 /* check sum */
1287 tmp = 0;
1288 for (i = 1; i < 16; i++) {
1289 if ((ass >> i) & 1)
1290 tmp++;
1291 }
1292 if (((ass >> 16) & 0xf) != tmp)
1293 return 0;
1294do_sku:
1295 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1296 ass & 0xffff, codec->vendor_id);
1297 /*
1298 * 0 : override
1299 * 1 : Swap Jack
1300 * 2 : 0 --> Desktop, 1 --> Laptop
1301 * 3~5 : External Amplifier control
1302 * 7~6 : Reserved
1303 */
1304 tmp = (ass & 0x38) >> 3; /* external Amp control */
1305 switch (tmp) {
1306 case 1:
1307 spec->init_amp = ALC_INIT_GPIO1;
1308 break;
1309 case 3:
1310 spec->init_amp = ALC_INIT_GPIO2;
1311 break;
1312 case 7:
1313 spec->init_amp = ALC_INIT_GPIO3;
1314 break;
1315 case 5:
1316 spec->init_amp = ALC_INIT_DEFAULT;
1317 break;
1318 }
1319
1320 /* is laptop or Desktop and enable the function "Mute internal speaker
1321 * when the external headphone out jack is plugged"
1322 */
1323 if (!(ass & 0x8000))
1324 return 1;
1325 /*
1326 * 10~8 : Jack location
1327 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1328 * 14~13: Resvered
1329 * 15 : 1 --> enable the function "Mute internal speaker
1330 * when the external headphone out jack is plugged"
1331 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001332 if (!spec->autocfg.hp_pins[0]) {
1333 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1334 if (tmp == 0)
1335 spec->autocfg.hp_pins[0] = porta;
1336 else if (tmp == 1)
1337 spec->autocfg.hp_pins[0] = porte;
1338 else if (tmp == 2)
1339 spec->autocfg.hp_pins[0] = portd;
1340 else
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001341 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001342 }
1343
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001344 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001345 alc_init_auto_mic(codec);
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001346 return 1;
1347}
Kailang Yangea1fb292008-08-26 12:58:38 +02001348
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001349static void alc_ssid_check(struct hda_codec *codec,
1350 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1351{
1352 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1353 struct alc_spec *spec = codec->spec;
1354 snd_printd("realtek: "
1355 "Enable default setup for auto mode as fallback\n");
1356 spec->init_amp = ALC_INIT_DEFAULT;
1357 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001358 alc_init_auto_mic(codec);
Takashi Iwai4a79ba342009-04-22 16:31:35 +02001359 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001360}
1361
Takashi Iwai41e41f12005-06-08 14:48:49 +02001362/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001363 * Fix-up pin default configurations
1364 */
1365
1366struct alc_pincfg {
1367 hda_nid_t nid;
1368 u32 val;
1369};
1370
1371static void alc_fix_pincfg(struct hda_codec *codec,
1372 const struct snd_pci_quirk *quirk,
1373 const struct alc_pincfg **pinfix)
1374{
1375 const struct alc_pincfg *cfg;
1376
1377 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1378 if (!quirk)
1379 return;
1380
1381 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001382 for (; cfg->nid; cfg++)
1383 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001384}
1385
1386/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001387 * ALC888
1388 */
1389
1390/*
1391 * 2ch mode
1392 */
1393static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1394/* Mic-in jack as mic in */
1395 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1396 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1397/* Line-in jack as Line in */
1398 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1399 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1400/* Line-Out as Front */
1401 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1402 { } /* end */
1403};
1404
1405/*
1406 * 4ch mode
1407 */
1408static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1409/* Mic-in jack as mic in */
1410 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1411 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1412/* Line-in jack as Surround */
1413 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1414 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1415/* Line-Out as Front */
1416 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1417 { } /* end */
1418};
1419
1420/*
1421 * 6ch mode
1422 */
1423static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1424/* Mic-in jack as CLFE */
1425 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1426 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1427/* Line-in jack as Surround */
1428 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1429 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1430/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1431 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1432 { } /* end */
1433};
1434
1435/*
1436 * 8ch mode
1437 */
1438static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1439/* Mic-in jack as CLFE */
1440 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1441 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1442/* Line-in jack as Surround */
1443 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1444 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1445/* Line-Out as Side */
1446 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1447 { } /* end */
1448};
1449
1450static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1451 { 2, alc888_4ST_ch2_intel_init },
1452 { 4, alc888_4ST_ch4_intel_init },
1453 { 6, alc888_4ST_ch6_intel_init },
1454 { 8, alc888_4ST_ch8_intel_init },
1455};
1456
1457/*
1458 * ALC888 Fujitsu Siemens Amillo xa3530
1459 */
1460
1461static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1462/* Front Mic: set to PIN_IN (empty by default) */
1463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1464/* Connect Internal HP to Front */
1465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1466 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1467 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1468/* Connect Bass HP to Front */
1469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1471 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1472/* Connect Line-Out side jack (SPDIF) to Side */
1473 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1474 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1475 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1476/* Connect Mic jack to CLFE */
1477 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1478 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1479 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1480/* Connect Line-in jack to Surround */
1481 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1482 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1483 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1484/* Connect HP out jack to Front */
1485 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1486 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1487 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1488/* Enable unsolicited event for HP jack and Line-out jack */
1489 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1490 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1491 {}
1492};
1493
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001494static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001495{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001496 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001497 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001498 hda_nid_t nid;
1499 int i;
1500
1501 spec->jack_present = 0;
1502 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1503 nid = spec->autocfg.hp_pins[i];
1504 if (!nid)
1505 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001506 pincap = snd_hda_query_pin_caps(codec, nid);
1507 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1508 snd_hda_codec_read(codec, nid, 0,
1509 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001510 val = snd_hda_codec_read(codec, nid, 0,
1511 AC_VERB_GET_PIN_SENSE, 0);
1512 if (val & AC_PINSENSE_PRESENCE) {
1513 spec->jack_present = 1;
1514 break;
1515 }
1516 }
1517
1518 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001519 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001520 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1521 nid = spec->autocfg.speaker_pins[i];
1522 if (!nid)
1523 break;
1524 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1525 HDA_AMP_MUTE, mute);
1526 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001527}
1528
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1530 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001531{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001532 if (codec->vendor_id == 0x10ec0880)
1533 res >>= 28;
1534 else
1535 res >>= 26;
1536 if (res == ALC880_HP_EVENT)
1537 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001538}
1539
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001540static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001541{
1542 struct alc_spec *spec = codec->spec;
1543
1544 spec->autocfg.hp_pins[0] = 0x15;
1545 spec->autocfg.speaker_pins[0] = 0x14;
1546 spec->autocfg.speaker_pins[1] = 0x16;
1547 spec->autocfg.speaker_pins[2] = 0x17;
1548 spec->autocfg.speaker_pins[3] = 0x19;
1549 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001550}
1551
1552static void alc889_intel_init_hook(struct hda_codec *codec)
1553{
1554 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001555 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001556}
1557
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001558static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001559{
1560 struct alc_spec *spec = codec->spec;
1561
1562 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1563 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1564 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1565 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001566}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001567
1568/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001569 * ALC888 Acer Aspire 4930G model
1570 */
1571
1572static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1573/* Front Mic: set to PIN_IN (empty by default) */
1574 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1575/* Unselect Front Mic by default in input mixer 3 */
1576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001577/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001578 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1579/* Connect Internal HP to front */
1580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1581 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1582 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1583/* Connect HP out to front */
1584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1586 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1587 { }
1588};
1589
Hector Martin3b315d72009-06-02 10:54:19 +02001590/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001591 * ALC888 Acer Aspire 6530G model
1592 */
1593
1594static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1595/* Bias voltage on for external mic port */
1596 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001597/* Front Mic: set to PIN_IN (empty by default) */
1598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1599/* Unselect Front Mic by default in input mixer 3 */
1600 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001601/* Enable unsolicited event for HP jack */
1602 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1603/* Enable speaker output */
1604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1606/* Enable headphone output */
1607 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1610 { }
1611};
1612
1613/*
Hector Martin018df412009-06-04 00:13:40 +02001614 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001615 */
1616
Hector Martin018df412009-06-04 00:13:40 +02001617static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001618/* Front Mic: set to PIN_IN (empty by default) */
1619 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1620/* Unselect Front Mic by default in input mixer 3 */
1621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1622/* Enable unsolicited event for HP jack */
1623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1624/* Connect Internal Front to Front */
1625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1627 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1628/* Connect Internal Rear to Rear */
1629 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1631 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1632/* Connect Internal CLFE to CLFE */
1633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1634 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1636/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1640/* Enable all DACs */
1641/* DAC DISABLE/MUTE 1? */
1642/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1643 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1644 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1645/* DAC DISABLE/MUTE 2? */
1646/* some bit here disables the other DACs. Init=0x4900 */
1647 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1648 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1649/* Enable amplifiers */
1650 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1651 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001652/* DMIC fix
1653 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1654 * which makes the stereo useless. However, either the mic or the ALC889
1655 * makes the signal become a difference/sum signal instead of standard
1656 * stereo, which is annoying. So instead we flip this bit which makes the
1657 * codec replicate the sum signal to both channels, turning it into a
1658 * normal mono mic.
1659 */
1660/* DMIC_CONTROL? Init value = 0x0001 */
1661 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1662 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001663 { }
1664};
1665
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001666static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001667 /* Front mic only available on one ADC */
1668 {
1669 .num_items = 4,
1670 .items = {
1671 { "Mic", 0x0 },
1672 { "Line", 0x2 },
1673 { "CD", 0x4 },
1674 { "Front Mic", 0xb },
1675 },
1676 },
1677 {
1678 .num_items = 3,
1679 .items = {
1680 { "Mic", 0x0 },
1681 { "Line", 0x2 },
1682 { "CD", 0x4 },
1683 },
1684 }
1685};
1686
Tony Vroond2fd4b02009-06-21 00:40:10 +01001687static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1688 /* Interal mic only available on one ADC */
1689 {
Tony Vroon684a8842009-06-26 09:27:50 +01001690 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001691 .items = {
1692 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001693 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001694 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001695 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001696 { "Int Mic", 0xb },
1697 },
1698 },
1699 {
Tony Vroon684a8842009-06-26 09:27:50 +01001700 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001701 .items = {
1702 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001703 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001704 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001705 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706 },
1707 }
1708};
1709
Hector Martin018df412009-06-04 00:13:40 +02001710static struct hda_input_mux alc889_capture_sources[3] = {
1711 /* Digital mic only available on first "ADC" */
1712 {
1713 .num_items = 5,
1714 .items = {
1715 { "Mic", 0x0 },
1716 { "Line", 0x2 },
1717 { "CD", 0x4 },
1718 { "Front Mic", 0xb },
1719 { "Input Mix", 0xa },
1720 },
1721 },
1722 {
1723 .num_items = 4,
1724 .items = {
1725 { "Mic", 0x0 },
1726 { "Line", 0x2 },
1727 { "CD", 0x4 },
1728 { "Input Mix", 0xa },
1729 },
1730 },
1731 {
1732 .num_items = 4,
1733 .items = {
1734 { "Mic", 0x0 },
1735 { "Line", 0x2 },
1736 { "CD", 0x4 },
1737 { "Input Mix", 0xa },
1738 },
1739 }
1740};
1741
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001742static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001743 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1744 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1745 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1747 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1748 HDA_OUTPUT),
1749 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1750 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1751 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1752 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1753 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1754 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_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001761 { } /* end */
1762};
1763
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001764static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001765{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001766 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001767
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001768 spec->autocfg.hp_pins[0] = 0x15;
1769 spec->autocfg.speaker_pins[0] = 0x14;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001770}
1771
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001772static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001773{
1774 struct alc_spec *spec = codec->spec;
1775
1776 spec->autocfg.hp_pins[0] = 0x15;
1777 spec->autocfg.speaker_pins[0] = 0x14;
1778 spec->autocfg.speaker_pins[1] = 0x16;
1779 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001780}
1781
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001782static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001783{
1784 struct alc_spec *spec = codec->spec;
1785
1786 spec->autocfg.hp_pins[0] = 0x15;
1787 spec->autocfg.speaker_pins[0] = 0x14;
1788 spec->autocfg.speaker_pins[1] = 0x16;
1789 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001790}
1791
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001792/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001793 * ALC880 3-stack model
1794 *
1795 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001796 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1797 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001798 */
1799
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800static hda_nid_t alc880_dac_nids[4] = {
1801 /* front, rear, clfe, rear_surr */
1802 0x02, 0x05, 0x04, 0x03
1803};
1804
1805static hda_nid_t alc880_adc_nids[3] = {
1806 /* ADC0-2 */
1807 0x07, 0x08, 0x09,
1808};
1809
1810/* The datasheet says the node 0x07 is connected from inputs,
1811 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001812 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001814static hda_nid_t alc880_adc_nids_alt[2] = {
1815 /* ADC1-2 */
1816 0x08, 0x09,
1817};
1818
1819#define ALC880_DIGOUT_NID 0x06
1820#define ALC880_DIGIN_NID 0x0a
1821
1822static struct hda_input_mux alc880_capture_source = {
1823 .num_items = 4,
1824 .items = {
1825 { "Mic", 0x0 },
1826 { "Front Mic", 0x3 },
1827 { "Line", 0x2 },
1828 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001830};
1831
1832/* channel source setting (2/6 channel selection for 3-stack) */
1833/* 2ch mode */
1834static struct hda_verb alc880_threestack_ch2_init[] = {
1835 /* set line-in to input, mute it */
1836 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1837 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1838 /* set mic-in to input vref 80%, mute it */
1839 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1840 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 { } /* end */
1842};
1843
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001844/* 6ch mode */
1845static struct hda_verb alc880_threestack_ch6_init[] = {
1846 /* set line-in to output, unmute it */
1847 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1848 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1849 /* set mic-in to output, unmute it */
1850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1852 { } /* end */
1853};
1854
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001855static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001856 { 2, alc880_threestack_ch2_init },
1857 { 6, alc880_threestack_ch6_init },
1858};
1859
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001860static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001862 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001863 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001864 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001865 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1866 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001867 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1868 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1871 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1872 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1875 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1876 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001878 {
1879 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1880 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001881 .info = alc_ch_mode_info,
1882 .get = alc_ch_mode_get,
1883 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001884 },
1885 { } /* end */
1886};
1887
1888/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001889static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1890 struct snd_ctl_elem_info *uinfo)
1891{
1892 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1893 struct alc_spec *spec = codec->spec;
1894 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001895
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001896 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001897 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1898 HDA_INPUT);
1899 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001900 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001901 return err;
1902}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001904static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1905 unsigned int size, unsigned int __user *tlv)
1906{
1907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1908 struct alc_spec *spec = codec->spec;
1909 int err;
1910
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001911 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001912 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1913 HDA_INPUT);
1914 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 return err;
1917}
1918
1919typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1920 struct snd_ctl_elem_value *ucontrol);
1921
1922static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1923 struct snd_ctl_elem_value *ucontrol,
1924 getput_call_t func)
1925{
1926 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1927 struct alc_spec *spec = codec->spec;
1928 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1929 int err;
1930
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001931 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001932 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1933 3, 0, HDA_INPUT);
1934 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001935 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936 return err;
1937}
1938
1939static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1940 struct snd_ctl_elem_value *ucontrol)
1941{
1942 return alc_cap_getput_caller(kcontrol, ucontrol,
1943 snd_hda_mixer_amp_volume_get);
1944}
1945
1946static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1947 struct snd_ctl_elem_value *ucontrol)
1948{
1949 return alc_cap_getput_caller(kcontrol, ucontrol,
1950 snd_hda_mixer_amp_volume_put);
1951}
1952
1953/* capture mixer elements */
1954#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1955
1956static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1957 struct snd_ctl_elem_value *ucontrol)
1958{
1959 return alc_cap_getput_caller(kcontrol, ucontrol,
1960 snd_hda_mixer_amp_switch_get);
1961}
1962
1963static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1964 struct snd_ctl_elem_value *ucontrol)
1965{
1966 return alc_cap_getput_caller(kcontrol, ucontrol,
1967 snd_hda_mixer_amp_switch_put);
1968}
1969
Takashi Iwaia23b6882009-03-23 15:21:36 +01001970#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001971 { \
1972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1973 .name = "Capture Switch", \
1974 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1975 .count = num, \
1976 .info = alc_cap_sw_info, \
1977 .get = alc_cap_sw_get, \
1978 .put = alc_cap_sw_put, \
1979 }, \
1980 { \
1981 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1982 .name = "Capture Volume", \
1983 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1984 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1985 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1986 .count = num, \
1987 .info = alc_cap_vol_info, \
1988 .get = alc_cap_vol_get, \
1989 .put = alc_cap_vol_put, \
1990 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001991 }
1992
1993#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001994 { \
1995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1996 /* .name = "Capture Source", */ \
1997 .name = "Input Source", \
1998 .count = num, \
1999 .info = alc_mux_enum_info, \
2000 .get = alc_mux_enum_get, \
2001 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002002 }
2003
2004#define DEFINE_CAPMIX(num) \
2005static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2006 _DEFINE_CAPMIX(num), \
2007 _DEFINE_CAPSRC(num), \
2008 { } /* end */ \
2009}
2010
2011#define DEFINE_CAPMIX_NOSRC(num) \
2012static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2013 _DEFINE_CAPMIX(num), \
2014 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002015}
2016
2017/* up to three ADCs */
2018DEFINE_CAPMIX(1);
2019DEFINE_CAPMIX(2);
2020DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002021DEFINE_CAPMIX_NOSRC(1);
2022DEFINE_CAPMIX_NOSRC(2);
2023DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002024
2025/*
2026 * ALC880 5-stack model
2027 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002028 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2029 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002030 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2031 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2032 */
2033
2034/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002035static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002036 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002037 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038 { } /* end */
2039};
2040
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041/* channel source setting (6/8 channel selection for 5-stack) */
2042/* 6ch mode */
2043static struct hda_verb alc880_fivestack_ch6_init[] = {
2044 /* set line-in to input, mute it */
2045 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2046 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002047 { } /* end */
2048};
2049
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002050/* 8ch mode */
2051static struct hda_verb alc880_fivestack_ch8_init[] = {
2052 /* set line-in to output, unmute it */
2053 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2054 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2055 { } /* end */
2056};
2057
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002058static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059 { 6, alc880_fivestack_ch6_init },
2060 { 8, alc880_fivestack_ch8_init },
2061};
2062
2063
2064/*
2065 * ALC880 6-stack model
2066 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002067 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2068 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2070 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2071 */
2072
2073static hda_nid_t alc880_6st_dac_nids[4] = {
2074 /* front, rear, clfe, rear_surr */
2075 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002076};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077
2078static struct hda_input_mux alc880_6stack_capture_source = {
2079 .num_items = 4,
2080 .items = {
2081 { "Mic", 0x0 },
2082 { "Front Mic", 0x1 },
2083 { "Line", 0x2 },
2084 { "CD", 0x4 },
2085 },
2086};
2087
2088/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002089static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002090 { 8, NULL },
2091};
2092
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002093static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002094 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002095 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002097 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2099 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002100 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2101 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002102 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002103 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002112 {
2113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2114 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002115 .info = alc_ch_mode_info,
2116 .get = alc_ch_mode_get,
2117 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002118 },
2119 { } /* end */
2120};
2121
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002122
2123/*
2124 * ALC880 W810 model
2125 *
2126 * W810 has rear IO for:
2127 * Front (DAC 02)
2128 * Surround (DAC 03)
2129 * Center/LFE (DAC 04)
2130 * Digital out (06)
2131 *
2132 * The system also has a pair of internal speakers, and a headphone jack.
2133 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002134 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002135 * There is a variable resistor to control the speaker or headphone
2136 * volume. This is a hardware-only device without a software API.
2137 *
2138 * Plugging headphones in will disable the internal speakers. This is
2139 * implemented in hardware, not via the driver using jack sense. In
2140 * a similar fashion, plugging into the rear socket marked "front" will
2141 * disable both the speakers and headphones.
2142 *
2143 * For input, there's a microphone jack, and an "audio in" jack.
2144 * These may not do anything useful with this driver yet, because I
2145 * haven't setup any initialization verbs for these yet...
2146 */
2147
2148static hda_nid_t alc880_w810_dac_nids[3] = {
2149 /* front, rear/surround, clfe */
2150 0x02, 0x03, 0x04
2151};
2152
2153/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002154static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002155 { 6, NULL }
2156};
2157
2158/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002159static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002160 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002161 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002162 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002163 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002164 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2165 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002166 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2167 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2169 { } /* end */
2170};
2171
2172
2173/*
2174 * Z710V model
2175 *
2176 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002177 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2178 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 */
2180
2181static hda_nid_t alc880_z71v_dac_nids[1] = {
2182 0x02
2183};
2184#define ALC880_Z71V_HP_DAC 0x03
2185
2186/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002187static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002188 { 2, NULL }
2189};
2190
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002191static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002195 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2200 { } /* end */
2201};
2202
2203
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002204/*
2205 * ALC880 F1734 model
2206 *
2207 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2208 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2209 */
2210
2211static hda_nid_t alc880_f1734_dac_nids[1] = {
2212 0x03
2213};
2214#define ALC880_F1734_HP_DAC 0x02
2215
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002216static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002218 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002219 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002221 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002225 { } /* end */
2226};
2227
Takashi Iwai937b4162008-02-11 14:52:36 +01002228static struct hda_input_mux alc880_f1734_capture_source = {
2229 .num_items = 2,
2230 .items = {
2231 { "Mic", 0x1 },
2232 { "CD", 0x4 },
2233 },
2234};
2235
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002236
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002237/*
2238 * ALC880 ASUS model
2239 *
2240 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2241 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2242 * Mic = 0x18, Line = 0x1a
2243 */
2244
2245#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2246#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2247
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002248static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002250 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002251 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002252 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002253 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2254 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002255 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2256 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002257 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2258 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2259 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2260 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2262 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002263 {
2264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2265 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002266 .info = alc_ch_mode_info,
2267 .get = alc_ch_mode_get,
2268 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002269 },
2270 { } /* end */
2271};
2272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273/*
2274 * ALC880 ASUS W1V model
2275 *
2276 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2277 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2278 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2279 */
2280
2281/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002282static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002283 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2284 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002285 { } /* end */
2286};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002287
Kailang Yangdf694da2005-12-05 19:42:22 +01002288/* TCL S700 */
2289static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2290 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2291 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2292 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2293 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2294 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2295 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2297 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2298 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002299 { } /* end */
2300};
2301
Kailang Yangccc656c2006-10-17 12:32:26 +02002302/* Uniwill */
2303static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002304 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2305 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2307 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002308 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2309 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2310 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2311 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2318 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002320 {
2321 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2322 .name = "Channel Mode",
2323 .info = alc_ch_mode_info,
2324 .get = alc_ch_mode_get,
2325 .put = alc_ch_mode_put,
2326 },
2327 { } /* end */
2328};
2329
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002330static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2331 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2332 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2334 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2335 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2336 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2337 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2338 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2339 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2340 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2341 { } /* end */
2342};
2343
Kailang Yangccc656c2006-10-17 12:32:26 +02002344static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002345 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2346 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2347 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2348 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002349 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2350 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2351 { } /* end */
2352};
2353
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002355 * virtual master controls
2356 */
2357
2358/*
2359 * slave controls for virtual master
2360 */
2361static const char *alc_slave_vols[] = {
2362 "Front Playback Volume",
2363 "Surround Playback Volume",
2364 "Center Playback Volume",
2365 "LFE Playback Volume",
2366 "Side Playback Volume",
2367 "Headphone Playback Volume",
2368 "Speaker Playback Volume",
2369 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002370 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002371 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002372 NULL,
2373};
2374
2375static const char *alc_slave_sws[] = {
2376 "Front Playback Switch",
2377 "Surround Playback Switch",
2378 "Center Playback Switch",
2379 "LFE Playback Switch",
2380 "Side Playback Switch",
2381 "Headphone Playback Switch",
2382 "Speaker Playback Switch",
2383 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002384 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002385 NULL,
2386};
2387
2388/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002389 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002391
2392static void alc_free_kctls(struct hda_codec *codec);
2393
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002394/* additional beep mixers; the actual parameters are overwritten at build */
2395static struct snd_kcontrol_new alc_beep_mixer[] = {
2396 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2398 { } /* end */
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401static int alc_build_controls(struct hda_codec *codec)
2402{
2403 struct alc_spec *spec = codec->spec;
2404 int err;
2405 int i;
2406
2407 for (i = 0; i < spec->num_mixers; i++) {
2408 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2409 if (err < 0)
2410 return err;
2411 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412 if (spec->cap_mixer) {
2413 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2414 if (err < 0)
2415 return err;
2416 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002418 err = snd_hda_create_spdif_out_ctls(codec,
2419 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 if (err < 0)
2421 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002422 if (!spec->no_analog) {
2423 err = snd_hda_create_spdif_share_sw(codec,
2424 &spec->multiout);
2425 if (err < 0)
2426 return err;
2427 spec->multiout.share_spdif = 1;
2428 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 }
2430 if (spec->dig_in_nid) {
2431 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2432 if (err < 0)
2433 return err;
2434 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002435
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002436 /* create beep controls if needed */
2437 if (spec->beep_amp) {
2438 struct snd_kcontrol_new *knew;
2439 for (knew = alc_beep_mixer; knew->name; knew++) {
2440 struct snd_kcontrol *kctl;
2441 kctl = snd_ctl_new1(knew, codec);
2442 if (!kctl)
2443 return -ENOMEM;
2444 kctl->private_value = spec->beep_amp;
2445 err = snd_hda_ctl_add(codec, kctl);
2446 if (err < 0)
2447 return err;
2448 }
2449 }
2450
Takashi Iwai2134ea42008-01-10 16:53:55 +01002451 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002452 if (!spec->no_analog &&
2453 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002454 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002455 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002456 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002457 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002458 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002459 if (err < 0)
2460 return err;
2461 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002462 if (!spec->no_analog &&
2463 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002464 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2465 NULL, alc_slave_sws);
2466 if (err < 0)
2467 return err;
2468 }
2469
Takashi Iwai603c4012008-07-30 15:01:44 +02002470 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 return 0;
2472}
2473
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002474
Linus Torvalds1da177e2005-04-16 15:20:36 -07002475/*
2476 * initialize the codec volumes, etc
2477 */
2478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002479/*
2480 * generic initialization of ADC, input mixers and output mixers
2481 */
2482static struct hda_verb alc880_volume_init_verbs[] = {
2483 /*
2484 * Unmute ADC0-2 and set the default input to mic-in
2485 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002486 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002488 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002490 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002491 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002493 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2494 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002495 * Note: PASD motherboards uses the Line In 2 as the input for front
2496 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2500 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2501 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2502 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2503 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002507 /*
2508 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 /* set vol=0 to output mixers */
2511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2513 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2515 /* set up input amps for analog loopback */
2516 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002517 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2520 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002521 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2524 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525
2526 { }
2527};
2528
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002529/*
2530 * 3-stack pin configuration:
2531 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2532 */
2533static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2534 /*
2535 * preset connection lists of input pins
2536 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2537 */
2538 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2539 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2540 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2541
2542 /*
2543 * Set pin mode and muting
2544 */
2545 /* set front pin widgets 0x14 for output */
2546 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2548 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2549 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2550 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2551 /* Mic2 (as headphone out) for HP output */
2552 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2553 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2554 /* Line In pin widget for input */
2555 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2556 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2557 /* Line2 (as front mic) pin widget for input and vref at 80% */
2558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2559 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2560 /* CD pin widget for input */
2561 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2562
2563 { }
2564};
2565
2566/*
2567 * 5-stack pin configuration:
2568 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2569 * line-in/side = 0x1a, f-mic = 0x1b
2570 */
2571static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2572 /*
2573 * preset connection lists of input pins
2574 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2575 */
2576 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2577 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2578
2579 /*
2580 * Set pin mode and muting
2581 */
2582 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002583 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2585 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2586 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587 /* unmute pins for output (no gain on this amp) */
2588 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2591 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2592
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2596 /* Mic2 (as headphone out) for HP output */
2597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002598 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002599 /* Line In pin widget for input */
2600 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2602 /* Line2 (as front mic) pin widget for input and vref at 80% */
2603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2604 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2605 /* CD pin widget for input */
2606 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607
2608 { }
2609};
2610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611/*
2612 * W810 pin configuration:
2613 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2614 */
2615static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 /* hphone/speaker input selector: front DAC */
2617 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2618
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2620 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2623 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2624 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2625
2626 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002627 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 { }
2630};
2631
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632/*
2633 * Z71V pin configuration:
2634 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2635 */
2636static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002641
Takashi Iwai16ded522005-06-10 19:58:24 +02002642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002646
2647 { }
2648};
2649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650/*
2651 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002652 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2653 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002654 */
2655static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2657
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002664 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2666
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 { }
2678};
Takashi Iwai16ded522005-06-10 19:58:24 +02002679
Kailang Yangccc656c2006-10-17 12:32:26 +02002680/*
2681 * Uniwill pin configuration:
2682 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2683 * line = 0x1a
2684 */
2685static struct hda_verb alc880_uniwill_init_verbs[] = {
2686 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2687
2688 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2689 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2690 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2692 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2693 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2694 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2695 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2696 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2698 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2699 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2700 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2701 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2702
2703 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2704 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2705 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2706 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2707 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2708 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2709 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2710 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2711 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2712
2713 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2714 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2715
2716 { }
2717};
2718
2719/*
2720* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002721* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002722 */
2723static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2724 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
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_HP},
2729 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2730 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2731 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2732 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2733 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2734 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2735 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2736 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2737 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2738
2739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2744 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2745
2746 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2747 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2748
2749 { }
2750};
2751
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002752static struct hda_verb alc880_beep_init_verbs[] = {
2753 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2754 { }
2755};
2756
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002757/* auto-toggle front mic */
2758static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2759{
2760 unsigned int present;
2761 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002762
2763 present = snd_hda_codec_read(codec, 0x18, 0,
2764 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002765 bits = present ? HDA_AMP_MUTE : 0;
2766 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002767}
2768
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002769static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002770{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002771 struct alc_spec *spec = codec->spec;
2772
2773 spec->autocfg.hp_pins[0] = 0x14;
2774 spec->autocfg.speaker_pins[0] = 0x15;
2775 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002776}
2777
2778static void alc880_uniwill_init_hook(struct hda_codec *codec)
2779{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002780 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002781 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002782}
2783
2784static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2785 unsigned int res)
2786{
2787 /* Looks like the unsol event is incompatible with the standard
2788 * definition. 4bit tag is placed at 28 bit!
2789 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002790 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002791 case ALC880_MIC_EVENT:
2792 alc880_uniwill_mic_automute(codec);
2793 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002794 default:
2795 alc_automute_amp_unsol_event(codec, res);
2796 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002797 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002798}
2799
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002800static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002801{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002802 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002803
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002804 spec->autocfg.hp_pins[0] = 0x14;
2805 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002806}
2807
2808static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2809{
2810 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002811
Kailang Yangccc656c2006-10-17 12:32:26 +02002812 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002813 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2814 present &= HDA_AMP_VOLMASK;
2815 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2816 HDA_AMP_VOLMASK, present);
2817 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2818 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002819}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002820
Kailang Yangccc656c2006-10-17 12:32:26 +02002821static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2822 unsigned int res)
2823{
2824 /* Looks like the unsol event is incompatible with the standard
2825 * definition. 4bit tag is placed at 28 bit!
2826 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002827 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002829 else
2830 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002831}
2832
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833/*
2834 * F1734 pin configuration:
2835 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2836 */
2837static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002838 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2840 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2841 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2842 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2843
2844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2847 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848
2849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2850 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002851 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002852 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2853 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2855 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002858
Takashi Iwai937b4162008-02-11 14:52:36 +01002859 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2860 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2861
Takashi Iwai16ded522005-06-10 19:58:24 +02002862 { }
2863};
2864
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002865/*
2866 * ASUS pin configuration:
2867 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2868 */
2869static struct hda_verb alc880_pin_asus_init_verbs[] = {
2870 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2871 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2872 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2873 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2874
2875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883
2884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2885 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2892 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002893
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002894 { }
2895};
2896
2897/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002898#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2899#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002900#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002901
Kailang Yangdf694da2005-12-05 19:42:22 +01002902/* Clevo m520g init */
2903static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2904 /* headphone output */
2905 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2906 /* line-out */
2907 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2908 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2909 /* Line-in */
2910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2912 /* CD */
2913 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2914 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2915 /* Mic1 (rear panel) */
2916 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2917 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 /* Mic2 (front panel) */
2919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 /* headphone */
2922 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2923 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 /* change to EAPD mode */
2925 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2926 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2927
2928 { }
2929};
2930
2931static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002932 /* change to EAPD mode */
2933 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2934 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2935
Kailang Yangdf694da2005-12-05 19:42:22 +01002936 /* Headphone output */
2937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2938 /* Front output*/
2939 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2940 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2941
2942 /* Line In pin widget for input */
2943 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2944 /* CD pin widget for input */
2945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2946 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2947 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2948
2949 /* change to EAPD mode */
2950 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2951 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2952
2953 { }
2954};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002955
2956/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002957 * LG m1 express dual
2958 *
2959 * Pin assignment:
2960 * Rear Line-In/Out (blue): 0x14
2961 * Build-in Mic-In: 0x15
2962 * Speaker-out: 0x17
2963 * HP-Out (green): 0x1b
2964 * Mic-In/Out (red): 0x19
2965 * SPDIF-Out: 0x1e
2966 */
2967
2968/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2969static hda_nid_t alc880_lg_dac_nids[3] = {
2970 0x05, 0x02, 0x03
2971};
2972
2973/* seems analog CD is not working */
2974static struct hda_input_mux alc880_lg_capture_source = {
2975 .num_items = 3,
2976 .items = {
2977 { "Mic", 0x1 },
2978 { "Line", 0x5 },
2979 { "Internal Mic", 0x6 },
2980 },
2981};
2982
2983/* 2,4,6 channel modes */
2984static struct hda_verb alc880_lg_ch2_init[] = {
2985 /* set line-in and mic-in to input */
2986 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2987 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2988 { }
2989};
2990
2991static struct hda_verb alc880_lg_ch4_init[] = {
2992 /* set line-in to out and mic-in to input */
2993 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2994 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2995 { }
2996};
2997
2998static struct hda_verb alc880_lg_ch6_init[] = {
2999 /* set line-in and mic-in to output */
3000 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3001 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3002 { }
3003};
3004
3005static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3006 { 2, alc880_lg_ch2_init },
3007 { 4, alc880_lg_ch4_init },
3008 { 6, alc880_lg_ch6_init },
3009};
3010
3011static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3013 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003014 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3016 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3017 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3018 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3019 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3025 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3026 {
3027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3028 .name = "Channel Mode",
3029 .info = alc_ch_mode_info,
3030 .get = alc_ch_mode_get,
3031 .put = alc_ch_mode_put,
3032 },
3033 { } /* end */
3034};
3035
3036static struct hda_verb alc880_lg_init_verbs[] = {
3037 /* set capture source to mic-in */
3038 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3040 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 /* mute all amp mixer inputs */
3042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003045 /* line-in to input */
3046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3048 /* built-in mic */
3049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3050 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 /* speaker-out */
3052 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3053 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 /* mic-in to input */
3055 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3056 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3057 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3058 /* HP-out */
3059 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3060 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3061 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3062 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003063 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003064 { }
3065};
3066
3067/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003068static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003069{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003070 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003071
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003072 spec->autocfg.hp_pins[0] = 0x1b;
3073 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003074}
3075
3076/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003077 * LG LW20
3078 *
3079 * Pin assignment:
3080 * Speaker-out: 0x14
3081 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003082 * Built-in Mic-In: 0x19
3083 * Line-In: 0x1b
3084 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003085 * SPDIF-Out: 0x1e
3086 */
3087
Takashi Iwaid6815182006-03-23 16:06:23 +01003088static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003089 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003090 .items = {
3091 { "Mic", 0x0 },
3092 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003093 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003094 },
3095};
3096
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003097#define alc880_lg_lw_modes alc880_threestack_modes
3098
Takashi Iwaid6815182006-03-23 16:06:23 +01003099static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3101 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3102 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3103 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3104 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3105 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3106 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3107 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3108 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3109 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3111 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3112 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3113 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003114 {
3115 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3116 .name = "Channel Mode",
3117 .info = alc_ch_mode_info,
3118 .get = alc_ch_mode_get,
3119 .put = alc_ch_mode_put,
3120 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003121 { } /* end */
3122};
3123
3124static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003125 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3126 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3127 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3128
Takashi Iwaid6815182006-03-23 16:06:23 +01003129 /* set capture source to mic-in */
3130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3132 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003133 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003134 /* speaker-out */
3135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3136 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3137 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3140 /* mic-in to input */
3141 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3142 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3143 /* built-in mic */
3144 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3145 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003147 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003148 { }
3149};
3150
3151/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003152static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003153{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003154 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003155
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003156 spec->autocfg.hp_pins[0] = 0x1b;
3157 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003158}
3159
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003160static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3161 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3162 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3165 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3166 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3167 { } /* end */
3168};
3169
3170static struct hda_input_mux alc880_medion_rim_capture_source = {
3171 .num_items = 2,
3172 .items = {
3173 { "Mic", 0x0 },
3174 { "Internal Mic", 0x1 },
3175 },
3176};
3177
3178static struct hda_verb alc880_medion_rim_init_verbs[] = {
3179 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3180
3181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183
3184 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3185 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3187 /* Mic2 (as headphone out) for HP output */
3188 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3189 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3190 /* Internal Speaker */
3191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3192 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193
3194 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3195 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3196
3197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3198 { }
3199};
3200
3201/* toggle speaker-output according to the hp-jack state */
3202static void alc880_medion_rim_automute(struct hda_codec *codec)
3203{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003204 struct alc_spec *spec = codec->spec;
3205 alc_automute_amp(codec);
3206 /* toggle EAPD */
3207 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003208 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3209 else
3210 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3211}
3212
3213static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3214 unsigned int res)
3215{
3216 /* Looks like the unsol event is incompatible with the standard
3217 * definition. 4bit tag is placed at 28 bit!
3218 */
3219 if ((res >> 28) == ALC880_HP_EVENT)
3220 alc880_medion_rim_automute(codec);
3221}
3222
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003223static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003224{
3225 struct alc_spec *spec = codec->spec;
3226
3227 spec->autocfg.hp_pins[0] = 0x14;
3228 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003229}
3230
Takashi Iwaicb53c622007-08-10 17:21:45 +02003231#ifdef CONFIG_SND_HDA_POWER_SAVE
3232static struct hda_amp_list alc880_loopbacks[] = {
3233 { 0x0b, HDA_INPUT, 0 },
3234 { 0x0b, HDA_INPUT, 1 },
3235 { 0x0b, HDA_INPUT, 2 },
3236 { 0x0b, HDA_INPUT, 3 },
3237 { 0x0b, HDA_INPUT, 4 },
3238 { } /* end */
3239};
3240
3241static struct hda_amp_list alc880_lg_loopbacks[] = {
3242 { 0x0b, HDA_INPUT, 1 },
3243 { 0x0b, HDA_INPUT, 6 },
3244 { 0x0b, HDA_INPUT, 7 },
3245 { } /* end */
3246};
3247#endif
3248
Takashi Iwaid6815182006-03-23 16:06:23 +01003249/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003250 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003252
Linus Torvalds1da177e2005-04-16 15:20:36 -07003253static int alc_init(struct hda_codec *codec)
3254{
3255 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 unsigned int i;
3257
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003258 alc_fix_pll(codec);
Takashi Iwai4a79ba342009-04-22 16:31:35 +02003259 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003260
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 for (i = 0; i < spec->num_init_verbs; i++)
3262 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003263
3264 if (spec->init_hook)
3265 spec->init_hook(codec);
3266
Linus Torvalds1da177e2005-04-16 15:20:36 -07003267 return 0;
3268}
3269
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003270static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3271{
3272 struct alc_spec *spec = codec->spec;
3273
3274 if (spec->unsol_event)
3275 spec->unsol_event(codec, res);
3276}
3277
Takashi Iwaicb53c622007-08-10 17:21:45 +02003278#ifdef CONFIG_SND_HDA_POWER_SAVE
3279static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3280{
3281 struct alc_spec *spec = codec->spec;
3282 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3283}
3284#endif
3285
Linus Torvalds1da177e2005-04-16 15:20:36 -07003286/*
3287 * Analog playback callbacks
3288 */
3289static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3290 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003291 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003292{
3293 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003294 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3295 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003296}
3297
3298static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3299 struct hda_codec *codec,
3300 unsigned int stream_tag,
3301 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003302 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003303{
3304 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003305 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3306 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307}
3308
3309static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3310 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003311 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003312{
3313 struct alc_spec *spec = codec->spec;
3314 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3315}
3316
3317/*
3318 * Digital out
3319 */
3320static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3321 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003322 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003323{
3324 struct alc_spec *spec = codec->spec;
3325 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3326}
3327
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003328static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3329 struct hda_codec *codec,
3330 unsigned int stream_tag,
3331 unsigned int format,
3332 struct snd_pcm_substream *substream)
3333{
3334 struct alc_spec *spec = codec->spec;
3335 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3336 stream_tag, format, substream);
3337}
3338
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003339static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3340 struct hda_codec *codec,
3341 struct snd_pcm_substream *substream)
3342{
3343 struct alc_spec *spec = codec->spec;
3344 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3345}
3346
Linus Torvalds1da177e2005-04-16 15:20:36 -07003347static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3348 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003349 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350{
3351 struct alc_spec *spec = codec->spec;
3352 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3353}
3354
3355/*
3356 * Analog capture
3357 */
Takashi Iwai63300792008-01-24 15:31:36 +01003358static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003359 struct hda_codec *codec,
3360 unsigned int stream_tag,
3361 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003362 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363{
3364 struct alc_spec *spec = codec->spec;
3365
Takashi Iwai63300792008-01-24 15:31:36 +01003366 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003367 stream_tag, 0, format);
3368 return 0;
3369}
3370
Takashi Iwai63300792008-01-24 15:31:36 +01003371static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003373 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374{
3375 struct alc_spec *spec = codec->spec;
3376
Takashi Iwai888afa12008-03-18 09:57:50 +01003377 snd_hda_codec_cleanup_stream(codec,
3378 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003379 return 0;
3380}
3381
3382
3383/*
3384 */
3385static struct hda_pcm_stream alc880_pcm_analog_playback = {
3386 .substreams = 1,
3387 .channels_min = 2,
3388 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003390 .ops = {
3391 .open = alc880_playback_pcm_open,
3392 .prepare = alc880_playback_pcm_prepare,
3393 .cleanup = alc880_playback_pcm_cleanup
3394 },
3395};
3396
3397static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003398 .substreams = 1,
3399 .channels_min = 2,
3400 .channels_max = 2,
3401 /* NID is set in alc_build_pcms */
3402};
3403
3404static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3405 .substreams = 1,
3406 .channels_min = 2,
3407 .channels_max = 2,
3408 /* NID is set in alc_build_pcms */
3409};
3410
3411static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3412 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003413 .channels_min = 2,
3414 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003415 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003416 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003417 .prepare = alc880_alt_capture_pcm_prepare,
3418 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419 },
3420};
3421
3422static struct hda_pcm_stream alc880_pcm_digital_playback = {
3423 .substreams = 1,
3424 .channels_min = 2,
3425 .channels_max = 2,
3426 /* NID is set in alc_build_pcms */
3427 .ops = {
3428 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003429 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003430 .prepare = alc880_dig_playback_pcm_prepare,
3431 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003432 },
3433};
3434
3435static struct hda_pcm_stream alc880_pcm_digital_capture = {
3436 .substreams = 1,
3437 .channels_min = 2,
3438 .channels_max = 2,
3439 /* NID is set in alc_build_pcms */
3440};
3441
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003442/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003443static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003444 .substreams = 0,
3445 .channels_min = 0,
3446 .channels_max = 0,
3447};
3448
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449static int alc_build_pcms(struct hda_codec *codec)
3450{
3451 struct alc_spec *spec = codec->spec;
3452 struct hda_pcm *info = spec->pcm_rec;
3453 int i;
3454
3455 codec->num_pcms = 1;
3456 codec->pcm_info = info;
3457
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003458 if (spec->no_analog)
3459 goto skip_analog;
3460
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003461 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3462 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003463 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003464
Takashi Iwai4a471b72005-12-07 13:56:29 +01003465 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003466 if (snd_BUG_ON(!spec->multiout.dac_nids))
3467 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003468 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3469 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3470 }
3471 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003472 if (snd_BUG_ON(!spec->adc_nids))
3473 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003474 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3475 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3476 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003477
Takashi Iwai4a471b72005-12-07 13:56:29 +01003478 if (spec->channel_mode) {
3479 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3480 for (i = 0; i < spec->num_channel_mode; i++) {
3481 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3482 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3483 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484 }
3485 }
3486
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003487 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003488 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003490 snprintf(spec->stream_name_digital,
3491 sizeof(spec->stream_name_digital),
3492 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003493 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003494 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003495 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003497 if (spec->dig_out_type)
3498 info->pcm_type = spec->dig_out_type;
3499 else
3500 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003501 if (spec->multiout.dig_out_nid &&
3502 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003503 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3504 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3505 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003506 if (spec->dig_in_nid &&
3507 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3509 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3510 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003511 /* FIXME: do we need this for all Realtek codec models? */
3512 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 }
3514
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003515 if (spec->no_analog)
3516 return 0;
3517
Takashi Iwaie08a0072006-09-07 17:52:14 +02003518 /* If the use of more than one ADC is requested for the current
3519 * model, configure a second analog capture-only PCM.
3520 */
3521 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003522 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3523 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003524 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003525 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003526 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003527 if (spec->alt_dac_nid) {
3528 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3529 *spec->stream_analog_alt_playback;
3530 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3531 spec->alt_dac_nid;
3532 } else {
3533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3534 alc_pcm_null_stream;
3535 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3536 }
3537 if (spec->num_adc_nids > 1) {
3538 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3539 *spec->stream_analog_alt_capture;
3540 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3541 spec->adc_nids[1];
3542 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3543 spec->num_adc_nids - 1;
3544 } else {
3545 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3546 alc_pcm_null_stream;
3547 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003548 }
3549 }
3550
Linus Torvalds1da177e2005-04-16 15:20:36 -07003551 return 0;
3552}
3553
Takashi Iwai603c4012008-07-30 15:01:44 +02003554static void alc_free_kctls(struct hda_codec *codec)
3555{
3556 struct alc_spec *spec = codec->spec;
3557
3558 if (spec->kctls.list) {
3559 struct snd_kcontrol_new *kctl = spec->kctls.list;
3560 int i;
3561 for (i = 0; i < spec->kctls.used; i++)
3562 kfree(kctl[i].name);
3563 }
3564 snd_array_free(&spec->kctls);
3565}
3566
Linus Torvalds1da177e2005-04-16 15:20:36 -07003567static void alc_free(struct hda_codec *codec)
3568{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003569 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003570
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003571 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003572 return;
3573
Takashi Iwai603c4012008-07-30 15:01:44 +02003574 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003576 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003577}
3578
Takashi Iwaie044c392008-10-27 16:56:24 +01003579#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003580static int alc_resume(struct hda_codec *codec)
3581{
Takashi Iwaie044c392008-10-27 16:56:24 +01003582 codec->patch_ops.init(codec);
3583 snd_hda_codec_resume_amp(codec);
3584 snd_hda_codec_resume_cache(codec);
3585 return 0;
3586}
Takashi Iwaie044c392008-10-27 16:56:24 +01003587#endif
3588
Linus Torvalds1da177e2005-04-16 15:20:36 -07003589/*
3590 */
3591static struct hda_codec_ops alc_patch_ops = {
3592 .build_controls = alc_build_controls,
3593 .build_pcms = alc_build_pcms,
3594 .init = alc_init,
3595 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003596 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003597#ifdef SND_HDA_NEEDS_RESUME
3598 .resume = alc_resume,
3599#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003600#ifdef CONFIG_SND_HDA_POWER_SAVE
3601 .check_power_status = alc_check_power_status,
3602#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003603};
3604
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003605
3606/*
3607 * Test configuration for debugging
3608 *
3609 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3610 * enum controls.
3611 */
3612#ifdef CONFIG_SND_DEBUG
3613static hda_nid_t alc880_test_dac_nids[4] = {
3614 0x02, 0x03, 0x04, 0x05
3615};
3616
3617static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003618 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003619 .items = {
3620 { "In-1", 0x0 },
3621 { "In-2", 0x1 },
3622 { "In-3", 0x2 },
3623 { "In-4", 0x3 },
3624 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003625 { "Front", 0x5 },
3626 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003627 },
3628};
3629
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003630static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003631 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003632 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003633 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003634 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003635};
3636
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003637static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3638 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003639{
3640 static char *texts[] = {
3641 "N/A", "Line Out", "HP Out",
3642 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3643 };
3644 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3645 uinfo->count = 1;
3646 uinfo->value.enumerated.items = 8;
3647 if (uinfo->value.enumerated.item >= 8)
3648 uinfo->value.enumerated.item = 7;
3649 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3650 return 0;
3651}
3652
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003653static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3654 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003655{
3656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3657 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3658 unsigned int pin_ctl, item = 0;
3659
3660 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3661 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3662 if (pin_ctl & AC_PINCTL_OUT_EN) {
3663 if (pin_ctl & AC_PINCTL_HP_EN)
3664 item = 2;
3665 else
3666 item = 1;
3667 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3668 switch (pin_ctl & AC_PINCTL_VREFEN) {
3669 case AC_PINCTL_VREF_HIZ: item = 3; break;
3670 case AC_PINCTL_VREF_50: item = 4; break;
3671 case AC_PINCTL_VREF_GRD: item = 5; break;
3672 case AC_PINCTL_VREF_80: item = 6; break;
3673 case AC_PINCTL_VREF_100: item = 7; break;
3674 }
3675 }
3676 ucontrol->value.enumerated.item[0] = item;
3677 return 0;
3678}
3679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003680static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3681 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003682{
3683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3684 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3685 static unsigned int ctls[] = {
3686 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3687 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3688 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3689 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3690 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3691 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3692 };
3693 unsigned int old_ctl, new_ctl;
3694
3695 old_ctl = snd_hda_codec_read(codec, nid, 0,
3696 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3697 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3698 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003699 int val;
3700 snd_hda_codec_write_cache(codec, nid, 0,
3701 AC_VERB_SET_PIN_WIDGET_CONTROL,
3702 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003703 val = ucontrol->value.enumerated.item[0] >= 3 ?
3704 HDA_AMP_MUTE : 0;
3705 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3706 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003707 return 1;
3708 }
3709 return 0;
3710}
3711
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003712static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3713 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003714{
3715 static char *texts[] = {
3716 "Front", "Surround", "CLFE", "Side"
3717 };
3718 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3719 uinfo->count = 1;
3720 uinfo->value.enumerated.items = 4;
3721 if (uinfo->value.enumerated.item >= 4)
3722 uinfo->value.enumerated.item = 3;
3723 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3724 return 0;
3725}
3726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003727static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3728 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003729{
3730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3731 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3732 unsigned int sel;
3733
3734 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3735 ucontrol->value.enumerated.item[0] = sel & 3;
3736 return 0;
3737}
3738
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003739static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3740 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003741{
3742 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3743 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3744 unsigned int sel;
3745
3746 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3747 if (ucontrol->value.enumerated.item[0] != sel) {
3748 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003749 snd_hda_codec_write_cache(codec, nid, 0,
3750 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003751 return 1;
3752 }
3753 return 0;
3754}
3755
3756#define PIN_CTL_TEST(xname,nid) { \
3757 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3758 .name = xname, \
3759 .info = alc_test_pin_ctl_info, \
3760 .get = alc_test_pin_ctl_get, \
3761 .put = alc_test_pin_ctl_put, \
3762 .private_value = nid \
3763 }
3764
3765#define PIN_SRC_TEST(xname,nid) { \
3766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3767 .name = xname, \
3768 .info = alc_test_pin_src_info, \
3769 .get = alc_test_pin_src_get, \
3770 .put = alc_test_pin_src_put, \
3771 .private_value = nid \
3772 }
3773
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003774static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003775 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3776 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3777 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3778 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3780 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3781 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3782 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003783 PIN_CTL_TEST("Front Pin Mode", 0x14),
3784 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3785 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3786 PIN_CTL_TEST("Side Pin Mode", 0x17),
3787 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3788 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3789 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3790 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3791 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3792 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3793 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3794 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3795 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3796 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3797 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3798 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3799 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3800 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3801 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3802 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3803 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3804 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 {
3806 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3807 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003808 .info = alc_ch_mode_info,
3809 .get = alc_ch_mode_get,
3810 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003811 },
3812 { } /* end */
3813};
3814
3815static struct hda_verb alc880_test_init_verbs[] = {
3816 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3819 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3820 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3822 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3824 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003825 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003826 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3827 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3828 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3832 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3833 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3834 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003835 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3837 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3838 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3839 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003840 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003841 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3842 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003843 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3844 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003846 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003847 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3848 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3849 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3850 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003851 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003853 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003855 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003856 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003857 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 /* Analog input/passthru */
3859 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3860 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3861 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3862 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3863 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003864 { }
3865};
3866#endif
3867
Linus Torvalds1da177e2005-04-16 15:20:36 -07003868/*
3869 */
3870
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003871static const char *alc880_models[ALC880_MODEL_LAST] = {
3872 [ALC880_3ST] = "3stack",
3873 [ALC880_TCL_S700] = "tcl",
3874 [ALC880_3ST_DIG] = "3stack-digout",
3875 [ALC880_CLEVO] = "clevo",
3876 [ALC880_5ST] = "5stack",
3877 [ALC880_5ST_DIG] = "5stack-digout",
3878 [ALC880_W810] = "w810",
3879 [ALC880_Z71V] = "z71v",
3880 [ALC880_6ST] = "6stack",
3881 [ALC880_6ST_DIG] = "6stack-digout",
3882 [ALC880_ASUS] = "asus",
3883 [ALC880_ASUS_W1V] = "asus-w1v",
3884 [ALC880_ASUS_DIG] = "asus-dig",
3885 [ALC880_ASUS_DIG2] = "asus-dig2",
3886 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003887 [ALC880_UNIWILL_P53] = "uniwill-p53",
3888 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003889 [ALC880_F1734] = "F1734",
3890 [ALC880_LG] = "lg",
3891 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003892 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003893#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003894 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003895#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003896 [ALC880_AUTO] = "auto",
3897};
3898
3899static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003900 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003901 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3902 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3903 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3904 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3905 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3906 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3907 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3908 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003909 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3910 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3912 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3913 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3914 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3915 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3916 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3917 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3918 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3919 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3920 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003921 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003922 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3923 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3924 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003925 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003926 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003927 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3928 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003929 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3930 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003931 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3932 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3933 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3934 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003935 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3936 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003937 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003938 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003939 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003940 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3942 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003943 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003944 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003945 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003947 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003948 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003949 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003950 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003951 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3953 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003955 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3956 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3957 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3958 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003959 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3960 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003961 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003962 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003963 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3964 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003965 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3966 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3967 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003968 /* default Intel */
3969 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3971 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 {}
3973};
3974
Takashi Iwai16ded522005-06-10 19:58:24 +02003975/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003976 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003977 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003978static struct alc_config_preset alc880_presets[] = {
3979 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003980 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003981 .init_verbs = { alc880_volume_init_verbs,
3982 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003983 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003984 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003985 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3986 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003987 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003988 .input_mux = &alc880_capture_source,
3989 },
3990 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003992 .init_verbs = { alc880_volume_init_verbs,
3993 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003994 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003995 .dac_nids = alc880_dac_nids,
3996 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003997 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3998 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003999 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 .input_mux = &alc880_capture_source,
4001 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004002 [ALC880_TCL_S700] = {
4003 .mixers = { alc880_tcl_s700_mixer },
4004 .init_verbs = { alc880_volume_init_verbs,
4005 alc880_pin_tcl_S700_init_verbs,
4006 alc880_gpio2_init_verbs },
4007 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4008 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004009 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4010 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004011 .hp_nid = 0x03,
4012 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4013 .channel_mode = alc880_2_jack_modes,
4014 .input_mux = &alc880_capture_source,
4015 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004016 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004017 .mixers = { alc880_three_stack_mixer,
4018 alc880_five_stack_mixer},
4019 .init_verbs = { alc880_volume_init_verbs,
4020 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4022 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004023 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4024 .channel_mode = alc880_fivestack_modes,
4025 .input_mux = &alc880_capture_source,
4026 },
4027 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004028 .mixers = { alc880_three_stack_mixer,
4029 alc880_five_stack_mixer },
4030 .init_verbs = { alc880_volume_init_verbs,
4031 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004032 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4033 .dac_nids = alc880_dac_nids,
4034 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004035 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4036 .channel_mode = alc880_fivestack_modes,
4037 .input_mux = &alc880_capture_source,
4038 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004039 [ALC880_6ST] = {
4040 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004041 .init_verbs = { alc880_volume_init_verbs,
4042 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004043 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4044 .dac_nids = alc880_6st_dac_nids,
4045 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4046 .channel_mode = alc880_sixstack_modes,
4047 .input_mux = &alc880_6stack_capture_source,
4048 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004049 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004051 .init_verbs = { alc880_volume_init_verbs,
4052 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004053 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4054 .dac_nids = alc880_6st_dac_nids,
4055 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004056 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4057 .channel_mode = alc880_sixstack_modes,
4058 .input_mux = &alc880_6stack_capture_source,
4059 },
4060 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004061 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004062 .init_verbs = { alc880_volume_init_verbs,
4063 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004064 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004065 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4066 .dac_nids = alc880_w810_dac_nids,
4067 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4069 .channel_mode = alc880_w810_modes,
4070 .input_mux = &alc880_capture_source,
4071 },
4072 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004074 .init_verbs = { alc880_volume_init_verbs,
4075 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004076 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4077 .dac_nids = alc880_z71v_dac_nids,
4078 .dig_out_nid = ALC880_DIGOUT_NID,
4079 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4081 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004082 .input_mux = &alc880_capture_source,
4083 },
4084 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004086 .init_verbs = { alc880_volume_init_verbs,
4087 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4089 .dac_nids = alc880_f1734_dac_nids,
4090 .hp_nid = 0x02,
4091 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4092 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004093 .input_mux = &alc880_f1734_capture_source,
4094 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004095 .setup = alc880_uniwill_p53_setup,
4096 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004097 },
4098 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004099 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004100 .init_verbs = { alc880_volume_init_verbs,
4101 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004102 alc880_gpio1_init_verbs },
4103 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4104 .dac_nids = alc880_asus_dac_nids,
4105 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4106 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004107 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004108 .input_mux = &alc880_capture_source,
4109 },
4110 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004111 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004112 .init_verbs = { alc880_volume_init_verbs,
4113 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004114 alc880_gpio1_init_verbs },
4115 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4116 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004117 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4119 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004120 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004121 .input_mux = &alc880_capture_source,
4122 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004123 [ALC880_ASUS_DIG2] = {
4124 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004125 .init_verbs = { alc880_volume_init_verbs,
4126 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004127 alc880_gpio2_init_verbs }, /* use GPIO2 */
4128 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4129 .dac_nids = alc880_asus_dac_nids,
4130 .dig_out_nid = ALC880_DIGOUT_NID,
4131 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4132 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004133 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004134 .input_mux = &alc880_capture_source,
4135 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004136 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004137 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004138 .init_verbs = { alc880_volume_init_verbs,
4139 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004140 alc880_gpio1_init_verbs },
4141 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4142 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004143 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4145 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004146 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004147 .input_mux = &alc880_capture_source,
4148 },
4149 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004150 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004151 .init_verbs = { alc880_volume_init_verbs,
4152 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004153 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4154 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004155 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004156 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4157 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004158 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004159 .input_mux = &alc880_capture_source,
4160 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004161 [ALC880_UNIWILL] = {
4162 .mixers = { alc880_uniwill_mixer },
4163 .init_verbs = { alc880_volume_init_verbs,
4164 alc880_uniwill_init_verbs },
4165 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4166 .dac_nids = alc880_asus_dac_nids,
4167 .dig_out_nid = ALC880_DIGOUT_NID,
4168 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4169 .channel_mode = alc880_threestack_modes,
4170 .need_dac_fix = 1,
4171 .input_mux = &alc880_capture_source,
4172 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004173 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004174 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004175 },
4176 [ALC880_UNIWILL_P53] = {
4177 .mixers = { alc880_uniwill_p53_mixer },
4178 .init_verbs = { alc880_volume_init_verbs,
4179 alc880_uniwill_p53_init_verbs },
4180 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4181 .dac_nids = alc880_asus_dac_nids,
4182 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004183 .channel_mode = alc880_threestack_modes,
4184 .input_mux = &alc880_capture_source,
4185 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004186 .setup = alc880_uniwill_p53_setup,
4187 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004188 },
4189 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004190 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004191 .init_verbs = { alc880_volume_init_verbs,
4192 alc880_uniwill_p53_init_verbs,
4193 alc880_beep_init_verbs },
4194 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4195 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004196 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004197 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4198 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004199 .input_mux = &alc880_capture_source,
4200 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004201 .setup = alc880_uniwill_p53_setup,
4202 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004203 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004204 [ALC880_CLEVO] = {
4205 .mixers = { alc880_three_stack_mixer },
4206 .init_verbs = { alc880_volume_init_verbs,
4207 alc880_pin_clevo_init_verbs },
4208 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4209 .dac_nids = alc880_dac_nids,
4210 .hp_nid = 0x03,
4211 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4212 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004213 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004214 .input_mux = &alc880_capture_source,
4215 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004216 [ALC880_LG] = {
4217 .mixers = { alc880_lg_mixer },
4218 .init_verbs = { alc880_volume_init_verbs,
4219 alc880_lg_init_verbs },
4220 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4221 .dac_nids = alc880_lg_dac_nids,
4222 .dig_out_nid = ALC880_DIGOUT_NID,
4223 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4224 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004225 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004226 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004227 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004228 .setup = alc880_lg_setup,
4229 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004230#ifdef CONFIG_SND_HDA_POWER_SAVE
4231 .loopbacks = alc880_lg_loopbacks,
4232#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004233 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004234 [ALC880_LG_LW] = {
4235 .mixers = { alc880_lg_lw_mixer },
4236 .init_verbs = { alc880_volume_init_verbs,
4237 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004238 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004239 .dac_nids = alc880_dac_nids,
4240 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004241 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4242 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004243 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004244 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004245 .setup = alc880_lg_lw_setup,
4246 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004247 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004248 [ALC880_MEDION_RIM] = {
4249 .mixers = { alc880_medion_rim_mixer },
4250 .init_verbs = { alc880_volume_init_verbs,
4251 alc880_medion_rim_init_verbs,
4252 alc_gpio2_init_verbs },
4253 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4254 .dac_nids = alc880_dac_nids,
4255 .dig_out_nid = ALC880_DIGOUT_NID,
4256 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4257 .channel_mode = alc880_2_jack_modes,
4258 .input_mux = &alc880_medion_rim_capture_source,
4259 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004260 .setup = alc880_medion_rim_setup,
4261 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004262 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004263#ifdef CONFIG_SND_DEBUG
4264 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 .mixers = { alc880_test_mixer },
4266 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004267 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4268 .dac_nids = alc880_test_dac_nids,
4269 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004270 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4271 .channel_mode = alc880_test_modes,
4272 .input_mux = &alc880_test_capture_source,
4273 },
4274#endif
4275};
4276
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004277/*
4278 * Automatic parse of I/O pins from the BIOS configuration
4279 */
4280
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281enum {
4282 ALC_CTL_WIDGET_VOL,
4283 ALC_CTL_WIDGET_MUTE,
4284 ALC_CTL_BIND_MUTE,
4285};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004286static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004287 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4288 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004289 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290};
4291
4292/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004293static int add_control(struct alc_spec *spec, int type, const char *name,
4294 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004296 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297
Takashi Iwai603c4012008-07-30 15:01:44 +02004298 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4299 knew = snd_array_new(&spec->kctls);
4300 if (!knew)
4301 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004302 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004303 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305 return -ENOMEM;
4306 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004307 return 0;
4308}
4309
4310#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4311#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4312#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4313#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004314#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4315#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4316#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4317#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4318#define ALC880_PIN_CD_NID 0x1c
4319
4320/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004321static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4322 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323{
4324 hda_nid_t nid;
4325 int assigned[4];
4326 int i, j;
4327
4328 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004329 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004330
4331 /* check the pins hardwired to audio widget */
4332 for (i = 0; i < cfg->line_outs; i++) {
4333 nid = cfg->line_out_pins[i];
4334 if (alc880_is_fixed_pin(nid)) {
4335 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004336 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004337 assigned[idx] = 1;
4338 }
4339 }
4340 /* left pins can be connect to any audio widget */
4341 for (i = 0; i < cfg->line_outs; i++) {
4342 nid = cfg->line_out_pins[i];
4343 if (alc880_is_fixed_pin(nid))
4344 continue;
4345 /* search for an empty channel */
4346 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004347 if (!assigned[j]) {
4348 spec->multiout.dac_nids[i] =
4349 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004350 assigned[j] = 1;
4351 break;
4352 }
4353 }
4354 }
4355 spec->multiout.num_dacs = cfg->line_outs;
4356 return 0;
4357}
4358
4359/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004360static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4361 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004362{
4363 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004364 static const char *chname[4] = {
4365 "Front", "Surround", NULL /*CLFE*/, "Side"
4366 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004367 hda_nid_t nid;
4368 int i, err;
4369
4370 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004371 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372 continue;
4373 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4374 if (i == 2) {
4375 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004376 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4377 "Center Playback Volume",
4378 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4379 HDA_OUTPUT));
4380 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004382 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4383 "LFE Playback Volume",
4384 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4385 HDA_OUTPUT));
4386 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004387 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004388 err = add_control(spec, ALC_CTL_BIND_MUTE,
4389 "Center Playback Switch",
4390 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4391 HDA_INPUT));
4392 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004393 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004394 err = add_control(spec, ALC_CTL_BIND_MUTE,
4395 "LFE Playback Switch",
4396 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4397 HDA_INPUT));
4398 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004399 return err;
4400 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004401 const char *pfx;
4402 if (cfg->line_outs == 1 &&
4403 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4404 pfx = "Speaker";
4405 else
4406 pfx = chname[i];
4407 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004408 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4409 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4410 HDA_OUTPUT));
4411 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 return err;
Takashi Iwaicb162b62009-08-25 16:05:03 +02004413 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004414 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4415 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4416 HDA_INPUT));
4417 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 return err;
4419 }
4420 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004421 return 0;
4422}
4423
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004424/* add playback controls for speaker and HP outputs */
4425static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4426 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427{
4428 hda_nid_t nid;
4429 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004430 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004432 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433 return 0;
4434
4435 if (alc880_is_fixed_pin(pin)) {
4436 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004437 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004438 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004439 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004440 else
4441 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442 /* control HP volume/switch on the output mixer amp */
4443 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004444 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004445 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4446 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4447 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004448 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004449 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004450 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4451 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4452 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004453 return err;
4454 } else if (alc880_is_multi_pin(pin)) {
4455 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004457 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004458 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4459 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4460 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461 return err;
4462 }
4463 return 0;
4464}
4465
4466/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004467static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4468 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004469 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004470{
4471 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004472 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004473
4474 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4476 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4477 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 return err;
4479 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004480 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4481 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4482 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004483 return err;
4484 return 0;
4485}
4486
Takashi Iwai05f5f472009-08-25 13:10:18 +02004487static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004489 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4490 return (pincap & AC_PINCAP_IN) != 0;
4491}
4492
4493/* create playback/capture controls for input pins */
4494static int alc_auto_create_input_ctls(struct hda_codec *codec,
4495 const struct auto_pin_cfg *cfg,
4496 hda_nid_t mixer,
4497 hda_nid_t cap1, hda_nid_t cap2)
4498{
4499 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004500 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004501 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004502
4503 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004504 hda_nid_t pin;
4505
4506 pin = cfg->input_pins[i];
4507 if (!alc_is_input_pin(codec, pin))
4508 continue;
4509
4510 if (mixer) {
4511 idx = get_connection_index(codec, mixer, pin);
4512 if (idx >= 0) {
4513 err = new_analog_input(spec, pin,
4514 auto_pin_cfg_labels[i],
4515 idx, mixer);
4516 if (err < 0)
4517 return err;
4518 }
4519 }
4520
4521 if (!cap1)
4522 continue;
4523 idx = get_connection_index(codec, cap1, pin);
4524 if (idx < 0 && cap2)
4525 idx = get_connection_index(codec, cap2, pin);
4526 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004527 imux->items[imux->num_items].label =
4528 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004529 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530 imux->num_items++;
4531 }
4532 }
4533 return 0;
4534}
4535
Takashi Iwai05f5f472009-08-25 13:10:18 +02004536static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4537 const struct auto_pin_cfg *cfg)
4538{
4539 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4540}
4541
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004542static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4543 unsigned int pin_type)
4544{
4545 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4546 pin_type);
4547 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004548 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4549 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004550}
4551
Kailang Yangdf694da2005-12-05 19:42:22 +01004552static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4553 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004554 int dac_idx)
4555{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004556 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004557 /* need the manual connection? */
4558 if (alc880_is_multi_pin(nid)) {
4559 struct alc_spec *spec = codec->spec;
4560 int idx = alc880_multi_pin_idx(nid);
4561 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4562 AC_VERB_SET_CONNECT_SEL,
4563 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4564 }
4565}
4566
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004567static int get_pin_type(int line_out_type)
4568{
4569 if (line_out_type == AUTO_PIN_HP_OUT)
4570 return PIN_HP;
4571 else
4572 return PIN_OUT;
4573}
4574
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575static void alc880_auto_init_multi_out(struct hda_codec *codec)
4576{
4577 struct alc_spec *spec = codec->spec;
4578 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004579
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004580 for (i = 0; i < spec->autocfg.line_outs; i++) {
4581 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004582 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4583 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 }
4585}
4586
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004587static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004588{
4589 struct alc_spec *spec = codec->spec;
4590 hda_nid_t pin;
4591
Takashi Iwai82bc9552006-03-21 11:24:42 +01004592 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004593 if (pin) /* connect to front */
4594 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004595 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004596 if (pin) /* connect to front */
4597 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4598}
4599
4600static void alc880_auto_init_analog_input(struct hda_codec *codec)
4601{
4602 struct alc_spec *spec = codec->spec;
4603 int i;
4604
4605 for (i = 0; i < AUTO_PIN_LAST; i++) {
4606 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004607 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004608 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004609 if (nid != ALC880_PIN_CD_NID &&
4610 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004611 snd_hda_codec_write(codec, nid, 0,
4612 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 AMP_OUT_MUTE);
4614 }
4615 }
4616}
4617
4618/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004619/* return 1 if successful, 0 if the proper config is not found,
4620 * or a negative error code
4621 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004622static int alc880_parse_auto_config(struct hda_codec *codec)
4623{
4624 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004625 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004626 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004627
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004628 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4629 alc880_ignore);
4630 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004632 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004634
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004635 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4636 if (err < 0)
4637 return err;
4638 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4639 if (err < 0)
4640 return err;
4641 err = alc880_auto_create_extra_out(spec,
4642 spec->autocfg.speaker_pins[0],
4643 "Speaker");
4644 if (err < 0)
4645 return err;
4646 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4647 "Headphone");
4648 if (err < 0)
4649 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004650 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004651 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 return err;
4653
4654 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4655
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004656 /* check multiple SPDIF-out (for recent codecs) */
4657 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4658 hda_nid_t dig_nid;
4659 err = snd_hda_get_connections(codec,
4660 spec->autocfg.dig_out_pins[i],
4661 &dig_nid, 1);
4662 if (err < 0)
4663 continue;
4664 if (!i)
4665 spec->multiout.dig_out_nid = dig_nid;
4666 else {
4667 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4668 spec->slave_dig_outs[i - 1] = dig_nid;
4669 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4670 break;
4671 }
4672 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004673 if (spec->autocfg.dig_in_pin)
4674 spec->dig_in_nid = ALC880_DIGIN_NID;
4675
Takashi Iwai603c4012008-07-30 15:01:44 +02004676 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004677 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004678
Takashi Iwaid88897e2008-10-31 15:01:37 +01004679 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004681 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004682 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004683
Takashi Iwai4a79ba342009-04-22 16:31:35 +02004684 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004686 return 1;
4687}
4688
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004689/* additional initialization for auto-configuration model */
4690static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004691{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004692 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004693 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004694 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004695 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004696 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004697 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004698}
4699
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004700/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4701 * one of two digital mic pins, e.g. on ALC272
4702 */
4703static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004704{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004705 struct alc_spec *spec = codec->spec;
4706 int i;
4707
4708 for (i = 0; i < spec->num_adc_nids; i++) {
4709 hda_nid_t cap = spec->capsrc_nids ?
4710 spec->capsrc_nids[i] : spec->adc_nids[i];
4711 int iidx, eidx;
4712
4713 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4714 if (iidx < 0)
4715 continue;
4716 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4717 if (eidx < 0)
4718 continue;
4719 spec->int_mic.mux_idx = iidx;
4720 spec->ext_mic.mux_idx = eidx;
4721 if (spec->capsrc_nids)
4722 spec->capsrc_nids += i;
4723 spec->adc_nids += i;
4724 spec->num_adc_nids = 1;
4725 return;
4726 }
4727 snd_printd(KERN_INFO "hda_codec: %s: "
4728 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4729 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4730 spec->auto_mic = 0; /* disable auto-mic to be sure */
4731}
4732
4733static void set_capture_mixer(struct hda_codec *codec)
4734{
4735 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004736 static struct snd_kcontrol_new *caps[2][3] = {
4737 { alc_capture_mixer_nosrc1,
4738 alc_capture_mixer_nosrc2,
4739 alc_capture_mixer_nosrc3 },
4740 { alc_capture_mixer1,
4741 alc_capture_mixer2,
4742 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004743 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004744 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4745 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004746 if (spec->auto_mic) {
4747 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004748 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004749 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004750 mux = 1;
4751 else
4752 mux = 0;
4753 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4754 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004755}
4756
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004757#define set_beep_amp(spec, nid, idx, dir) \
4758 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4759
4760/*
4761 * OK, here we have finally the patch for ALC880
4762 */
4763
Linus Torvalds1da177e2005-04-16 15:20:36 -07004764static int patch_alc880(struct hda_codec *codec)
4765{
4766 struct alc_spec *spec;
4767 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004768 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004769
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004770 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 if (spec == NULL)
4772 return -ENOMEM;
4773
4774 codec->spec = spec;
4775
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004776 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4777 alc880_models,
4778 alc880_cfg_tbl);
4779 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004780 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4781 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004783 }
4784
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004785 if (board_config == ALC880_AUTO) {
4786 /* automatic parse from the BIOS config */
4787 err = alc880_parse_auto_config(codec);
4788 if (err < 0) {
4789 alc_free(codec);
4790 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004791 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004792 printk(KERN_INFO
4793 "hda_codec: Cannot set up configuration "
4794 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004795 board_config = ALC880_3ST;
4796 }
4797 }
4798
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004799 err = snd_hda_attach_beep_device(codec, 0x1);
4800 if (err < 0) {
4801 alc_free(codec);
4802 return err;
4803 }
4804
Kailang Yangdf694da2005-12-05 19:42:22 +01004805 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004806 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004807
Linus Torvalds1da177e2005-04-16 15:20:36 -07004808 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4809 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004810 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004811
Linus Torvalds1da177e2005-04-16 15:20:36 -07004812 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4813 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4814
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004815 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004817 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004819 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004820 if (wcap != AC_WID_AUD_IN) {
4821 spec->adc_nids = alc880_adc_nids_alt;
4822 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004823 } else {
4824 spec->adc_nids = alc880_adc_nids;
4825 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004826 }
4827 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004828 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004829 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004830
Takashi Iwai2134ea42008-01-10 16:53:55 +01004831 spec->vmaster_nid = 0x0c;
4832
Linus Torvalds1da177e2005-04-16 15:20:36 -07004833 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004834 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004835 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004836#ifdef CONFIG_SND_HDA_POWER_SAVE
4837 if (!spec->loopback.amplist)
4838 spec->loopback.amplist = alc880_loopbacks;
4839#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004840 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004841
4842 return 0;
4843}
4844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845
Linus Torvalds1da177e2005-04-16 15:20:36 -07004846/*
4847 * ALC260 support
4848 */
4849
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004850static hda_nid_t alc260_dac_nids[1] = {
4851 /* front */
4852 0x02,
4853};
4854
4855static hda_nid_t alc260_adc_nids[1] = {
4856 /* ADC0 */
4857 0x04,
4858};
4859
Kailang Yangdf694da2005-12-05 19:42:22 +01004860static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004861 /* ADC1 */
4862 0x05,
4863};
4864
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004865/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4866 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4867 */
4868static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004869 /* ADC0, ADC1 */
4870 0x04, 0x05
4871};
4872
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873#define ALC260_DIGOUT_NID 0x03
4874#define ALC260_DIGIN_NID 0x06
4875
4876static struct hda_input_mux alc260_capture_source = {
4877 .num_items = 4,
4878 .items = {
4879 { "Mic", 0x0 },
4880 { "Front Mic", 0x1 },
4881 { "Line", 0x2 },
4882 { "CD", 0x4 },
4883 },
4884};
4885
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004886/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004887 * headphone jack and the internal CD lines since these are the only pins at
4888 * which audio can appear. For flexibility, also allow the option of
4889 * recording the mixer output on the second ADC (ADC0 doesn't have a
4890 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004891 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004892static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4893 {
4894 .num_items = 3,
4895 .items = {
4896 { "Mic/Line", 0x0 },
4897 { "CD", 0x4 },
4898 { "Headphone", 0x2 },
4899 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004900 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004901 {
4902 .num_items = 4,
4903 .items = {
4904 { "Mic/Line", 0x0 },
4905 { "CD", 0x4 },
4906 { "Headphone", 0x2 },
4907 { "Mixer", 0x5 },
4908 },
4909 },
4910
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004911};
4912
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004913/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4914 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004915 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004916static struct hda_input_mux alc260_acer_capture_sources[2] = {
4917 {
4918 .num_items = 4,
4919 .items = {
4920 { "Mic", 0x0 },
4921 { "Line", 0x2 },
4922 { "CD", 0x4 },
4923 { "Headphone", 0x5 },
4924 },
4925 },
4926 {
4927 .num_items = 5,
4928 .items = {
4929 { "Mic", 0x0 },
4930 { "Line", 0x2 },
4931 { "CD", 0x4 },
4932 { "Headphone", 0x6 },
4933 { "Mixer", 0x5 },
4934 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004935 },
4936};
Michael Schwingencc959482009-02-22 18:58:45 +01004937
4938/* Maxdata Favorit 100XS */
4939static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4940 {
4941 .num_items = 2,
4942 .items = {
4943 { "Line/Mic", 0x0 },
4944 { "CD", 0x4 },
4945 },
4946 },
4947 {
4948 .num_items = 3,
4949 .items = {
4950 { "Line/Mic", 0x0 },
4951 { "CD", 0x4 },
4952 { "Mixer", 0x5 },
4953 },
4954 },
4955};
4956
Linus Torvalds1da177e2005-04-16 15:20:36 -07004957/*
4958 * This is just place-holder, so there's something for alc_build_pcms to look
4959 * at when it calculates the maximum number of channels. ALC260 has no mixer
4960 * element which allows changing the channel mode, so the verb list is
4961 * never used.
4962 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004963static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004964 { 2, NULL },
4965};
4966
Kailang Yangdf694da2005-12-05 19:42:22 +01004967
4968/* Mixer combinations
4969 *
4970 * basic: base_output + input + pc_beep + capture
4971 * HP: base_output + input + capture_alt
4972 * HP_3013: hp_3013 + input + capture
4973 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004974 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 */
4976
4977static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004978 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004979 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004980 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4981 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4982 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4983 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4984 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004985};
Kailang Yangdf694da2005-12-05 19:42:22 +01004986
4987static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004988 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4989 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4990 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4991 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4993 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004996 { } /* end */
4997};
4998
Takashi Iwaibec15c32008-01-28 18:16:30 +01004999/* update HP, line and mono out pins according to the master switch */
5000static void alc260_hp_master_update(struct hda_codec *codec,
5001 hda_nid_t hp, hda_nid_t line,
5002 hda_nid_t mono)
5003{
5004 struct alc_spec *spec = codec->spec;
5005 unsigned int val = spec->master_sw ? PIN_HP : 0;
5006 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005007 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005008 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005009 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005010 val);
5011 /* mono (speaker) depending on the HP jack sense */
5012 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005013 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005014 val);
5015}
5016
5017static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5018 struct snd_ctl_elem_value *ucontrol)
5019{
5020 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5021 struct alc_spec *spec = codec->spec;
5022 *ucontrol->value.integer.value = spec->master_sw;
5023 return 0;
5024}
5025
5026static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5027 struct snd_ctl_elem_value *ucontrol)
5028{
5029 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5030 struct alc_spec *spec = codec->spec;
5031 int val = !!*ucontrol->value.integer.value;
5032 hda_nid_t hp, line, mono;
5033
5034 if (val == spec->master_sw)
5035 return 0;
5036 spec->master_sw = val;
5037 hp = (kcontrol->private_value >> 16) & 0xff;
5038 line = (kcontrol->private_value >> 8) & 0xff;
5039 mono = kcontrol->private_value & 0xff;
5040 alc260_hp_master_update(codec, hp, line, mono);
5041 return 1;
5042}
5043
5044static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5045 {
5046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5047 .name = "Master Playback Switch",
5048 .info = snd_ctl_boolean_mono_info,
5049 .get = alc260_hp_master_sw_get,
5050 .put = alc260_hp_master_sw_put,
5051 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5052 },
5053 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5054 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5055 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5056 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5057 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5058 HDA_OUTPUT),
5059 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5060 { } /* end */
5061};
5062
5063static struct hda_verb alc260_hp_unsol_verbs[] = {
5064 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5065 {},
5066};
5067
5068static void alc260_hp_automute(struct hda_codec *codec)
5069{
5070 struct alc_spec *spec = codec->spec;
5071 unsigned int present;
5072
5073 present = snd_hda_codec_read(codec, 0x10, 0,
5074 AC_VERB_GET_PIN_SENSE, 0);
5075 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5076 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5077}
5078
5079static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5080{
5081 if ((res >> 26) == ALC880_HP_EVENT)
5082 alc260_hp_automute(codec);
5083}
5084
Kailang Yangdf694da2005-12-05 19:42:22 +01005085static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005086 {
5087 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5088 .name = "Master Playback Switch",
5089 .info = snd_ctl_boolean_mono_info,
5090 .get = alc260_hp_master_sw_get,
5091 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005092 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005093 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005094 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5095 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5096 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5097 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5098 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5099 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005100 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5101 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005102 { } /* end */
5103};
5104
Kailang Yang3f878302008-08-26 13:02:23 +02005105static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5106 .ops = &snd_hda_bind_vol,
5107 .values = {
5108 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5109 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5110 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5111 0
5112 },
5113};
5114
5115static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5116 .ops = &snd_hda_bind_sw,
5117 .values = {
5118 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5119 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5120 0
5121 },
5122};
5123
5124static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5125 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5126 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5127 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5128 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5129 { } /* end */
5130};
5131
Takashi Iwaibec15c32008-01-28 18:16:30 +01005132static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5133 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5134 {},
5135};
5136
5137static void alc260_hp_3013_automute(struct hda_codec *codec)
5138{
5139 struct alc_spec *spec = codec->spec;
5140 unsigned int present;
5141
5142 present = snd_hda_codec_read(codec, 0x15, 0,
5143 AC_VERB_GET_PIN_SENSE, 0);
5144 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005145 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005146}
5147
5148static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5149 unsigned int res)
5150{
5151 if ((res >> 26) == ALC880_HP_EVENT)
5152 alc260_hp_3013_automute(codec);
5153}
5154
Kailang Yang3f878302008-08-26 13:02:23 +02005155static void alc260_hp_3012_automute(struct hda_codec *codec)
5156{
5157 unsigned int present, bits;
5158
5159 present = snd_hda_codec_read(codec, 0x10, 0,
5160 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5161
5162 bits = present ? 0 : PIN_OUT;
5163 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5164 bits);
5165 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5166 bits);
5167 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5168 bits);
5169}
5170
5171static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5172 unsigned int res)
5173{
5174 if ((res >> 26) == ALC880_HP_EVENT)
5175 alc260_hp_3012_automute(codec);
5176}
5177
5178/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005179 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5180 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005181static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005182 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005183 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005184 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005185 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5186 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5187 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5188 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005189 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005190 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5191 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005192 { } /* end */
5193};
5194
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005195/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5196 * versions of the ALC260 don't act on requests to enable mic bias from NID
5197 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5198 * datasheet doesn't mention this restriction. At this stage it's not clear
5199 * whether this behaviour is intentional or is a hardware bug in chip
5200 * revisions available in early 2006. Therefore for now allow the
5201 * "Headphone Jack Mode" control to span all choices, but if it turns out
5202 * that the lack of mic bias for this NID is intentional we could change the
5203 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5204 *
5205 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5206 * don't appear to make the mic bias available from the "line" jack, even
5207 * though the NID used for this jack (0x14) can supply it. The theory is
5208 * that perhaps Acer have included blocking capacitors between the ALC260
5209 * and the output jack. If this turns out to be the case for all such
5210 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5211 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005212 *
5213 * The C20x Tablet series have a mono internal speaker which is controlled
5214 * via the chip's Mono sum widget and pin complex, so include the necessary
5215 * controls for such models. On models without a "mono speaker" the control
5216 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005217 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005218static struct snd_kcontrol_new alc260_acer_mixer[] = {
5219 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5220 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005221 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005222 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005223 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005224 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005225 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005226 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5227 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5229 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5230 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5231 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5232 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5233 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005234 { } /* end */
5235};
5236
Michael Schwingencc959482009-02-22 18:58:45 +01005237/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5238 */
5239static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5240 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5241 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5242 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5243 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5244 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5245 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5246 { } /* end */
5247};
5248
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005249/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5250 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5251 */
5252static struct snd_kcontrol_new alc260_will_mixer[] = {
5253 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5254 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5256 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5257 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5258 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5259 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5260 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5261 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5262 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005263 { } /* end */
5264};
5265
5266/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5267 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5268 */
5269static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5270 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5271 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5272 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5273 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5274 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5275 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5276 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5277 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5278 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5279 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5280 { } /* end */
5281};
5282
Kailang Yangdf694da2005-12-05 19:42:22 +01005283/*
5284 * initialization verbs
5285 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005286static struct hda_verb alc260_init_verbs[] = {
5287 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005289 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005291 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005292 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005293 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005294 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005295 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005297 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005298 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005299 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005300 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005301 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005302 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005303 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005304 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5305 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005306 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005307 /* set connection select to line in (default select for this ADC) */
5308 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005309 /* mute capture amp left and right */
5310 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5311 /* set connection select to line in (default select for this ADC) */
5312 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005313 /* set vol=0 Line-Out mixer amp left and right */
5314 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5315 /* unmute pin widget amp left and right (no gain on this amp) */
5316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5317 /* set vol=0 HP mixer amp left and right */
5318 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5319 /* unmute pin widget amp left and right (no gain on this amp) */
5320 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5321 /* set vol=0 Mono mixer amp left and right */
5322 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5323 /* unmute pin widget amp left and right (no gain on this amp) */
5324 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5325 /* unmute LINE-2 out pin */
5326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005327 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5328 * Line In 2 = 0x03
5329 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005330 /* mute analog inputs */
5331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5332 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005336 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005337 /* mute Front out path */
5338 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5339 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5340 /* mute Headphone out path */
5341 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5342 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5343 /* mute Mono out path */
5344 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5345 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005346 { }
5347};
5348
Takashi Iwai474167d2006-05-17 17:17:43 +02005349#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005350static struct hda_verb alc260_hp_init_verbs[] = {
5351 /* Headphone and output */
5352 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5353 /* mono output */
5354 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5355 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5357 /* Mic2 (front panel) pin widget for input and vref at 80% */
5358 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5359 /* Line In pin widget for input */
5360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5361 /* Line-2 pin widget for output */
5362 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5363 /* CD pin widget for input */
5364 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5365 /* unmute amp left and right */
5366 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5367 /* set connection select to line in (default select for this ADC) */
5368 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5369 /* unmute Line-Out mixer amp left and right (volume = 0) */
5370 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5371 /* mute pin widget amp left and right (no gain on this amp) */
5372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5373 /* unmute HP mixer amp left and right (volume = 0) */
5374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5375 /* mute pin widget amp left and right (no gain on this amp) */
5376 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005377 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5378 * Line In 2 = 0x03
5379 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005380 /* mute analog inputs */
5381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5382 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5383 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5384 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5385 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005386 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5387 /* Unmute Front out path */
5388 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5390 /* Unmute Headphone out path */
5391 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5393 /* Unmute Mono out path */
5394 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5395 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5396 { }
5397};
Takashi Iwai474167d2006-05-17 17:17:43 +02005398#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005399
5400static struct hda_verb alc260_hp_3013_init_verbs[] = {
5401 /* Line out and output */
5402 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5403 /* mono output */
5404 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5405 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5406 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5407 /* Mic2 (front panel) pin widget for input and vref at 80% */
5408 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5409 /* Line In pin widget for input */
5410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5411 /* Headphone pin widget for output */
5412 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5413 /* CD pin widget for input */
5414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5415 /* unmute amp left and right */
5416 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5417 /* set connection select to line in (default select for this ADC) */
5418 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5419 /* unmute Line-Out mixer amp left and right (volume = 0) */
5420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5421 /* mute pin widget amp left and right (no gain on this amp) */
5422 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5423 /* unmute HP mixer amp left and right (volume = 0) */
5424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5425 /* mute pin widget amp left and right (no gain on this amp) */
5426 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005427 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5428 * Line In 2 = 0x03
5429 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005430 /* mute analog inputs */
5431 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5432 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5433 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5435 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005436 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5437 /* Unmute Front out path */
5438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5440 /* Unmute Headphone out path */
5441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5442 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5443 /* Unmute Mono out path */
5444 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5445 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5446 { }
5447};
5448
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005449/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005450 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5451 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005452 */
5453static struct hda_verb alc260_fujitsu_init_verbs[] = {
5454 /* Disable all GPIOs */
5455 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5456 /* Internal speaker is connected to headphone pin */
5457 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5458 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5459 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005460 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5461 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5462 /* Ensure all other unused pins are disabled and muted. */
5463 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005465 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005466 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005467 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005468 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5470 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005471
Jonathan Woithef7ace402006-02-28 11:46:14 +01005472 /* Disable digital (SPDIF) pins */
5473 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5474 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005475
Kailang Yangea1fb292008-08-26 12:58:38 +02005476 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005477 * when acting as an output.
5478 */
5479 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5480
5481 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005482 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5483 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5484 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5485 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5486 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5488 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5489 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5490 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005491
Jonathan Woithef7ace402006-02-28 11:46:14 +01005492 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5493 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5494 /* Unmute Line1 pin widget output buffer since it starts as an output.
5495 * If the pin mode is changed by the user the pin mode control will
5496 * take care of enabling the pin's input/output buffers as needed.
5497 * Therefore there's no need to enable the input buffer at this
5498 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005499 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005500 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005501 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005502 * mixer ctrl)
5503 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005504 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005505
Jonathan Woithef7ace402006-02-28 11:46:14 +01005506 /* Mute capture amp left and right */
5507 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005508 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005509 * in (on mic1 pin)
5510 */
5511 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005512
Jonathan Woithef7ace402006-02-28 11:46:14 +01005513 /* Do the same for the second ADC: mute capture input amp and
5514 * set ADC connection to line in (on mic1 pin)
5515 */
5516 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5517 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005518
Jonathan Woithef7ace402006-02-28 11:46:14 +01005519 /* Mute all inputs to mixer widget (even unconnected ones) */
5520 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5522 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5526 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5527 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005528
5529 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005530};
5531
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005532/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5533 * similar laptops (adapted from Fujitsu init verbs).
5534 */
5535static struct hda_verb alc260_acer_init_verbs[] = {
5536 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5537 * the headphone jack. Turn this on and rely on the standard mute
5538 * methods whenever the user wants to turn these outputs off.
5539 */
5540 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5541 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5542 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5543 /* Internal speaker/Headphone jack is connected to Line-out pin */
5544 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5545 /* Internal microphone/Mic jack is connected to Mic1 pin */
5546 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5547 /* Line In jack is connected to Line1 pin */
5548 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005549 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5550 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005551 /* Ensure all other unused pins are disabled and muted. */
5552 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5553 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005554 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5555 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5556 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5557 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5558 /* Disable digital (SPDIF) pins */
5559 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5560 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5561
Kailang Yangea1fb292008-08-26 12:58:38 +02005562 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005563 * bus when acting as outputs.
5564 */
5565 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5566 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5567
5568 /* Start with output sum widgets muted and their output gains at min */
5569 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5570 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5573 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5574 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5575 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5576 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5577 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005579 /* Unmute Line-out pin widget amp left and right
5580 * (no equiv mixer ctrl)
5581 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005582 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005583 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5584 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005585 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5586 * inputs. If the pin mode is changed by the user the pin mode control
5587 * will take care of enabling the pin's input/output buffers as needed.
5588 * Therefore there's no need to enable the input buffer at this
5589 * stage.
5590 */
5591 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5592 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5593
5594 /* Mute capture amp left and right */
5595 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5596 /* Set ADC connection select to match default mixer setting - mic
5597 * (on mic1 pin)
5598 */
5599 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5600
5601 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005602 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005603 */
5604 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005605 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005606
5607 /* Mute all inputs to mixer widget (even unconnected ones) */
5608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5611 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5612 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5614 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5615 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5616
5617 { }
5618};
5619
Michael Schwingencc959482009-02-22 18:58:45 +01005620/* Initialisation sequence for Maxdata Favorit 100XS
5621 * (adapted from Acer init verbs).
5622 */
5623static struct hda_verb alc260_favorit100_init_verbs[] = {
5624 /* GPIO 0 enables the output jack.
5625 * Turn this on and rely on the standard mute
5626 * methods whenever the user wants to turn these outputs off.
5627 */
5628 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5629 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5630 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5631 /* Line/Mic input jack is connected to Mic1 pin */
5632 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5633 /* Ensure all other unused pins are disabled and muted. */
5634 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5635 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5636 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5637 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5638 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5639 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5640 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5641 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5642 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5643 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5644 /* Disable digital (SPDIF) pins */
5645 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5646 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5647
5648 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5649 * bus when acting as outputs.
5650 */
5651 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5652 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5653
5654 /* Start with output sum widgets muted and their output gains at min */
5655 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5656 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5657 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5658 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5659 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5660 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5661 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5662 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5663 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5664
5665 /* Unmute Line-out pin widget amp left and right
5666 * (no equiv mixer ctrl)
5667 */
5668 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5669 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5670 * inputs. If the pin mode is changed by the user the pin mode control
5671 * will take care of enabling the pin's input/output buffers as needed.
5672 * Therefore there's no need to enable the input buffer at this
5673 * stage.
5674 */
5675 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5676
5677 /* Mute capture amp left and right */
5678 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5679 /* Set ADC connection select to match default mixer setting - mic
5680 * (on mic1 pin)
5681 */
5682 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5683
5684 /* Do similar with the second ADC: mute capture input amp and
5685 * set ADC connection to mic to match ALSA's default state.
5686 */
5687 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5688 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5689
5690 /* Mute all inputs to mixer widget (even unconnected ones) */
5691 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5692 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5693 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5694 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5695 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5696 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5697 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5699
5700 { }
5701};
5702
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005703static struct hda_verb alc260_will_verbs[] = {
5704 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5705 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5706 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5707 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5708 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5709 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5710 {}
5711};
5712
5713static struct hda_verb alc260_replacer_672v_verbs[] = {
5714 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5715 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5716 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5717
5718 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5719 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5720 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5721
5722 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5723 {}
5724};
5725
5726/* toggle speaker-output according to the hp-jack state */
5727static void alc260_replacer_672v_automute(struct hda_codec *codec)
5728{
5729 unsigned int present;
5730
5731 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5732 present = snd_hda_codec_read(codec, 0x0f, 0,
5733 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5734 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005735 snd_hda_codec_write_cache(codec, 0x01, 0,
5736 AC_VERB_SET_GPIO_DATA, 1);
5737 snd_hda_codec_write_cache(codec, 0x0f, 0,
5738 AC_VERB_SET_PIN_WIDGET_CONTROL,
5739 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005740 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005741 snd_hda_codec_write_cache(codec, 0x01, 0,
5742 AC_VERB_SET_GPIO_DATA, 0);
5743 snd_hda_codec_write_cache(codec, 0x0f, 0,
5744 AC_VERB_SET_PIN_WIDGET_CONTROL,
5745 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005746 }
5747}
5748
5749static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5750 unsigned int res)
5751{
5752 if ((res >> 26) == ALC880_HP_EVENT)
5753 alc260_replacer_672v_automute(codec);
5754}
5755
Kailang Yang3f878302008-08-26 13:02:23 +02005756static struct hda_verb alc260_hp_dc7600_verbs[] = {
5757 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5758 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5759 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5760 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5761 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5763 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5764 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5765 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5766 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5767 {}
5768};
5769
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005770/* Test configuration for debugging, modelled after the ALC880 test
5771 * configuration.
5772 */
5773#ifdef CONFIG_SND_DEBUG
5774static hda_nid_t alc260_test_dac_nids[1] = {
5775 0x02,
5776};
5777static hda_nid_t alc260_test_adc_nids[2] = {
5778 0x04, 0x05,
5779};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005780/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005781 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005782 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005783 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005784static struct hda_input_mux alc260_test_capture_sources[2] = {
5785 {
5786 .num_items = 7,
5787 .items = {
5788 { "MIC1 pin", 0x0 },
5789 { "MIC2 pin", 0x1 },
5790 { "LINE1 pin", 0x2 },
5791 { "LINE2 pin", 0x3 },
5792 { "CD pin", 0x4 },
5793 { "LINE-OUT pin", 0x5 },
5794 { "HP-OUT pin", 0x6 },
5795 },
5796 },
5797 {
5798 .num_items = 8,
5799 .items = {
5800 { "MIC1 pin", 0x0 },
5801 { "MIC2 pin", 0x1 },
5802 { "LINE1 pin", 0x2 },
5803 { "LINE2 pin", 0x3 },
5804 { "CD pin", 0x4 },
5805 { "Mixer", 0x5 },
5806 { "LINE-OUT pin", 0x6 },
5807 { "HP-OUT pin", 0x7 },
5808 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005809 },
5810};
5811static struct snd_kcontrol_new alc260_test_mixer[] = {
5812 /* Output driver widgets */
5813 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5814 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5815 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5816 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5817 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5818 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5819
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005820 /* Modes for retasking pin widgets
5821 * Note: the ALC260 doesn't seem to act on requests to enable mic
5822 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5823 * mention this restriction. At this stage it's not clear whether
5824 * this behaviour is intentional or is a hardware bug in chip
5825 * revisions available at least up until early 2006. Therefore for
5826 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5827 * choices, but if it turns out that the lack of mic bias for these
5828 * NIDs is intentional we could change their modes from
5829 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5830 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005831 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5832 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5833 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5834 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5835 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5836 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5837
5838 /* Loopback mixer controls */
5839 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5840 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5841 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5842 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5843 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5844 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5845 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5846 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5847 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5848 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005849 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5850 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5851 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5852 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005853
5854 /* Controls for GPIO pins, assuming they are configured as outputs */
5855 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5856 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5857 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5858 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5859
Jonathan Woithe92621f12006-02-28 11:47:47 +01005860 /* Switches to allow the digital IO pins to be enabled. The datasheet
5861 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005862 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005863 */
5864 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5865 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5866
Jonathan Woithef8225f62008-01-08 12:16:54 +01005867 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5868 * this output to turn on an external amplifier.
5869 */
5870 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5871 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5872
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005873 { } /* end */
5874};
5875static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005876 /* Enable all GPIOs as outputs with an initial value of 0 */
5877 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5878 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5879 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5880
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005881 /* Enable retasking pins as output, initially without power amp */
5882 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5883 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5884 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5886 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5887 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5888
Jonathan Woithe92621f12006-02-28 11:47:47 +01005889 /* Disable digital (SPDIF) pins initially, but users can enable
5890 * them via a mixer switch. In the case of SPDIF-out, this initverb
5891 * payload also sets the generation to 0, output to be in "consumer"
5892 * PCM format, copyright asserted, no pre-emphasis and no validity
5893 * control.
5894 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005895 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5896 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5897
Kailang Yangea1fb292008-08-26 12:58:38 +02005898 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005899 * OUT1 sum bus when acting as an output.
5900 */
5901 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5902 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5903 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5904 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5905
5906 /* Start with output sum widgets muted and their output gains at min */
5907 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5908 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5910 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5912 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5913 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5914 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5915 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5916
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005917 /* Unmute retasking pin widget output buffers since the default
5918 * state appears to be output. As the pin mode is changed by the
5919 * user the pin mode control will take care of enabling the pin's
5920 * input/output buffers as needed.
5921 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005922 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5926 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5927 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5928 /* Also unmute the mono-out pin widget */
5929 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5930
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005931 /* Mute capture amp left and right */
5932 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005933 /* Set ADC connection select to match default mixer setting (mic1
5934 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005935 */
5936 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5937
5938 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005939 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005940 */
5941 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5942 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5943
5944 /* Mute all inputs to mixer widget (even unconnected ones) */
5945 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5946 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5947 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5948 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5949 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5950 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5951 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5953
5954 { }
5955};
5956#endif
5957
Takashi Iwai63300792008-01-24 15:31:36 +01005958#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5959#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005960
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005961#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5962#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5963
Kailang Yangdf694da2005-12-05 19:42:22 +01005964/*
5965 * for BIOS auto-configuration
5966 */
5967
5968static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005969 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005970{
5971 hda_nid_t nid_vol;
5972 unsigned long vol_val, sw_val;
5973 char name[32];
5974 int err;
5975
5976 if (nid >= 0x0f && nid < 0x11) {
5977 nid_vol = nid - 0x7;
5978 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5979 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5980 } else if (nid == 0x11) {
5981 nid_vol = nid - 0x7;
5982 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5983 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5984 } else if (nid >= 0x12 && nid <= 0x15) {
5985 nid_vol = 0x08;
5986 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5987 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5988 } else
5989 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005990
Takashi Iwai863b4512008-10-21 17:01:47 +02005991 if (!(*vol_bits & (1 << nid_vol))) {
5992 /* first control for the volume widget */
5993 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5994 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5995 if (err < 0)
5996 return err;
5997 *vol_bits |= (1 << nid_vol);
5998 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005999 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006000 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
6001 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006002 return err;
6003 return 1;
6004}
6005
6006/* add playback controls from the parsed DAC table */
6007static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6008 const struct auto_pin_cfg *cfg)
6009{
6010 hda_nid_t nid;
6011 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006012 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006013
6014 spec->multiout.num_dacs = 1;
6015 spec->multiout.dac_nids = spec->private_dac_nids;
6016 spec->multiout.dac_nids[0] = 0x02;
6017
6018 nid = cfg->line_out_pins[0];
6019 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006020 const char *pfx;
6021 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6022 pfx = "Master";
6023 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6024 pfx = "Speaker";
6025 else
6026 pfx = "Front";
6027 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006028 if (err < 0)
6029 return err;
6030 }
6031
Takashi Iwai82bc9552006-03-21 11:24:42 +01006032 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006033 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006034 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006035 if (err < 0)
6036 return err;
6037 }
6038
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006039 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006040 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006041 err = alc260_add_playback_controls(spec, nid, "Headphone",
6042 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006043 if (err < 0)
6044 return err;
6045 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006046 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006047}
6048
6049/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006050static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006051 const struct auto_pin_cfg *cfg)
6052{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006053 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006054}
6055
6056static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6057 hda_nid_t nid, int pin_type,
6058 int sel_idx)
6059{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006060 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006061 /* need the manual connection? */
6062 if (nid >= 0x12) {
6063 int idx = nid - 0x12;
6064 snd_hda_codec_write(codec, idx + 0x0b, 0,
6065 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006066 }
6067}
6068
6069static void alc260_auto_init_multi_out(struct hda_codec *codec)
6070{
6071 struct alc_spec *spec = codec->spec;
6072 hda_nid_t nid;
6073
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006074 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006075 if (nid) {
6076 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6077 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6078 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006079
Takashi Iwai82bc9552006-03-21 11:24:42 +01006080 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006081 if (nid)
6082 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6083
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006084 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006085 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006086 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006087}
Kailang Yangdf694da2005-12-05 19:42:22 +01006088
6089#define ALC260_PIN_CD_NID 0x16
6090static void alc260_auto_init_analog_input(struct hda_codec *codec)
6091{
6092 struct alc_spec *spec = codec->spec;
6093 int i;
6094
6095 for (i = 0; i < AUTO_PIN_LAST; i++) {
6096 hda_nid_t nid = spec->autocfg.input_pins[i];
6097 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006098 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006099 if (nid != ALC260_PIN_CD_NID &&
6100 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006101 snd_hda_codec_write(codec, nid, 0,
6102 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006103 AMP_OUT_MUTE);
6104 }
6105 }
6106}
6107
6108/*
6109 * generic initialization of ADC, input mixers and output mixers
6110 */
6111static struct hda_verb alc260_volume_init_verbs[] = {
6112 /*
6113 * Unmute ADC0-1 and set the default input to mic-in
6114 */
6115 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6116 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6117 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6118 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006119
Kailang Yangdf694da2005-12-05 19:42:22 +01006120 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6121 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006122 * Note: PASD motherboards uses the Line In 2 as the input for
6123 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006124 */
6125 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006126 /* mute analog inputs */
6127 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6128 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006132
6133 /*
6134 * Set up output mixers (0x08 - 0x0a)
6135 */
6136 /* set vol=0 to output mixers */
6137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6138 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6139 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6140 /* set up input amps for analog loopback */
6141 /* Amp Indices: DAC = 0, mixer = 1 */
6142 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6144 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6146 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6147 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006148
Kailang Yangdf694da2005-12-05 19:42:22 +01006149 { }
6150};
6151
6152static int alc260_parse_auto_config(struct hda_codec *codec)
6153{
6154 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006155 int err;
6156 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6157
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006158 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6159 alc260_ignore);
6160 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006161 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006162 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6163 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006164 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006165 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006166 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006167 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006168 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006169 return err;
6170
6171 spec->multiout.max_channels = 2;
6172
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006173 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006174 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006175 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006176 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006177
Takashi Iwaid88897e2008-10-31 15:01:37 +01006178 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006179
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006180 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006181 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006182
Takashi Iwai4a79ba342009-04-22 16:31:35 +02006183 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6184
Kailang Yangdf694da2005-12-05 19:42:22 +01006185 return 1;
6186}
6187
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006188/* additional initialization for auto-configuration model */
6189static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006190{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006191 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006192 alc260_auto_init_multi_out(codec);
6193 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006194 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006195 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006196}
6197
Takashi Iwaicb53c622007-08-10 17:21:45 +02006198#ifdef CONFIG_SND_HDA_POWER_SAVE
6199static struct hda_amp_list alc260_loopbacks[] = {
6200 { 0x07, HDA_INPUT, 0 },
6201 { 0x07, HDA_INPUT, 1 },
6202 { 0x07, HDA_INPUT, 2 },
6203 { 0x07, HDA_INPUT, 3 },
6204 { 0x07, HDA_INPUT, 4 },
6205 { } /* end */
6206};
6207#endif
6208
Kailang Yangdf694da2005-12-05 19:42:22 +01006209/*
6210 * ALC260 configurations
6211 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006212static const char *alc260_models[ALC260_MODEL_LAST] = {
6213 [ALC260_BASIC] = "basic",
6214 [ALC260_HP] = "hp",
6215 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006216 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006217 [ALC260_FUJITSU_S702X] = "fujitsu",
6218 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006219 [ALC260_WILL] = "will",
6220 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006221 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006222#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006223 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006224#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006225 [ALC260_AUTO] = "auto",
6226};
6227
6228static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006229 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006230 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006231 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006232 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006233 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006234 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006235 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006236 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006237 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6238 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6239 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6240 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6241 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6242 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6243 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6244 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6245 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006246 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006247 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006248 {}
6249};
6250
Kailang Yangdf694da2005-12-05 19:42:22 +01006251static struct alc_config_preset alc260_presets[] = {
6252 [ALC260_BASIC] = {
6253 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006254 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006255 .init_verbs = { alc260_init_verbs },
6256 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6257 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006258 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006259 .adc_nids = alc260_adc_nids,
6260 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6261 .channel_mode = alc260_modes,
6262 .input_mux = &alc260_capture_source,
6263 },
6264 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006265 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006266 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006267 .init_verbs = { alc260_init_verbs,
6268 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006269 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6270 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006271 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6272 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006273 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6274 .channel_mode = alc260_modes,
6275 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006276 .unsol_event = alc260_hp_unsol_event,
6277 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006278 },
Kailang Yang3f878302008-08-26 13:02:23 +02006279 [ALC260_HP_DC7600] = {
6280 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006281 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006282 .init_verbs = { alc260_init_verbs,
6283 alc260_hp_dc7600_verbs },
6284 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6285 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006286 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6287 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006288 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6289 .channel_mode = alc260_modes,
6290 .input_mux = &alc260_capture_source,
6291 .unsol_event = alc260_hp_3012_unsol_event,
6292 .init_hook = alc260_hp_3012_automute,
6293 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006294 [ALC260_HP_3013] = {
6295 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006296 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006297 .init_verbs = { alc260_hp_3013_init_verbs,
6298 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006299 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6300 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006301 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6302 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006303 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6304 .channel_mode = alc260_modes,
6305 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006306 .unsol_event = alc260_hp_3013_unsol_event,
6307 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006308 },
6309 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006310 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006311 .init_verbs = { alc260_fujitsu_init_verbs },
6312 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6313 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006314 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6315 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6317 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006318 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6319 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006320 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006321 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006322 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006323 .init_verbs = { alc260_acer_init_verbs },
6324 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6325 .dac_nids = alc260_dac_nids,
6326 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6327 .adc_nids = alc260_dual_adc_nids,
6328 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6329 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006330 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6331 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006332 },
Michael Schwingencc959482009-02-22 18:58:45 +01006333 [ALC260_FAVORIT100] = {
6334 .mixers = { alc260_favorit100_mixer },
6335 .init_verbs = { alc260_favorit100_init_verbs },
6336 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6337 .dac_nids = alc260_dac_nids,
6338 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6339 .adc_nids = alc260_dual_adc_nids,
6340 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6341 .channel_mode = alc260_modes,
6342 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6343 .input_mux = alc260_favorit100_capture_sources,
6344 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006345 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006346 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006347 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6348 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6349 .dac_nids = alc260_dac_nids,
6350 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6351 .adc_nids = alc260_adc_nids,
6352 .dig_out_nid = ALC260_DIGOUT_NID,
6353 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6354 .channel_mode = alc260_modes,
6355 .input_mux = &alc260_capture_source,
6356 },
6357 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006358 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006359 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6360 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6361 .dac_nids = alc260_dac_nids,
6362 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6363 .adc_nids = alc260_adc_nids,
6364 .dig_out_nid = ALC260_DIGOUT_NID,
6365 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6366 .channel_mode = alc260_modes,
6367 .input_mux = &alc260_capture_source,
6368 .unsol_event = alc260_replacer_672v_unsol_event,
6369 .init_hook = alc260_replacer_672v_automute,
6370 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006371#ifdef CONFIG_SND_DEBUG
6372 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006373 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006374 .init_verbs = { alc260_test_init_verbs },
6375 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6376 .dac_nids = alc260_test_dac_nids,
6377 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6378 .adc_nids = alc260_test_adc_nids,
6379 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6380 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006381 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6382 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006383 },
6384#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006385};
6386
Linus Torvalds1da177e2005-04-16 15:20:36 -07006387static int patch_alc260(struct hda_codec *codec)
6388{
6389 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006390 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006391
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006392 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006393 if (spec == NULL)
6394 return -ENOMEM;
6395
6396 codec->spec = spec;
6397
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006398 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6399 alc260_models,
6400 alc260_cfg_tbl);
6401 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006402 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006403 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006404 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006405 }
6406
Kailang Yangdf694da2005-12-05 19:42:22 +01006407 if (board_config == ALC260_AUTO) {
6408 /* automatic parse from the BIOS config */
6409 err = alc260_parse_auto_config(codec);
6410 if (err < 0) {
6411 alc_free(codec);
6412 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006413 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006414 printk(KERN_INFO
6415 "hda_codec: Cannot set up configuration "
6416 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006417 board_config = ALC260_BASIC;
6418 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006419 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006420
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006421 err = snd_hda_attach_beep_device(codec, 0x1);
6422 if (err < 0) {
6423 alc_free(codec);
6424 return err;
6425 }
6426
Kailang Yangdf694da2005-12-05 19:42:22 +01006427 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006428 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006429
Linus Torvalds1da177e2005-04-16 15:20:36 -07006430 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6431 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6432
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006433 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6434 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6435
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006436 if (!spec->adc_nids && spec->input_mux) {
6437 /* check whether NID 0x04 is valid */
6438 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006439 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006440 /* get type */
6441 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6442 spec->adc_nids = alc260_adc_nids_alt;
6443 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6444 } else {
6445 spec->adc_nids = alc260_adc_nids;
6446 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6447 }
6448 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006449 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006450 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006451
Takashi Iwai2134ea42008-01-10 16:53:55 +01006452 spec->vmaster_nid = 0x08;
6453
Linus Torvalds1da177e2005-04-16 15:20:36 -07006454 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006455 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006456 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006457#ifdef CONFIG_SND_HDA_POWER_SAVE
6458 if (!spec->loopback.amplist)
6459 spec->loopback.amplist = alc260_loopbacks;
6460#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006461 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006462
6463 return 0;
6464}
6465
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006466
Linus Torvalds1da177e2005-04-16 15:20:36 -07006467/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006468 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006469 *
6470 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6471 * configuration. Each pin widget can choose any input DACs and a mixer.
6472 * Each ADC is connected from a mixer of all inputs. This makes possible
6473 * 6-channel independent captures.
6474 *
6475 * In addition, an independent DAC for the multi-playback (not used in this
6476 * driver yet).
6477 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006478#define ALC882_DIGOUT_NID 0x06
6479#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006480#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6481#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6482#define ALC1200_DIGOUT_NID 0x10
6483
Linus Torvalds1da177e2005-04-16 15:20:36 -07006484
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006485static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006486 { 8, NULL }
6487};
6488
Takashi Iwai4953550a2009-06-30 15:28:30 +02006489/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006490static hda_nid_t alc882_dac_nids[4] = {
6491 /* front, rear, clfe, rear_surr */
6492 0x02, 0x03, 0x04, 0x05
6493};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006494#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006495
Takashi Iwai4953550a2009-06-30 15:28:30 +02006496/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006497#define alc882_adc_nids alc880_adc_nids
6498#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006499#define alc883_adc_nids alc882_adc_nids_alt
6500static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6501static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6502#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006503
Takashi Iwaie1406342008-02-11 18:32:32 +01006504static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6505static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006506#define alc883_capsrc_nids alc882_capsrc_nids_alt
6507static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6508#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006509
Linus Torvalds1da177e2005-04-16 15:20:36 -07006510/* input MUX */
6511/* FIXME: should be a matrix-type input source selection */
6512
6513static struct hda_input_mux alc882_capture_source = {
6514 .num_items = 4,
6515 .items = {
6516 { "Mic", 0x0 },
6517 { "Front Mic", 0x1 },
6518 { "Line", 0x2 },
6519 { "CD", 0x4 },
6520 },
6521};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006522
Takashi Iwai4953550a2009-06-30 15:28:30 +02006523#define alc883_capture_source alc882_capture_source
6524
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006525static struct hda_input_mux alc889_capture_source = {
6526 .num_items = 3,
6527 .items = {
6528 { "Front Mic", 0x0 },
6529 { "Mic", 0x3 },
6530 { "Line", 0x2 },
6531 },
6532};
6533
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006534static struct hda_input_mux mb5_capture_source = {
6535 .num_items = 3,
6536 .items = {
6537 { "Mic", 0x1 },
6538 { "Line", 0x2 },
6539 { "CD", 0x4 },
6540 },
6541};
6542
Takashi Iwai4953550a2009-06-30 15:28:30 +02006543static struct hda_input_mux alc883_3stack_6ch_intel = {
6544 .num_items = 4,
6545 .items = {
6546 { "Mic", 0x1 },
6547 { "Front Mic", 0x0 },
6548 { "Line", 0x2 },
6549 { "CD", 0x4 },
6550 },
6551};
6552
6553static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6554 .num_items = 2,
6555 .items = {
6556 { "Mic", 0x1 },
6557 { "Line", 0x2 },
6558 },
6559};
6560
6561static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6562 .num_items = 4,
6563 .items = {
6564 { "Mic", 0x0 },
6565 { "iMic", 0x1 },
6566 { "Line", 0x2 },
6567 { "CD", 0x4 },
6568 },
6569};
6570
6571static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6572 .num_items = 2,
6573 .items = {
6574 { "Mic", 0x0 },
6575 { "Int Mic", 0x1 },
6576 },
6577};
6578
6579static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6580 .num_items = 3,
6581 .items = {
6582 { "Mic", 0x0 },
6583 { "Front Mic", 0x1 },
6584 { "Line", 0x4 },
6585 },
6586};
6587
6588static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6589 .num_items = 2,
6590 .items = {
6591 { "Mic", 0x0 },
6592 { "Line", 0x2 },
6593 },
6594};
6595
6596static struct hda_input_mux alc889A_mb31_capture_source = {
6597 .num_items = 2,
6598 .items = {
6599 { "Mic", 0x0 },
6600 /* Front Mic (0x01) unused */
6601 { "Line", 0x2 },
6602 /* Line 2 (0x03) unused */
6603 /* CD (0x04) unsused? */
6604 },
6605};
6606
6607/*
6608 * 2ch mode
6609 */
6610static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6611 { 2, NULL }
6612};
6613
Kailang Yangdf694da2005-12-05 19:42:22 +01006614/*
Kailang Yang272a5272007-05-14 11:00:38 +02006615 * 2ch mode
6616 */
6617static struct hda_verb alc882_3ST_ch2_init[] = {
6618 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6619 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6622 { } /* end */
6623};
6624
6625/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006626 * 4ch mode
6627 */
6628static struct hda_verb alc882_3ST_ch4_init[] = {
6629 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6630 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6631 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6632 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6633 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6634 { } /* end */
6635};
6636
6637/*
Kailang Yang272a5272007-05-14 11:00:38 +02006638 * 6ch mode
6639 */
6640static struct hda_verb alc882_3ST_ch6_init[] = {
6641 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6642 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6643 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6644 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6645 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6646 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6647 { } /* end */
6648};
6649
Takashi Iwai4953550a2009-06-30 15:28:30 +02006650static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006651 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006652 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006653 { 6, alc882_3ST_ch6_init },
6654};
6655
Takashi Iwai4953550a2009-06-30 15:28:30 +02006656#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6657
Kailang Yang272a5272007-05-14 11:00:38 +02006658/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006659 * 6ch mode
6660 */
6661static struct hda_verb alc882_sixstack_ch6_init[] = {
6662 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6663 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6665 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6666 { } /* end */
6667};
6668
6669/*
6670 * 8ch mode
6671 */
6672static struct hda_verb alc882_sixstack_ch8_init[] = {
6673 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6674 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6675 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6676 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6677 { } /* end */
6678};
6679
6680static struct hda_channel_mode alc882_sixstack_modes[2] = {
6681 { 6, alc882_sixstack_ch6_init },
6682 { 8, alc882_sixstack_ch8_init },
6683};
6684
Takashi Iwai87350ad2007-08-16 18:19:38 +02006685/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006686 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006687 */
6688
6689/*
6690 * 2ch mode
6691 */
6692static struct hda_verb alc885_mbp_ch2_init[] = {
6693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6694 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6695 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6696 { } /* end */
6697};
6698
6699/*
6700 * 6ch mode
6701 */
6702static struct hda_verb alc885_mbp_ch6_init[] = {
6703 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6704 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6705 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6706 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6707 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6708 { } /* end */
6709};
6710
6711static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6712 { 2, alc885_mbp_ch2_init },
6713 { 6, alc885_mbp_ch6_init },
6714};
6715
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006716/*
6717 * 2ch
6718 * Speakers/Woofer/HP = Front
6719 * LineIn = Input
6720 */
6721static struct hda_verb alc885_mb5_ch2_init[] = {
6722 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6724 { } /* end */
6725};
6726
6727/*
6728 * 6ch mode
6729 * Speakers/HP = Front
6730 * Woofer = LFE
6731 * LineIn = Surround
6732 */
6733static struct hda_verb alc885_mb5_ch6_init[] = {
6734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6736 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6737 { } /* end */
6738};
6739
6740static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6741 { 2, alc885_mb5_ch2_init },
6742 { 6, alc885_mb5_ch6_init },
6743};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006744
Takashi Iwai4953550a2009-06-30 15:28:30 +02006745
6746/*
6747 * 2ch mode
6748 */
6749static struct hda_verb alc883_4ST_ch2_init[] = {
6750 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6751 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6752 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6753 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6754 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6755 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6756 { } /* end */
6757};
6758
6759/*
6760 * 4ch mode
6761 */
6762static struct hda_verb alc883_4ST_ch4_init[] = {
6763 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6764 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6765 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6766 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6767 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6768 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6769 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6770 { } /* end */
6771};
6772
6773/*
6774 * 6ch mode
6775 */
6776static struct hda_verb alc883_4ST_ch6_init[] = {
6777 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6778 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6779 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6780 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6781 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6782 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6783 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6784 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6785 { } /* end */
6786};
6787
6788/*
6789 * 8ch mode
6790 */
6791static struct hda_verb alc883_4ST_ch8_init[] = {
6792 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6793 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6794 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6795 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6796 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6797 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6798 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6799 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6800 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6801 { } /* end */
6802};
6803
6804static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6805 { 2, alc883_4ST_ch2_init },
6806 { 4, alc883_4ST_ch4_init },
6807 { 6, alc883_4ST_ch6_init },
6808 { 8, alc883_4ST_ch8_init },
6809};
6810
6811
6812/*
6813 * 2ch mode
6814 */
6815static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6816 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6817 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6818 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6819 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6820 { } /* end */
6821};
6822
6823/*
6824 * 4ch mode
6825 */
6826static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6827 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6828 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6829 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6830 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6831 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6832 { } /* end */
6833};
6834
6835/*
6836 * 6ch mode
6837 */
6838static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6839 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6840 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6841 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6842 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6843 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6844 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6845 { } /* end */
6846};
6847
6848static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6849 { 2, alc883_3ST_ch2_intel_init },
6850 { 4, alc883_3ST_ch4_intel_init },
6851 { 6, alc883_3ST_ch6_intel_init },
6852};
6853
6854/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006855 * 2ch mode
6856 */
6857static struct hda_verb alc889_ch2_intel_init[] = {
6858 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6859 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6860 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6861 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6864 { } /* end */
6865};
6866
6867/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006868 * 6ch mode
6869 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006870static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006871 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6872 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6873 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6874 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6875 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006876 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6877 { } /* end */
6878};
6879
6880/*
6881 * 8ch mode
6882 */
6883static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006884 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6885 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6886 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6887 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6888 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006889 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6890 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006891 { } /* end */
6892};
6893
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006894static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6895 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006896 { 6, alc889_ch6_intel_init },
6897 { 8, alc889_ch8_intel_init },
6898};
6899
6900/*
6901 * 6ch mode
6902 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006903static struct hda_verb alc883_sixstack_ch6_init[] = {
6904 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6905 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6906 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6908 { } /* end */
6909};
6910
6911/*
6912 * 8ch mode
6913 */
6914static struct hda_verb alc883_sixstack_ch8_init[] = {
6915 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6916 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6917 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6918 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6919 { } /* end */
6920};
6921
6922static struct hda_channel_mode alc883_sixstack_modes[2] = {
6923 { 6, alc883_sixstack_ch6_init },
6924 { 8, alc883_sixstack_ch8_init },
6925};
6926
6927
Linus Torvalds1da177e2005-04-16 15:20:36 -07006928/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6929 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6930 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006931static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006933 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006934 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006935 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006936 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6937 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006938 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6939 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006940 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006941 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006942 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6943 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6944 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6945 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6946 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006948 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006949 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6950 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006951 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006952 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006953 { } /* end */
6954};
6955
Takashi Iwai87350ad2007-08-16 18:19:38 +02006956static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6958 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6959 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6960 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6961 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6962 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006963 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6964 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006965 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6967 { } /* end */
6968};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006969
6970static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6972 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6973 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6974 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6975 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6976 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6977 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6978 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6980 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6982 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6983 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6984 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6985 { } /* end */
6986};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006987
Kailang Yangbdd148a2007-05-08 15:19:08 +02006988static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6989 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6990 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6991 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6992 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6993 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6994 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006998 { } /* end */
6999};
7000
Kailang Yang272a5272007-05-14 11:00:38 +02007001static struct snd_kcontrol_new alc882_targa_mixer[] = {
7002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7004 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7005 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7006 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7007 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7008 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7009 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7010 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007012 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7013 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007014 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007015 { } /* end */
7016};
7017
7018/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7019 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7020 */
7021static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7022 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7023 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7025 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7026 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7027 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7028 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7029 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7031 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007034 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007035 { } /* end */
7036};
7037
Takashi Iwai914759b2007-09-06 14:52:04 +02007038static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7039 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7040 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007049 { } /* end */
7050};
7051
Kailang Yangdf694da2005-12-05 19:42:22 +01007052static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7053 {
7054 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7055 .name = "Channel Mode",
7056 .info = alc_ch_mode_info,
7057 .get = alc_ch_mode_get,
7058 .put = alc_ch_mode_put,
7059 },
7060 { } /* end */
7061};
7062
Takashi Iwai4953550a2009-06-30 15:28:30 +02007063static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007064 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007065 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007068 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7071 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007072 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7074 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007076 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007077 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7078 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7079 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007080
Takashi Iwaicb638122009-07-03 10:56:10 +02007081 /* mute analog input loopbacks */
7082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007088 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007089 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007090 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007091 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007092 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007095 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007096 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007097 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007098 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007099 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007100 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007101 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007102 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007103 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007104 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007105 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007106 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7107 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007108 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007109 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7110 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007111 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007112 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7113 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7115 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7116 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007117 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007118 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007119
7120 /* FIXME: use matrix-type input source selection */
7121 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007122 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007127 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007132 /* ADC2: mute amp left and right */
7133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007134 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007135 /* ADC3: mute amp left and right */
7136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007137 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007138
7139 { }
7140};
7141
Takashi Iwai4953550a2009-06-30 15:28:30 +02007142static struct hda_verb alc882_adc1_init_verbs[] = {
7143 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7148 /* ADC1: mute amp left and right */
7149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7150 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7151 { }
7152};
7153
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007154static struct hda_verb alc882_eapd_verbs[] = {
7155 /* change to EAPD mode */
7156 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007157 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007158 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007159};
7160
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007161static struct hda_verb alc889_eapd_verbs[] = {
7162 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7163 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7164 { }
7165};
7166
Wu Fengguang6732bd02009-07-30 09:19:14 +02007167static struct hda_verb alc_hp15_unsol_verbs[] = {
7168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7170 {}
7171};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007172
7173static struct hda_verb alc885_init_verbs[] = {
7174 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7178 /* Rear mixer */
7179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7182 /* CLFE mixer */
7183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7185 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7186 /* Side mixer */
7187 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7188 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7190
7191 /* mute analog input loopbacks */
7192 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7193 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7194 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195
7196 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007197 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7199 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7200 /* Front Pin: output 0 (0x0c) */
7201 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7202 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7203 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7204 /* Rear Pin: output 1 (0x0d) */
7205 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7206 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7207 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7208 /* CLFE Pin: output 2 (0x0e) */
7209 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7210 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7211 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7212 /* Side Pin: output 3 (0x0f) */
7213 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7214 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7215 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7216 /* Mic (rear) pin: input vref at 80% */
7217 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7218 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7219 /* Front Mic pin: input vref at 80% */
7220 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7221 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7222 /* Line In pin: input */
7223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7224 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7225
7226 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7227 /* Input mixer1 */
7228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7231 /* Input mixer2 */
7232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7235 /* Input mixer3 */
7236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7239 /* ADC2: mute amp left and right */
7240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7241 /* ADC3: mute amp left and right */
7242 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7243
7244 { }
7245};
7246
7247static struct hda_verb alc885_init_input_verbs[] = {
7248 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7249 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7250 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7251 { }
7252};
7253
7254
7255/* Unmute Selector 24h and set the default input to front mic */
7256static struct hda_verb alc889_init_input_verbs[] = {
7257 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7258 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7259 { }
7260};
7261
7262
Takashi Iwai4953550a2009-06-30 15:28:30 +02007263#define alc883_init_verbs alc882_base_init_verbs
7264
Tobin Davis9102cd12006-12-15 10:02:12 +01007265/* Mac Pro test */
7266static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7267 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7268 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7269 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7270 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7271 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007272 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007273 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7274 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007275 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007276 { } /* end */
7277};
7278
7279static struct hda_verb alc882_macpro_init_verbs[] = {
7280 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7281 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7284 /* Front Pin: output 0 (0x0c) */
7285 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7287 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7288 /* Front Mic pin: input vref at 80% */
7289 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7291 /* Speaker: output */
7292 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7294 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7295 /* Headphone output (output 0 - 0x0c) */
7296 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7297 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7298 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7299
7300 /* FIXME: use matrix-type input source selection */
7301 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7302 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7305 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7306 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7307 /* Input mixer2 */
7308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7310 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7312 /* Input mixer3 */
7313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7317 /* ADC1: mute amp left and right */
7318 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7319 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7320 /* ADC2: mute amp left and right */
7321 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7322 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7323 /* ADC3: mute amp left and right */
7324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7325 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7326
7327 { }
7328};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007329
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007330/* Macbook 5,1 */
7331static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007332 /* DACs */
7333 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7334 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7335 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7336 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007337 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007341 /* Surround mixer */
7342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7345 /* LFE mixer */
7346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7349 /* HP mixer */
7350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7353 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007356 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7357 /* LFE Pin (0x0e) */
7358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7361 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7363 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007364 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007365 /* Front Mic pin: input vref at 80% */
7366 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7368 /* Line In pin */
7369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7370 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7371
7372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7376 { }
7377};
7378
Takashi Iwai87350ad2007-08-16 18:19:38 +02007379/* Macbook Pro rev3 */
7380static struct hda_verb alc885_mbp3_init_verbs[] = {
7381 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7383 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7385 /* Rear mixer */
7386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7389 /* Front Pin: output 0 (0x0c) */
7390 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7391 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7392 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7393 /* HP Pin: output 0 (0x0d) */
7394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7395 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7396 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7397 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7398 /* Mic (rear) pin: input vref at 80% */
7399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7401 /* Front Mic pin: input vref at 80% */
7402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7404 /* Line In pin: use output 1 when in LineOut mode */
7405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7407 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7408
7409 /* FIXME: use matrix-type input source selection */
7410 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7411 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7415 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7416 /* Input mixer2 */
7417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7420 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7421 /* Input mixer3 */
7422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7426 /* ADC1: mute amp left and right */
7427 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7428 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7429 /* ADC2: mute amp left and right */
7430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7431 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7432 /* ADC3: mute amp left and right */
7433 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7434 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7435
7436 { }
7437};
7438
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007439/* iMac 24 mixer. */
7440static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7441 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7442 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7443 { } /* end */
7444};
7445
7446/* iMac 24 init verbs. */
7447static struct hda_verb alc885_imac24_init_verbs[] = {
7448 /* Internal speakers: output 0 (0x0c) */
7449 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7450 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7451 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7452 /* Internal speakers: output 0 (0x0c) */
7453 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7454 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7455 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7456 /* Headphone: output 0 (0x0c) */
7457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7459 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7460 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7461 /* Front Mic: input vref at 80% */
7462 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7463 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7464 { }
7465};
7466
7467/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007468static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007469{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007470 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007471
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007472 spec->autocfg.hp_pins[0] = 0x14;
7473 spec->autocfg.speaker_pins[0] = 0x18;
7474 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007475}
7476
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007477static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007478{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007479 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007480
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007481 spec->autocfg.hp_pins[0] = 0x15;
7482 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007483}
7484
7485
Kailang Yang272a5272007-05-14 11:00:38 +02007486static struct hda_verb alc882_targa_verbs[] = {
7487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7489
7490 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7491 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007492
Kailang Yang272a5272007-05-14 11:00:38 +02007493 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7494 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7495 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7496
7497 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007498 { } /* end */
7499};
7500
7501/* toggle speaker-output according to the hp-jack state */
7502static void alc882_targa_automute(struct hda_codec *codec)
7503{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007504 struct alc_spec *spec = codec->spec;
7505 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007506 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007507 spec->jack_present ? 1 : 3);
7508}
7509
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007510static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007511{
7512 struct alc_spec *spec = codec->spec;
7513
7514 spec->autocfg.hp_pins[0] = 0x14;
7515 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007516}
7517
7518static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7519{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007520 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007521 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007522}
7523
7524static struct hda_verb alc882_asus_a7j_verbs[] = {
7525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7527
7528 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7529 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7530 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007531
Kailang Yang272a5272007-05-14 11:00:38 +02007532 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7533 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7534 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7535
7536 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7537 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7538 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7539 { } /* end */
7540};
7541
Takashi Iwai914759b2007-09-06 14:52:04 +02007542static struct hda_verb alc882_asus_a7m_verbs[] = {
7543 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7544 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7545
7546 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7547 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7548 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007549
Takashi Iwai914759b2007-09-06 14:52:04 +02007550 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7551 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7552 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7553
7554 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7555 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7556 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7557 { } /* end */
7558};
7559
Tobin Davis9102cd12006-12-15 10:02:12 +01007560static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7561{
7562 unsigned int gpiostate, gpiomask, gpiodir;
7563
7564 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7565 AC_VERB_GET_GPIO_DATA, 0);
7566
7567 if (!muted)
7568 gpiostate |= (1 << pin);
7569 else
7570 gpiostate &= ~(1 << pin);
7571
7572 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7573 AC_VERB_GET_GPIO_MASK, 0);
7574 gpiomask |= (1 << pin);
7575
7576 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7577 AC_VERB_GET_GPIO_DIRECTION, 0);
7578 gpiodir |= (1 << pin);
7579
7580
7581 snd_hda_codec_write(codec, codec->afg, 0,
7582 AC_VERB_SET_GPIO_MASK, gpiomask);
7583 snd_hda_codec_write(codec, codec->afg, 0,
7584 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7585
7586 msleep(1);
7587
7588 snd_hda_codec_write(codec, codec->afg, 0,
7589 AC_VERB_SET_GPIO_DATA, gpiostate);
7590}
7591
Takashi Iwai7debbe52007-08-16 15:01:03 +02007592/* set up GPIO at initialization */
7593static void alc885_macpro_init_hook(struct hda_codec *codec)
7594{
7595 alc882_gpio_mute(codec, 0, 0);
7596 alc882_gpio_mute(codec, 1, 0);
7597}
7598
7599/* set up GPIO and update auto-muting at initialization */
7600static void alc885_imac24_init_hook(struct hda_codec *codec)
7601{
7602 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007603 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007604}
7605
Kailang Yangdf694da2005-12-05 19:42:22 +01007606/*
7607 * generic initialization of ADC, input mixers and output mixers
7608 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007609static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007610 /*
7611 * Unmute ADC0-2 and set the default input to mic-in
7612 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007613 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7615 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7617
Takashi Iwaicb53c622007-08-10 17:21:45 +02007618 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007619 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007620 * Note: PASD motherboards uses the Line In 2 as the input for
7621 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007622 */
7623 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7626 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7627 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7628 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007629
7630 /*
7631 * Set up output mixers (0x0c - 0x0f)
7632 */
7633 /* set vol=0 to output mixers */
7634 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7635 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7637 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7638 /* set up input amps for analog loopback */
7639 /* Amp Indices: DAC = 0, mixer = 1 */
7640 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7641 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7642 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7644 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7646 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7648 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7649 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7650
7651 /* FIXME: use matrix-type input source selection */
7652 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007653 /* Input mixer2 */
7654 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7655 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7656 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7657 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7658 /* Input mixer3 */
7659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7660 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7661 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7662 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7663
7664 { }
7665};
7666
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007667/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7668static struct hda_verb alc889A_mb31_ch2_init[] = {
7669 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7670 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7672 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7673 { } /* end */
7674};
7675
7676/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7677static struct hda_verb alc889A_mb31_ch4_init[] = {
7678 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7679 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7680 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7681 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7682 { } /* end */
7683};
7684
7685/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7686static struct hda_verb alc889A_mb31_ch5_init[] = {
7687 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7688 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7689 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7690 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7691 { } /* end */
7692};
7693
7694/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7695static struct hda_verb alc889A_mb31_ch6_init[] = {
7696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7697 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7698 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7700 { } /* end */
7701};
7702
7703static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7704 { 2, alc889A_mb31_ch2_init },
7705 { 4, alc889A_mb31_ch4_init },
7706 { 5, alc889A_mb31_ch5_init },
7707 { 6, alc889A_mb31_ch6_init },
7708};
7709
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007710static struct hda_verb alc883_medion_eapd_verbs[] = {
7711 /* eanable EAPD on medion laptop */
7712 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7713 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7714 { }
7715};
7716
Takashi Iwai4953550a2009-06-30 15:28:30 +02007717#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007718
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007719static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7720 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7721 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7722 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7723 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7724 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7725 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7726 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7731 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7732 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007733 { } /* end */
7734};
7735
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007736static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007737 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7738 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7739 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7740 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7742 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7746 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007747 { } /* end */
7748};
7749
Jiang zhefb97dc62008-03-06 11:07:11 +01007750static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7751 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7752 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7753 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7754 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7760 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007761 { } /* end */
7762};
7763
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007764static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7765 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7766 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7767 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7768 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7769 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7770 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7771 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7772 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007773 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007776 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007778 { } /* end */
7779};
7780
7781static struct snd_kcontrol_new alc883_3ST_6ch_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("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7785 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7786 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7787 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7788 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7789 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7790 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7791 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7792 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7793 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7794 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7795 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007797 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007799 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007800 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007801 { } /* end */
7802};
7803
Jiang zhe17bba1b2008-06-04 12:11:07 +02007804static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7806 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7808 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7809 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7810 HDA_OUTPUT),
7811 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7812 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7813 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7820 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7823 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7824 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007825 { } /* end */
7826};
7827
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007828static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7830 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7832 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7833 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7834 HDA_OUTPUT),
7835 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7836 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7837 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7838 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7839 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7842 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7844 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7846 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7847 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7848 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7849 { } /* end */
7850};
7851
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007852static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007853 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007855 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007856 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007857 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7858 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007859 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7860 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007861 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7864 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7866 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007867 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7869 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007872 { } /* end */
7873};
7874
Sasha Alexandrc2592492009-06-16 14:52:54 -04007875static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7878 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7879 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7880 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7881 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7883 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7884 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007892 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007893};
Kailang Yangccc656c2006-10-17 12:32:26 +02007894
Sasha Alexandrc2592492009-06-16 14:52:54 -04007895static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007896 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7898 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7899 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7900 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007902 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007903 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007904 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7905 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7906 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007907 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007908};
Kailang Yangccc656c2006-10-17 12:32:26 +02007909
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007910static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7911 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7912 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007913 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7914 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007915 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7916 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007919 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007920};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007921
Kailang Yang272a5272007-05-14 11:00:38 +02007922static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7923 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7924 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7930 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7931 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007932 { } /* end */
7933};
7934
7935static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7937 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7938 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7939 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7940 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7942 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7943 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7944 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007945 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007946};
Kailang Yang272a5272007-05-14 11:00:38 +02007947
Tobin Davis2880a862007-08-07 11:50:26 +02007948static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7950 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007957 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007958};
Tobin Davis2880a862007-08-07 11:50:26 +02007959
Tony Vroond2fd4b02009-06-21 00:40:10 +01007960static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7962 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7963 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7964 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007965 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7966 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007967 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7968 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7970 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7972 { } /* end */
7973};
7974
Kailang Yange2757d52008-08-26 13:17:46 +02007975static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7976 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7977 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7979 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7980 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7981 0x0d, 1, 0x0, HDA_OUTPUT),
7982 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7983 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7984 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7985 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7986 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007987 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7988 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7995 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007997 { } /* end */
7998};
7999
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008000static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8001 /* Output mixers */
8002 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8003 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8004 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8006 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8007 HDA_OUTPUT),
8008 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8009 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8010 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8011 /* Output switches */
8012 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8013 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8014 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8015 /* Boost mixers */
8016 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8017 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8018 /* Input mixers */
8019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8021 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8022 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8023 { } /* end */
8024};
8025
Guido Günther3e1647c52009-06-05 00:47:26 +02008026static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8027 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8028 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8031 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8032 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8033 { } /* end */
8034};
8035
Kailang Yange2757d52008-08-26 13:17:46 +02008036static struct hda_bind_ctls alc883_bind_cap_vol = {
8037 .ops = &snd_hda_bind_vol,
8038 .values = {
8039 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8040 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8041 0
8042 },
8043};
8044
8045static struct hda_bind_ctls alc883_bind_cap_switch = {
8046 .ops = &snd_hda_bind_sw,
8047 .values = {
8048 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8049 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8050 0
8051 },
8052};
8053
8054static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8055 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8056 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8058 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8059 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8061 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8062 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008063 { } /* end */
8064};
8065
8066static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008067 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8068 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8069 {
8070 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8071 /* .name = "Capture Source", */
8072 .name = "Input Source",
8073 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008074 .info = alc_mux_enum_info,
8075 .get = alc_mux_enum_get,
8076 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008077 },
8078 { } /* end */
8079};
8080
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008081static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8082 {
8083 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8084 .name = "Channel Mode",
8085 .info = alc_ch_mode_info,
8086 .get = alc_ch_mode_get,
8087 .put = alc_ch_mode_put,
8088 },
8089 { } /* end */
8090};
8091
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008092/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008093static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008094{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008095 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008096
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008097 spec->autocfg.hp_pins[0] = 0x15;
8098 spec->autocfg.speaker_pins[0] = 0x14;
8099 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008100}
8101
8102/* auto-toggle front mic */
8103/*
8104static void alc883_mitac_mic_automute(struct hda_codec *codec)
8105{
8106 unsigned int present;
8107 unsigned char bits;
8108
8109 present = snd_hda_codec_read(codec, 0x18, 0,
8110 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8111 bits = present ? HDA_AMP_MUTE : 0;
8112 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8113}
8114*/
8115
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008116static struct hda_verb alc883_mitac_verbs[] = {
8117 /* HP */
8118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8120 /* Subwoofer */
8121 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8122 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8123
8124 /* enable unsolicited event */
8125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8126 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8127
8128 { } /* end */
8129};
8130
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008131static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008132 /* HP */
8133 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8134 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8135 /* Int speaker */
8136 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8137 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8138
8139 /* enable unsolicited event */
8140 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008141 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008142
8143 { } /* end */
8144};
8145
Jiang zhefb97dc62008-03-06 11:07:11 +01008146static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8147 /* HP */
8148 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8150 /* Subwoofer */
8151 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8153
8154 /* enable unsolicited event */
8155 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8156
8157 { } /* end */
8158};
8159
Sasha Alexandrc2592492009-06-16 14:52:54 -04008160static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8163
8164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8165 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008166
David Heidelberger64a8be72009-06-08 16:15:18 +02008167/* Connect Line-Out side jack (SPDIF) to Side */
8168 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8169 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8170 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8171/* Connect Mic jack to CLFE */
8172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8173 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8174 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8175/* Connect Line-in jack to Surround */
8176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8178 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8179/* Connect HP out jack to Front */
8180 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8181 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8182 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008183
8184 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008185
8186 { } /* end */
8187};
8188
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008189static struct hda_verb alc883_lenovo_101e_verbs[] = {
8190 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8191 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8192 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8193 { } /* end */
8194};
8195
Kailang Yang272a5272007-05-14 11:00:38 +02008196static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8198 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8199 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8200 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8201 { } /* end */
8202};
8203
8204static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8207 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8208 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8209 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8210 { } /* end */
8211};
8212
Kailang Yang189609a2007-08-20 11:31:23 +02008213static struct hda_verb alc883_haier_w66_verbs[] = {
8214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8216
8217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8218
8219 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8221 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8222 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8223 { } /* end */
8224};
8225
Kailang Yange2757d52008-08-26 13:17:46 +02008226static struct hda_verb alc888_lenovo_sky_verbs[] = {
8227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8233 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8234 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8235 { } /* end */
8236};
8237
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008238static struct hda_verb alc888_6st_dell_verbs[] = {
8239 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8240 { }
8241};
8242
Guido Günther3e1647c52009-06-05 00:47:26 +02008243static struct hda_verb alc883_vaiott_verbs[] = {
8244 /* HP */
8245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8247
8248 /* enable unsolicited event */
8249 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8250
8251 { } /* end */
8252};
8253
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008254static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008255{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008256 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008257
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008258 spec->autocfg.hp_pins[0] = 0x1b;
8259 spec->autocfg.speaker_pins[0] = 0x14;
8260 spec->autocfg.speaker_pins[1] = 0x16;
8261 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008262}
8263
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008264static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008265 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008266 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8267 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008268 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008269 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008270};
8271
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008272/*
8273 * 2ch mode
8274 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008275static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008276 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8277 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8278 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8279 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008280 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008281};
8282
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008283/*
8284 * 4ch mode
8285 */
8286static struct hda_verb alc888_3st_hp_4ch_init[] = {
8287 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8288 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8289 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8290 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8291 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8292 { } /* end */
8293};
8294
8295/*
8296 * 6ch mode
8297 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008298static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008299 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8300 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008301 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008302 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8303 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008304 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8305 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008306};
8307
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008308static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008309 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008310 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008311 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008312};
8313
Kailang Yang272a5272007-05-14 11:00:38 +02008314/* toggle front-jack and RCA according to the hp-jack state */
8315static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8316{
8317 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008318
Kailang Yang272a5272007-05-14 11:00:38 +02008319 present = snd_hda_codec_read(codec, 0x1b, 0,
8320 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008321 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8322 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8323 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8324 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008325}
8326
8327/* toggle RCA according to the front-jack state */
8328static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8329{
8330 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008331
Kailang Yang272a5272007-05-14 11:00:38 +02008332 present = snd_hda_codec_read(codec, 0x14, 0,
8333 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008334 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8335 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008336}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008337
Kailang Yang272a5272007-05-14 11:00:38 +02008338static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8339 unsigned int res)
8340{
8341 if ((res >> 26) == ALC880_HP_EVENT)
8342 alc888_lenovo_ms7195_front_automute(codec);
8343 if ((res >> 26) == ALC880_FRONT_EVENT)
8344 alc888_lenovo_ms7195_rca_automute(codec);
8345}
8346
8347static struct hda_verb alc883_medion_md2_verbs[] = {
8348 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8350
8351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8352
8353 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8354 { } /* end */
8355};
8356
8357/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008358static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008359{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008360 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008361
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008362 spec->autocfg.hp_pins[0] = 0x14;
8363 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008364}
8365
Kailang Yangccc656c2006-10-17 12:32:26 +02008366/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008367#define alc883_targa_init_hook alc882_targa_init_hook
8368#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008369
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008370static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8371{
8372 unsigned int present;
8373
8374 present = snd_hda_codec_read(codec, 0x18, 0,
8375 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8376 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8377 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8378}
8379
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008380static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008381{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008382 struct alc_spec *spec = codec->spec;
8383
8384 spec->autocfg.hp_pins[0] = 0x15;
8385 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008386}
8387
8388static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8389{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008390 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008391 alc883_clevo_m720_mic_automute(codec);
8392}
8393
8394static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008395 unsigned int res)
8396{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008397 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008398 case ALC880_MIC_EVENT:
8399 alc883_clevo_m720_mic_automute(codec);
8400 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008401 default:
8402 alc_automute_amp_unsol_event(codec, res);
8403 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008404 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008405}
8406
Jiang zhefb97dc62008-03-06 11:07:11 +01008407/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008408static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008409{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008410 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008411
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008412 spec->autocfg.hp_pins[0] = 0x14;
8413 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008414}
8415
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008416static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008418 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008419
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008420 spec->autocfg.hp_pins[0] = 0x1b;
8421 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008422}
8423
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008424static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8425{
8426 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008427 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008428
David Heidelberger64a8be72009-06-08 16:15:18 +02008429 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8430 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008431 bits = present ? HDA_AMP_MUTE : 0;
8432 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8433 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008434}
8435
8436static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8437{
8438 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008439 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008440
8441 present = snd_hda_codec_read(codec, 0x1b, 0,
8442 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008443 bits = present ? HDA_AMP_MUTE : 0;
8444 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8445 HDA_AMP_MUTE, bits);
8446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8447 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008448}
8449
8450static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8451 unsigned int res)
8452{
8453 if ((res >> 26) == ALC880_HP_EVENT)
8454 alc883_lenovo_101e_all_automute(codec);
8455 if ((res >> 26) == ALC880_FRONT_EVENT)
8456 alc883_lenovo_101e_ispeaker_automute(codec);
8457}
8458
Takashi Iwai676a9b52007-08-16 15:23:35 +02008459/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008460static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008461{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008462 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008463
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008464 spec->autocfg.hp_pins[0] = 0x14;
8465 spec->autocfg.speaker_pins[0] = 0x15;
8466 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008467}
8468
Kailang Yangd1a991a2007-08-15 16:21:59 +02008469static struct hda_verb alc883_acer_eapd_verbs[] = {
8470 /* HP Pin: output 0 (0x0c) */
8471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8473 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8474 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8476 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008477 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008478 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8479 /* eanable EAPD on medion laptop */
8480 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8481 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008482 /* enable unsolicited event */
8483 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008484 { }
8485};
8486
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008487static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008488{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008489 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008490
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008491 spec->autocfg.hp_pins[0] = 0x1b;
8492 spec->autocfg.speaker_pins[0] = 0x14;
8493 spec->autocfg.speaker_pins[1] = 0x15;
8494 spec->autocfg.speaker_pins[2] = 0x16;
8495 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008496}
8497
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008498static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008499{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008500 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008501
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008502 spec->autocfg.hp_pins[0] = 0x1b;
8503 spec->autocfg.speaker_pins[0] = 0x14;
8504 spec->autocfg.speaker_pins[1] = 0x15;
8505 spec->autocfg.speaker_pins[2] = 0x16;
8506 spec->autocfg.speaker_pins[3] = 0x17;
8507 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008508}
8509
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008510static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02008511{
8512 struct alc_spec *spec = codec->spec;
8513
8514 spec->autocfg.hp_pins[0] = 0x15;
8515 spec->autocfg.speaker_pins[0] = 0x14;
8516 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02008517}
8518
Kailang Yange2757d52008-08-26 13:17:46 +02008519static struct hda_verb alc888_asus_m90v_verbs[] = {
8520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8521 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8522 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8523 /* enable unsolicited event */
8524 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8525 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8526 { } /* end */
8527};
8528
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008529static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008530{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008531 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008532
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008533 spec->autocfg.hp_pins[0] = 0x1b;
8534 spec->autocfg.speaker_pins[0] = 0x14;
8535 spec->autocfg.speaker_pins[1] = 0x15;
8536 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008537 spec->ext_mic.pin = 0x18;
8538 spec->int_mic.pin = 0x19;
8539 spec->ext_mic.mux_idx = 0;
8540 spec->int_mic.mux_idx = 1;
8541 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008542}
8543
8544static struct hda_verb alc888_asus_eee1601_verbs[] = {
8545 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8548 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8549 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8550 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8551 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8552 /* enable unsolicited event */
8553 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8554 { } /* end */
8555};
8556
Kailang Yange2757d52008-08-26 13:17:46 +02008557static void alc883_eee1601_inithook(struct hda_codec *codec)
8558{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008559 struct alc_spec *spec = codec->spec;
8560
8561 spec->autocfg.hp_pins[0] = 0x14;
8562 spec->autocfg.speaker_pins[0] = 0x1b;
8563 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008564}
8565
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008566static struct hda_verb alc889A_mb31_verbs[] = {
8567 /* Init rear pin (used as headphone output) */
8568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8569 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8570 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8571 /* Init line pin (used as output in 4ch and 6ch mode) */
8572 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8573 /* Init line 2 pin (used as headphone out by default) */
8574 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8575 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8576 { } /* end */
8577};
8578
8579/* Mute speakers according to the headphone jack state */
8580static void alc889A_mb31_automute(struct hda_codec *codec)
8581{
8582 unsigned int present;
8583
8584 /* Mute only in 2ch or 4ch mode */
8585 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8586 == 0x00) {
8587 present = snd_hda_codec_read(codec, 0x15, 0,
8588 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8589 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8590 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8591 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8592 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8593 }
8594}
8595
8596static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8597{
8598 if ((res >> 26) == ALC880_HP_EVENT)
8599 alc889A_mb31_automute(codec);
8600}
8601
Takashi Iwai4953550a2009-06-30 15:28:30 +02008602
Takashi Iwaicb53c622007-08-10 17:21:45 +02008603#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008604#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008605#endif
8606
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008607/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008608#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8609#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8610#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8611#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8612
8613static hda_nid_t alc883_slave_dig_outs[] = {
8614 ALC1200_DIGOUT_NID, 0,
8615};
8616
8617static hda_nid_t alc1200_slave_dig_outs[] = {
8618 ALC883_DIGOUT_NID, 0,
8619};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008620
8621/*
8622 * configuration and preset
8623 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008624static const char *alc882_models[ALC882_MODEL_LAST] = {
8625 [ALC882_3ST_DIG] = "3stack-dig",
8626 [ALC882_6ST_DIG] = "6stack-dig",
8627 [ALC882_ARIMA] = "arima",
8628 [ALC882_W2JC] = "w2jc",
8629 [ALC882_TARGA] = "targa",
8630 [ALC882_ASUS_A7J] = "asus-a7j",
8631 [ALC882_ASUS_A7M] = "asus-a7m",
8632 [ALC885_MACPRO] = "macpro",
8633 [ALC885_MB5] = "mb5",
8634 [ALC885_MBP3] = "mbp3",
8635 [ALC885_IMAC24] = "imac24",
8636 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008637 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8638 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008639 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008640 [ALC883_TARGA_DIG] = "targa-dig",
8641 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008642 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008643 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008644 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008645 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008646 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008647 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008648 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008649 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008650 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008651 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008652 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8653 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008654 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008655 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008656 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008657 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008658 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008659 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008660 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008661 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008662 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008663 [ALC889A_INTEL] = "intel-alc889a",
8664 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008665 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008666 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02008667 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008668 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008669};
8670
Takashi Iwai4953550a2009-06-30 15:28:30 +02008671static struct snd_pci_quirk alc882_cfg_tbl[] = {
8672 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8673
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008674 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008675 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008676 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008677 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8678 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008679 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008680 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8681 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008682 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8683 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008684 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8685 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008686 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8687 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008688 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8689 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008690 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008691 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008692 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008693 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008694 /* default Acer -- disabled as it causes more problems.
8695 * model=auto should work fine now
8696 */
8697 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008698
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008699 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008700
Tobin Davisfebe3372007-06-12 11:27:46 +02008701 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008702 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8703 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008704 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008705 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008706 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008707
8708 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8709 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8710 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008711 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008712 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8713 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8714 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008715 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008716 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008717 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008718 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008719
8720 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008721 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008722 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008723 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008724 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8725 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008726 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008727 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008728 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8729
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008730 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8731 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8732 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008733 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008734 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008735 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008736 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008737 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008738 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8739 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8740 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8741 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8742 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8743 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008744 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008745 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8746 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8747 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008748 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008749 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8750 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008751 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008752 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008753 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008754 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008755 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008756 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008757 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008758 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008759
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008760 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008761 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8762 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008763 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008764 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008765 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008766 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008767 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008768 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008769 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008770 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008771 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008772 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008773 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8774 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008775 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008776 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008777 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008778 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008779 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008780
Jiang zhe17bba1b2008-06-04 12:11:07 +02008781 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8782 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008783 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008784 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8785 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8786 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008787 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008788
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008789 {}
8790};
8791
Takashi Iwai4953550a2009-06-30 15:28:30 +02008792/* codec SSID table for Intel Mac */
8793static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8794 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8795 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8796 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8797 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8798 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8799 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8800 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8801 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8802 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8803 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8804 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8805 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8806 * no perfect solution yet
8807 */
8808 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8809 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008810};
8811
Takashi Iwai4953550a2009-06-30 15:28:30 +02008812static struct alc_config_preset alc882_presets[] = {
8813 [ALC882_3ST_DIG] = {
8814 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008815 .init_verbs = { alc882_base_init_verbs,
8816 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008817 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8818 .dac_nids = alc882_dac_nids,
8819 .dig_out_nid = ALC882_DIGOUT_NID,
8820 .dig_in_nid = ALC882_DIGIN_NID,
8821 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8822 .channel_mode = alc882_ch_modes,
8823 .need_dac_fix = 1,
8824 .input_mux = &alc882_capture_source,
8825 },
8826 [ALC882_6ST_DIG] = {
8827 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008828 .init_verbs = { alc882_base_init_verbs,
8829 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008830 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8831 .dac_nids = alc882_dac_nids,
8832 .dig_out_nid = ALC882_DIGOUT_NID,
8833 .dig_in_nid = ALC882_DIGIN_NID,
8834 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8835 .channel_mode = alc882_sixstack_modes,
8836 .input_mux = &alc882_capture_source,
8837 },
8838 [ALC882_ARIMA] = {
8839 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008840 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8841 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008842 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8843 .dac_nids = alc882_dac_nids,
8844 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8845 .channel_mode = alc882_sixstack_modes,
8846 .input_mux = &alc882_capture_source,
8847 },
8848 [ALC882_W2JC] = {
8849 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008850 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8851 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008852 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8853 .dac_nids = alc882_dac_nids,
8854 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8855 .channel_mode = alc880_threestack_modes,
8856 .need_dac_fix = 1,
8857 .input_mux = &alc882_capture_source,
8858 .dig_out_nid = ALC882_DIGOUT_NID,
8859 },
8860 [ALC885_MBP3] = {
8861 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8862 .init_verbs = { alc885_mbp3_init_verbs,
8863 alc880_gpio1_init_verbs },
8864 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8865 .dac_nids = alc882_dac_nids,
8866 .channel_mode = alc885_mbp_6ch_modes,
8867 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8868 .input_mux = &alc882_capture_source,
8869 .dig_out_nid = ALC882_DIGOUT_NID,
8870 .dig_in_nid = ALC882_DIGIN_NID,
8871 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008872 .setup = alc885_mbp3_setup,
8873 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008874 },
8875 [ALC885_MB5] = {
8876 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8877 .init_verbs = { alc885_mb5_init_verbs,
8878 alc880_gpio1_init_verbs },
8879 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8880 .dac_nids = alc882_dac_nids,
8881 .channel_mode = alc885_mb5_6ch_modes,
8882 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8883 .input_mux = &mb5_capture_source,
8884 .dig_out_nid = ALC882_DIGOUT_NID,
8885 .dig_in_nid = ALC882_DIGIN_NID,
8886 },
8887 [ALC885_MACPRO] = {
8888 .mixers = { alc882_macpro_mixer },
8889 .init_verbs = { alc882_macpro_init_verbs },
8890 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8891 .dac_nids = alc882_dac_nids,
8892 .dig_out_nid = ALC882_DIGOUT_NID,
8893 .dig_in_nid = ALC882_DIGIN_NID,
8894 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8895 .channel_mode = alc882_ch_modes,
8896 .input_mux = &alc882_capture_source,
8897 .init_hook = alc885_macpro_init_hook,
8898 },
8899 [ALC885_IMAC24] = {
8900 .mixers = { alc885_imac24_mixer },
8901 .init_verbs = { alc885_imac24_init_verbs },
8902 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8903 .dac_nids = alc882_dac_nids,
8904 .dig_out_nid = ALC882_DIGOUT_NID,
8905 .dig_in_nid = ALC882_DIGIN_NID,
8906 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8907 .channel_mode = alc882_ch_modes,
8908 .input_mux = &alc882_capture_source,
8909 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008910 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008911 .init_hook = alc885_imac24_init_hook,
8912 },
8913 [ALC882_TARGA] = {
8914 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008915 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008916 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008917 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8918 .dac_nids = alc882_dac_nids,
8919 .dig_out_nid = ALC882_DIGOUT_NID,
8920 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8921 .adc_nids = alc882_adc_nids,
8922 .capsrc_nids = alc882_capsrc_nids,
8923 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8924 .channel_mode = alc882_3ST_6ch_modes,
8925 .need_dac_fix = 1,
8926 .input_mux = &alc882_capture_source,
8927 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008928 .setup = alc882_targa_setup,
8929 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008930 },
8931 [ALC882_ASUS_A7J] = {
8932 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008933 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8934 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008935 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8936 .dac_nids = alc882_dac_nids,
8937 .dig_out_nid = ALC882_DIGOUT_NID,
8938 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8939 .adc_nids = alc882_adc_nids,
8940 .capsrc_nids = alc882_capsrc_nids,
8941 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8942 .channel_mode = alc882_3ST_6ch_modes,
8943 .need_dac_fix = 1,
8944 .input_mux = &alc882_capture_source,
8945 },
8946 [ALC882_ASUS_A7M] = {
8947 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008948 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8949 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008950 alc882_asus_a7m_verbs },
8951 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8952 .dac_nids = alc882_dac_nids,
8953 .dig_out_nid = ALC882_DIGOUT_NID,
8954 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8955 .channel_mode = alc880_threestack_modes,
8956 .need_dac_fix = 1,
8957 .input_mux = &alc882_capture_source,
8958 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008959 [ALC883_3ST_2ch_DIG] = {
8960 .mixers = { alc883_3ST_2ch_mixer },
8961 .init_verbs = { alc883_init_verbs },
8962 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8963 .dac_nids = alc883_dac_nids,
8964 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008965 .dig_in_nid = ALC883_DIGIN_NID,
8966 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8967 .channel_mode = alc883_3ST_2ch_modes,
8968 .input_mux = &alc883_capture_source,
8969 },
8970 [ALC883_3ST_6ch_DIG] = {
8971 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8972 .init_verbs = { alc883_init_verbs },
8973 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8974 .dac_nids = alc883_dac_nids,
8975 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008976 .dig_in_nid = ALC883_DIGIN_NID,
8977 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8978 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008979 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008980 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008981 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008982 [ALC883_3ST_6ch] = {
8983 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8984 .init_verbs = { alc883_init_verbs },
8985 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8986 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008987 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8988 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008989 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008990 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008991 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008992 [ALC883_3ST_6ch_INTEL] = {
8993 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8994 .init_verbs = { alc883_init_verbs },
8995 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8996 .dac_nids = alc883_dac_nids,
8997 .dig_out_nid = ALC883_DIGOUT_NID,
8998 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008999 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009000 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9001 .channel_mode = alc883_3ST_6ch_intel_modes,
9002 .need_dac_fix = 1,
9003 .input_mux = &alc883_3stack_6ch_intel,
9004 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009005 [ALC889A_INTEL] = {
9006 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009007 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9008 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009009 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9010 .dac_nids = alc883_dac_nids,
9011 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9012 .adc_nids = alc889_adc_nids,
9013 .dig_out_nid = ALC883_DIGOUT_NID,
9014 .dig_in_nid = ALC883_DIGIN_NID,
9015 .slave_dig_outs = alc883_slave_dig_outs,
9016 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9017 .channel_mode = alc889_8ch_intel_modes,
9018 .capsrc_nids = alc889_capsrc_nids,
9019 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009020 .setup = alc889_automute_setup,
9021 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009022 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009023 .need_dac_fix = 1,
9024 },
9025 [ALC889_INTEL] = {
9026 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9027 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009028 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009029 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9030 .dac_nids = alc883_dac_nids,
9031 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9032 .adc_nids = alc889_adc_nids,
9033 .dig_out_nid = ALC883_DIGOUT_NID,
9034 .dig_in_nid = ALC883_DIGIN_NID,
9035 .slave_dig_outs = alc883_slave_dig_outs,
9036 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9037 .channel_mode = alc889_8ch_intel_modes,
9038 .capsrc_nids = alc889_capsrc_nids,
9039 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009040 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009041 .init_hook = alc889_intel_init_hook,
9042 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009043 .need_dac_fix = 1,
9044 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009045 [ALC883_6ST_DIG] = {
9046 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9047 .init_verbs = { alc883_init_verbs },
9048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9049 .dac_nids = alc883_dac_nids,
9050 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009051 .dig_in_nid = ALC883_DIGIN_NID,
9052 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9053 .channel_mode = alc883_sixstack_modes,
9054 .input_mux = &alc883_capture_source,
9055 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009056 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009057 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009058 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9059 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009060 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9061 .dac_nids = alc883_dac_nids,
9062 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009063 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9064 .channel_mode = alc883_3ST_6ch_modes,
9065 .need_dac_fix = 1,
9066 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009067 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009068 .setup = alc882_targa_setup,
9069 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009070 },
9071 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009072 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009073 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9074 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9076 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009077 .adc_nids = alc883_adc_nids_alt,
9078 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009079 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009080 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9081 .channel_mode = alc883_3ST_2ch_modes,
9082 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009083 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009084 .setup = alc882_targa_setup,
9085 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009086 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009087 [ALC883_TARGA_8ch_DIG] = {
9088 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9089 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009090 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009091 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9092 .dac_nids = alc883_dac_nids,
9093 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9094 .adc_nids = alc883_adc_nids_rev,
9095 .capsrc_nids = alc883_capsrc_nids_rev,
9096 .dig_out_nid = ALC883_DIGOUT_NID,
9097 .dig_in_nid = ALC883_DIGIN_NID,
9098 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9099 .channel_mode = alc883_4ST_8ch_modes,
9100 .need_dac_fix = 1,
9101 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009102 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009103 .setup = alc882_targa_setup,
9104 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009105 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009106 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009107 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009108 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9109 * and the headphone jack. Turn this on and rely on the
9110 * standard mute methods whenever the user wants to turn
9111 * these outputs off.
9112 */
9113 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9114 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9115 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009116 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9117 .channel_mode = alc883_3ST_2ch_modes,
9118 .input_mux = &alc883_capture_source,
9119 },
Tobin Davis2880a862007-08-07 11:50:26 +02009120 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009121 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009122 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009123 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9124 .dac_nids = alc883_dac_nids,
9125 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009126 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9127 .channel_mode = alc883_3ST_2ch_modes,
9128 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009129 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009130 .setup = alc883_acer_aspire_setup,
9131 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009132 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009133 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009134 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009135 alc883_chmode_mixer },
9136 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9137 alc888_acer_aspire_4930g_verbs },
9138 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9139 .dac_nids = alc883_dac_nids,
9140 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9141 .adc_nids = alc883_adc_nids_rev,
9142 .capsrc_nids = alc883_capsrc_nids_rev,
9143 .dig_out_nid = ALC883_DIGOUT_NID,
9144 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9145 .channel_mode = alc883_3ST_6ch_modes,
9146 .need_dac_fix = 1,
9147 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009148 ARRAY_SIZE(alc888_2_capture_sources),
9149 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009150 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009151 .setup = alc888_acer_aspire_4930g_setup,
9152 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009153 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009154 [ALC888_ACER_ASPIRE_6530G] = {
9155 .mixers = { alc888_acer_aspire_6530_mixer },
9156 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9157 alc888_acer_aspire_6530g_verbs },
9158 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9159 .dac_nids = alc883_dac_nids,
9160 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9161 .adc_nids = alc883_adc_nids_rev,
9162 .capsrc_nids = alc883_capsrc_nids_rev,
9163 .dig_out_nid = ALC883_DIGOUT_NID,
9164 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9165 .channel_mode = alc883_3ST_2ch_modes,
9166 .num_mux_defs =
9167 ARRAY_SIZE(alc888_2_capture_sources),
9168 .input_mux = alc888_acer_aspire_6530_sources,
9169 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009170 .setup = alc888_acer_aspire_6530g_setup,
9171 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009172 },
Hector Martin3b315d72009-06-02 10:54:19 +02009173 [ALC888_ACER_ASPIRE_8930G] = {
9174 .mixers = { alc888_base_mixer,
9175 alc883_chmode_mixer },
9176 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009177 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009178 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9179 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009180 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9181 .adc_nids = alc889_adc_nids,
9182 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009183 .dig_out_nid = ALC883_DIGOUT_NID,
9184 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9185 .channel_mode = alc883_3ST_6ch_modes,
9186 .need_dac_fix = 1,
9187 .const_channel_count = 6,
9188 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009189 ARRAY_SIZE(alc889_capture_sources),
9190 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009191 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009192 .setup = alc889_acer_aspire_8930g_setup,
9193 .init_hook = alc_automute_amp,
Hector Martin3b315d72009-06-02 10:54:19 +02009194 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009195 [ALC883_MEDION] = {
9196 .mixers = { alc883_fivestack_mixer,
9197 alc883_chmode_mixer },
9198 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009199 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009200 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9201 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009202 .adc_nids = alc883_adc_nids_alt,
9203 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009204 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9205 .channel_mode = alc883_sixstack_modes,
9206 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009207 },
Kailang Yang272a5272007-05-14 11:00:38 +02009208 [ALC883_MEDION_MD2] = {
9209 .mixers = { alc883_medion_md2_mixer},
9210 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9211 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9212 .dac_nids = alc883_dac_nids,
9213 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9215 .channel_mode = alc883_3ST_2ch_modes,
9216 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009217 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009218 .setup = alc883_medion_md2_setup,
9219 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009220 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009221 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009222 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009223 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9224 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9225 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9227 .channel_mode = alc883_3ST_2ch_modes,
9228 .input_mux = &alc883_capture_source,
9229 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009230 [ALC883_CLEVO_M720] = {
9231 .mixers = { alc883_clevo_m720_mixer },
9232 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9234 .dac_nids = alc883_dac_nids,
9235 .dig_out_nid = ALC883_DIGOUT_NID,
9236 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9237 .channel_mode = alc883_3ST_2ch_modes,
9238 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009239 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009240 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009241 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009242 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009243 [ALC883_LENOVO_101E_2ch] = {
9244 .mixers = { alc883_lenovo_101e_2ch_mixer},
9245 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9246 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9247 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009248 .adc_nids = alc883_adc_nids_alt,
9249 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009250 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9251 .channel_mode = alc883_3ST_2ch_modes,
9252 .input_mux = &alc883_lenovo_101e_capture_source,
9253 .unsol_event = alc883_lenovo_101e_unsol_event,
9254 .init_hook = alc883_lenovo_101e_all_automute,
9255 },
Kailang Yang272a5272007-05-14 11:00:38 +02009256 [ALC883_LENOVO_NB0763] = {
9257 .mixers = { alc883_lenovo_nb0763_mixer },
9258 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9259 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9260 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009261 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9262 .channel_mode = alc883_3ST_2ch_modes,
9263 .need_dac_fix = 1,
9264 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009265 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009266 .setup = alc883_medion_md2_setup,
9267 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009268 },
9269 [ALC888_LENOVO_MS7195_DIG] = {
9270 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9271 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9272 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9273 .dac_nids = alc883_dac_nids,
9274 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009275 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9276 .channel_mode = alc883_3ST_6ch_modes,
9277 .need_dac_fix = 1,
9278 .input_mux = &alc883_capture_source,
9279 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9280 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009281 },
9282 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009283 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009284 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9285 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9286 .dac_nids = alc883_dac_nids,
9287 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009288 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9289 .channel_mode = alc883_3ST_2ch_modes,
9290 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009291 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009292 .setup = alc883_haier_w66_setup,
9293 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009294 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009295 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009296 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009297 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009298 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9299 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009300 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9301 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009302 .need_dac_fix = 1,
9303 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009304 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009305 .setup = alc888_3st_hp_setup,
9306 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009307 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009308 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009309 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009310 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9312 .dac_nids = alc883_dac_nids,
9313 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009314 .dig_in_nid = ALC883_DIGIN_NID,
9315 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9316 .channel_mode = alc883_sixstack_modes,
9317 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009318 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009319 .setup = alc888_6st_dell_setup,
9320 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009321 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009322 [ALC883_MITAC] = {
9323 .mixers = { alc883_mitac_mixer },
9324 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9325 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9326 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009327 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9328 .channel_mode = alc883_3ST_2ch_modes,
9329 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009330 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009331 .setup = alc883_mitac_setup,
9332 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009333 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009334 [ALC883_FUJITSU_PI2515] = {
9335 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9336 .init_verbs = { alc883_init_verbs,
9337 alc883_2ch_fujitsu_pi2515_verbs},
9338 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9339 .dac_nids = alc883_dac_nids,
9340 .dig_out_nid = ALC883_DIGOUT_NID,
9341 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9342 .channel_mode = alc883_3ST_2ch_modes,
9343 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009344 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009345 .setup = alc883_2ch_fujitsu_pi2515_setup,
9346 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009347 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009348 [ALC888_FUJITSU_XA3530] = {
9349 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9350 .init_verbs = { alc883_init_verbs,
9351 alc888_fujitsu_xa3530_verbs },
9352 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9353 .dac_nids = alc883_dac_nids,
9354 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9355 .adc_nids = alc883_adc_nids_rev,
9356 .capsrc_nids = alc883_capsrc_nids_rev,
9357 .dig_out_nid = ALC883_DIGOUT_NID,
9358 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9359 .channel_mode = alc888_4ST_8ch_intel_modes,
9360 .num_mux_defs =
9361 ARRAY_SIZE(alc888_2_capture_sources),
9362 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009363 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009364 .setup = alc888_fujitsu_xa3530_setup,
9365 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009366 },
Kailang Yange2757d52008-08-26 13:17:46 +02009367 [ALC888_LENOVO_SKY] = {
9368 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9369 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9370 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9371 .dac_nids = alc883_dac_nids,
9372 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009373 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9374 .channel_mode = alc883_sixstack_modes,
9375 .need_dac_fix = 1,
9376 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009377 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009378 .setup = alc888_lenovo_sky_setup,
9379 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009380 },
9381 [ALC888_ASUS_M90V] = {
9382 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9383 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9384 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9385 .dac_nids = alc883_dac_nids,
9386 .dig_out_nid = ALC883_DIGOUT_NID,
9387 .dig_in_nid = ALC883_DIGIN_NID,
9388 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9389 .channel_mode = alc883_3ST_6ch_modes,
9390 .need_dac_fix = 1,
9391 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009392 .unsol_event = alc_sku_unsol_event,
9393 .setup = alc883_mode2_setup,
9394 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009395 },
9396 [ALC888_ASUS_EEE1601] = {
9397 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009398 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009399 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9400 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9401 .dac_nids = alc883_dac_nids,
9402 .dig_out_nid = ALC883_DIGOUT_NID,
9403 .dig_in_nid = ALC883_DIGIN_NID,
9404 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9405 .channel_mode = alc883_3ST_2ch_modes,
9406 .need_dac_fix = 1,
9407 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009408 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009409 .init_hook = alc883_eee1601_inithook,
9410 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009411 [ALC1200_ASUS_P5Q] = {
9412 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9413 .init_verbs = { alc883_init_verbs },
9414 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9415 .dac_nids = alc883_dac_nids,
9416 .dig_out_nid = ALC1200_DIGOUT_NID,
9417 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009418 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009419 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9420 .channel_mode = alc883_sixstack_modes,
9421 .input_mux = &alc883_capture_source,
9422 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009423 [ALC889A_MB31] = {
9424 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9425 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9426 alc880_gpio1_init_verbs },
9427 .adc_nids = alc883_adc_nids,
9428 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9429 .dac_nids = alc883_dac_nids,
9430 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9431 .channel_mode = alc889A_mb31_6ch_modes,
9432 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9433 .input_mux = &alc889A_mb31_capture_source,
9434 .dig_out_nid = ALC883_DIGOUT_NID,
9435 .unsol_event = alc889A_mb31_unsol_event,
9436 .init_hook = alc889A_mb31_automute,
9437 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009438 [ALC883_SONY_VAIO_TT] = {
9439 .mixers = { alc883_vaiott_mixer },
9440 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9441 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9442 .dac_nids = alc883_dac_nids,
9443 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9444 .channel_mode = alc883_3ST_2ch_modes,
9445 .input_mux = &alc883_capture_source,
9446 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009447 .setup = alc883_vaiott_setup,
9448 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +02009449 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009450};
9451
9452
9453/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009454 * Pin config fixes
9455 */
9456enum {
9457 PINFIX_ABIT_AW9D_MAX
9458};
9459
9460static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9461 { 0x15, 0x01080104 }, /* side */
9462 { 0x16, 0x01011012 }, /* rear */
9463 { 0x17, 0x01016011 }, /* clfe */
9464 { }
9465};
9466
9467static const struct alc_pincfg *alc882_pin_fixes[] = {
9468 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9469};
9470
9471static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9472 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9473 {}
9474};
9475
9476/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009477 * BIOS auto configuration
9478 */
Takashi Iwai05f5f472009-08-25 13:10:18 +02009479static int alc882_auto_create_input_ctls(struct hda_codec *codec,
9480 const struct auto_pin_cfg *cfg)
9481{
9482 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
9483}
9484
Takashi Iwai4953550a2009-06-30 15:28:30 +02009485static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009486 hda_nid_t nid, int pin_type,
9487 int dac_idx)
9488{
9489 /* set as output */
9490 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009491 int idx;
9492
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009493 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009494 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9495 idx = 4;
9496 else
9497 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009498 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9499
9500}
9501
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009503{
9504 struct alc_spec *spec = codec->spec;
9505 int i;
9506
9507 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009508 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009509 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009510 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009511 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009512 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009513 }
9514}
9515
Takashi Iwai4953550a2009-06-30 15:28:30 +02009516static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009517{
9518 struct alc_spec *spec = codec->spec;
9519 hda_nid_t pin;
9520
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009521 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009522 if (pin) /* connect to front */
9523 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009524 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009525 pin = spec->autocfg.speaker_pins[0];
9526 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009527 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009528}
9529
Takashi Iwai4953550a2009-06-30 15:28:30 +02009530static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009531{
9532 struct alc_spec *spec = codec->spec;
9533 int i;
9534
9535 for (i = 0; i < AUTO_PIN_LAST; i++) {
9536 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009537 if (!nid)
9538 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009539 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009540 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9541 snd_hda_codec_write(codec, nid, 0,
9542 AC_VERB_SET_AMP_GAIN_MUTE,
9543 AMP_OUT_MUTE);
9544 }
9545}
9546
9547static void alc882_auto_init_input_src(struct hda_codec *codec)
9548{
9549 struct alc_spec *spec = codec->spec;
9550 int c;
9551
9552 for (c = 0; c < spec->num_adc_nids; c++) {
9553 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9554 hda_nid_t nid = spec->capsrc_nids[c];
9555 unsigned int mux_idx;
9556 const struct hda_input_mux *imux;
9557 int conns, mute, idx, item;
9558
9559 conns = snd_hda_get_connections(codec, nid, conn_list,
9560 ARRAY_SIZE(conn_list));
9561 if (conns < 0)
9562 continue;
9563 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9564 imux = &spec->input_mux[mux_idx];
9565 for (idx = 0; idx < conns; idx++) {
9566 /* if the current connection is the selected one,
9567 * unmute it as default - otherwise mute it
9568 */
9569 mute = AMP_IN_MUTE(idx);
9570 for (item = 0; item < imux->num_items; item++) {
9571 if (imux->items[item].index == idx) {
9572 if (spec->cur_mux[c] == item)
9573 mute = AMP_IN_UNMUTE(idx);
9574 break;
9575 }
9576 }
9577 /* check if we have a selector or mixer
9578 * we could check for the widget type instead, but
9579 * just check for Amp-In presence (in case of mixer
9580 * without amp-in there is something wrong, this
9581 * function shouldn't be used or capsrc nid is wrong)
9582 */
9583 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009584 snd_hda_codec_write(codec, nid, 0,
9585 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009586 mute);
9587 else if (mute != AMP_IN_MUTE(idx))
9588 snd_hda_codec_write(codec, nid, 0,
9589 AC_VERB_SET_CONNECT_SEL,
9590 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009591 }
9592 }
9593}
9594
Takashi Iwai4953550a2009-06-30 15:28:30 +02009595/* add mic boosts if needed */
9596static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009597{
9598 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009599 int err;
9600 hda_nid_t nid;
9601
9602 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9603 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9604 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9605 "Mic Boost",
9606 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9607 if (err < 0)
9608 return err;
9609 }
9610 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9611 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9612 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9613 "Front Mic Boost",
9614 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9615 if (err < 0)
9616 return err;
9617 }
9618 return 0;
9619}
9620
9621/* almost identical with ALC880 parser... */
9622static int alc882_parse_auto_config(struct hda_codec *codec)
9623{
9624 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009625 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
9626 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009627
Takashi Iwai05f5f472009-08-25 13:10:18 +02009628 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9629 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009630 if (err < 0)
9631 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02009632 if (!spec->autocfg.line_outs)
9633 return 0; /* can't find valid BIOS pin config */
9634
9635 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
9636 if (err < 0)
9637 return err;
9638 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
9639 if (err < 0)
9640 return err;
9641 err = alc880_auto_create_extra_out(spec,
9642 spec->autocfg.speaker_pins[0],
9643 "Speaker");
9644 if (err < 0)
9645 return err;
9646 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
9647 "Headphone");
9648 if (err < 0)
9649 return err;
9650 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
9651 if (err < 0)
9652 return err;
9653
9654 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9655
9656 /* check multiple SPDIF-out (for recent codecs) */
9657 for (i = 0; i < spec->autocfg.dig_outs; i++) {
9658 hda_nid_t dig_nid;
9659 err = snd_hda_get_connections(codec,
9660 spec->autocfg.dig_out_pins[i],
9661 &dig_nid, 1);
9662 if (err < 0)
9663 continue;
9664 if (!i)
9665 spec->multiout.dig_out_nid = dig_nid;
9666 else {
9667 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
9668 spec->slave_dig_outs[i - 1] = dig_nid;
9669 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
9670 break;
9671 }
9672 }
9673 if (spec->autocfg.dig_in_pin)
9674 spec->dig_in_nid = ALC880_DIGIN_NID;
9675
9676 if (spec->kctls.list)
9677 add_mixer(spec, spec->kctls.list);
9678
9679 add_verb(spec, alc883_auto_init_verbs);
9680 /* if ADC 0x07 is available, initialize it, too */
9681 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
9682 add_verb(spec, alc882_adc1_init_verbs);
9683
9684 spec->num_mux_defs = 1;
9685 spec->input_mux = &spec->private_imux[0];
9686
9687 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
Takashi Iwai776e1842007-08-29 15:07:11 +02009688
9689 err = alc_auto_add_mic_boost(codec);
9690 if (err < 0)
9691 return err;
9692
Takashi Iwai776e1842007-08-29 15:07:11 +02009693 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009694}
9695
9696/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009697static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009698{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009699 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009700 alc882_auto_init_multi_out(codec);
9701 alc882_auto_init_hp_out(codec);
9702 alc882_auto_init_analog_input(codec);
9703 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009704 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009705 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009706}
9707
Takashi Iwai4953550a2009-06-30 15:28:30 +02009708static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709{
9710 struct alc_spec *spec;
9711 int err, board_config;
9712
9713 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9714 if (spec == NULL)
9715 return -ENOMEM;
9716
9717 codec->spec = spec;
9718
Takashi Iwai4953550a2009-06-30 15:28:30 +02009719 switch (codec->vendor_id) {
9720 case 0x10ec0882:
9721 case 0x10ec0885:
9722 break;
9723 default:
9724 /* ALC883 and variants */
9725 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9726 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727 }
9728
Takashi Iwai4953550a2009-06-30 15:28:30 +02009729 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9730 alc882_models,
9731 alc882_cfg_tbl);
9732
9733 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9734 board_config = snd_hda_check_board_codec_sid_config(codec,
9735 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9736
9737 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009738 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009739 codec->chip_name);
9740 board_config = ALC882_AUTO;
9741 }
9742
9743 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9744
9745 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009746 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009747 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009748 if (err < 0) {
9749 alc_free(codec);
9750 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009751 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009752 printk(KERN_INFO
9753 "hda_codec: Cannot set up configuration "
9754 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009755 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009756 }
9757 }
9758
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009759 err = snd_hda_attach_beep_device(codec, 0x1);
9760 if (err < 0) {
9761 alc_free(codec);
9762 return err;
9763 }
9764
Takashi Iwai4953550a2009-06-30 15:28:30 +02009765 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009766 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009767
Takashi Iwai4953550a2009-06-30 15:28:30 +02009768 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9769 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9770 /* FIXME: setup DAC5 */
9771 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9772 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9773
9774 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9775 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9776
9777 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba342009-04-22 16:31:35 +02009778 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779
9780 if (!spec->adc_nids && spec->input_mux) {
9781 int i;
9782 spec->num_adc_nids = 0;
9783 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9784 hda_nid_t cap;
9785 hda_nid_t nid = alc882_adc_nids[i];
9786 unsigned int wcap = get_wcaps(codec, nid);
9787 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009788 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789 if (wcap != AC_WID_AUD_IN)
9790 continue;
9791 spec->private_adc_nids[spec->num_adc_nids] = nid;
9792 err = snd_hda_get_connections(codec, nid, &cap, 1);
9793 if (err < 0)
9794 continue;
9795 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9796 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009797 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009798 spec->adc_nids = spec->private_adc_nids;
9799 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009800 }
9801
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009802 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009803 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009804
Takashi Iwai2134ea42008-01-10 16:53:55 +01009805 spec->vmaster_nid = 0x0c;
9806
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009807 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009808 if (board_config == ALC882_AUTO)
9809 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009810#ifdef CONFIG_SND_HDA_POWER_SAVE
9811 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009812 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009813#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009814 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009815
9816 return 0;
9817}
9818
Takashi Iwai4953550a2009-06-30 15:28:30 +02009819
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009820/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009821 * ALC262 support
9822 */
9823
9824#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9825#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9826
9827#define alc262_dac_nids alc260_dac_nids
9828#define alc262_adc_nids alc882_adc_nids
9829#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009830#define alc262_capsrc_nids alc882_capsrc_nids
9831#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009832
9833#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009834#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009835
Kailang Yang4e555fe2008-08-26 13:05:55 +02009836static hda_nid_t alc262_dmic_adc_nids[1] = {
9837 /* ADC0 */
9838 0x09
9839};
9840
9841static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9842
Kailang Yangdf694da2005-12-05 19:42:22 +01009843static struct snd_kcontrol_new alc262_base_mixer[] = {
9844 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9845 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9846 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9847 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009853 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9854 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009855 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009856 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9857 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9858 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9859 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009860 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009861};
9862
Takashi Iwaice875f02008-01-28 18:17:43 +01009863/* update HP, line and mono-out pins according to the master switch */
9864static void alc262_hp_master_update(struct hda_codec *codec)
9865{
9866 struct alc_spec *spec = codec->spec;
9867 int val = spec->master_sw;
9868
9869 /* HP & line-out */
9870 snd_hda_codec_write_cache(codec, 0x1b, 0,
9871 AC_VERB_SET_PIN_WIDGET_CONTROL,
9872 val ? PIN_HP : 0);
9873 snd_hda_codec_write_cache(codec, 0x15, 0,
9874 AC_VERB_SET_PIN_WIDGET_CONTROL,
9875 val ? PIN_HP : 0);
9876 /* mono (speaker) depending on the HP jack sense */
9877 val = val && !spec->jack_present;
9878 snd_hda_codec_write_cache(codec, 0x16, 0,
9879 AC_VERB_SET_PIN_WIDGET_CONTROL,
9880 val ? PIN_OUT : 0);
9881}
9882
9883static void alc262_hp_bpc_automute(struct hda_codec *codec)
9884{
9885 struct alc_spec *spec = codec->spec;
9886 unsigned int presence;
9887 presence = snd_hda_codec_read(codec, 0x1b, 0,
9888 AC_VERB_GET_PIN_SENSE, 0);
9889 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9890 alc262_hp_master_update(codec);
9891}
9892
9893static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9894{
9895 if ((res >> 26) != ALC880_HP_EVENT)
9896 return;
9897 alc262_hp_bpc_automute(codec);
9898}
9899
9900static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9901{
9902 struct alc_spec *spec = codec->spec;
9903 unsigned int presence;
9904 presence = snd_hda_codec_read(codec, 0x15, 0,
9905 AC_VERB_GET_PIN_SENSE, 0);
9906 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9907 alc262_hp_master_update(codec);
9908}
9909
9910static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9911 unsigned int res)
9912{
9913 if ((res >> 26) != ALC880_HP_EVENT)
9914 return;
9915 alc262_hp_wildwest_automute(codec);
9916}
9917
Takashi Iwaib72519b2009-05-08 14:31:55 +02009918#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009919
9920static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9921 struct snd_ctl_elem_value *ucontrol)
9922{
9923 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9924 struct alc_spec *spec = codec->spec;
9925 int val = !!*ucontrol->value.integer.value;
9926
9927 if (val == spec->master_sw)
9928 return 0;
9929 spec->master_sw = val;
9930 alc262_hp_master_update(codec);
9931 return 1;
9932}
9933
Takashi Iwaib72519b2009-05-08 14:31:55 +02009934#define ALC262_HP_MASTER_SWITCH \
9935 { \
9936 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9937 .name = "Master Playback Switch", \
9938 .info = snd_ctl_boolean_mono_info, \
9939 .get = alc262_hp_master_sw_get, \
9940 .put = alc262_hp_master_sw_put, \
9941 }
9942
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009943static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009944 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009945 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9946 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9947 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009948 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9949 HDA_OUTPUT),
9950 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9951 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9953 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009954 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009955 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9956 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009957 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9959 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9960 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9961 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009962 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9963 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9964 { } /* end */
9965};
9966
Kailang Yangcd7509a2007-01-26 18:33:17 +01009967static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009968 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009969 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9970 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009973 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9974 HDA_OUTPUT),
9975 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9976 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009979 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009984 { } /* end */
9985};
9986
9987static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9988 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9989 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009990 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009991 { } /* end */
9992};
9993
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009994/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009995static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009996{
9997 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009998
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009999 spec->autocfg.hp_pins[0] = 0x15;
10000 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010001}
10002
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010003static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10005 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010006 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10010 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10011 { } /* end */
10012};
10013
10014static struct hda_verb alc262_hp_t5735_verbs[] = {
10015 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10017
10018 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10019 { }
10020};
10021
Kailang Yang8c427222008-01-10 13:03:59 +010010022static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010023 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010025 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10026 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10029 { } /* end */
10030};
10031
10032static struct hda_verb alc262_hp_rp5700_verbs[] = {
10033 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10034 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10035 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10037 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10038 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10039 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10041 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10043 {}
10044};
10045
10046static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10047 .num_items = 1,
10048 .items = {
10049 { "Line", 0x1 },
10050 },
10051};
10052
Takashi Iwai42171c12009-05-08 14:11:43 +020010053/* bind hp and internal speaker mute (with plug check) as master switch */
10054static void alc262_hippo_master_update(struct hda_codec *codec)
10055{
10056 struct alc_spec *spec = codec->spec;
10057 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10058 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10059 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10060 unsigned int mute;
10061
10062 /* HP */
10063 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10064 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10065 HDA_AMP_MUTE, mute);
10066 /* mute internal speaker per jack sense */
10067 if (spec->jack_present)
10068 mute = HDA_AMP_MUTE;
10069 if (line_nid)
10070 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10071 HDA_AMP_MUTE, mute);
10072 if (speaker_nid && speaker_nid != line_nid)
10073 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10074 HDA_AMP_MUTE, mute);
10075}
10076
10077#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10078
10079static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10080 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010081{
10082 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010083 struct alc_spec *spec = codec->spec;
10084 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010085
Takashi Iwai42171c12009-05-08 14:11:43 +020010086 if (val == spec->master_sw)
10087 return 0;
10088 spec->master_sw = val;
10089 alc262_hippo_master_update(codec);
10090 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010091}
Takashi Iwai5b319542007-07-26 11:49:22 +020010092
Takashi Iwai42171c12009-05-08 14:11:43 +020010093#define ALC262_HIPPO_MASTER_SWITCH \
10094 { \
10095 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10096 .name = "Master Playback Switch", \
10097 .info = snd_ctl_boolean_mono_info, \
10098 .get = alc262_hippo_master_sw_get, \
10099 .put = alc262_hippo_master_sw_put, \
10100 }
10101
10102static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10103 ALC262_HIPPO_MASTER_SWITCH,
10104 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10105 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10106 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10109 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10111 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10112 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10113 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10114 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10115 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10116 { } /* end */
10117};
10118
10119static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10120 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10121 ALC262_HIPPO_MASTER_SWITCH,
10122 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10123 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10124 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10125 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10126 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10127 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10128 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10129 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10130 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10131 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10132 { } /* end */
10133};
10134
10135/* mute/unmute internal speaker according to the hp jack and mute state */
10136static void alc262_hippo_automute(struct hda_codec *codec)
10137{
10138 struct alc_spec *spec = codec->spec;
10139 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10140 unsigned int present;
10141
10142 /* need to execute and sync at first */
10143 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10144 present = snd_hda_codec_read(codec, hp_nid, 0,
10145 AC_VERB_GET_PIN_SENSE, 0);
10146 spec->jack_present = (present & 0x80000000) != 0;
10147 alc262_hippo_master_update(codec);
10148}
10149
10150static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10151{
10152 if ((res >> 26) != ALC880_HP_EVENT)
10153 return;
10154 alc262_hippo_automute(codec);
10155}
10156
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010157static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010158{
10159 struct alc_spec *spec = codec->spec;
10160
10161 spec->autocfg.hp_pins[0] = 0x15;
10162 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010163}
10164
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010165static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010166{
10167 struct alc_spec *spec = codec->spec;
10168
10169 spec->autocfg.hp_pins[0] = 0x1b;
10170 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010171}
10172
10173
Kailang Yang272a5272007-05-14 11:00:38 +020010174static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010175 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010176 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10179 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10180 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10181 { } /* end */
10182};
10183
Kailang Yang83c34212007-07-05 11:43:05 +020010184static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010185 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10186 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10188 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10189 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10190 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10191 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10192 { } /* end */
10193};
Kailang Yang272a5272007-05-14 11:00:38 +020010194
Tony Vroonba340e82009-02-02 19:01:30 +000010195static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10196 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10197 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10198 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10199 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10200 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10201 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10202 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10203 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10204 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10205 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10206 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10207 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10208 { } /* end */
10209};
10210
10211static struct hda_verb alc262_tyan_verbs[] = {
10212 /* Headphone automute */
10213 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10214 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10215 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10216
10217 /* P11 AUX_IN, white 4-pin connector */
10218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10219 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10220 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10221 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10222
10223 {}
10224};
10225
10226/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010227static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010228{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010229 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010230
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010231 spec->autocfg.hp_pins[0] = 0x1b;
10232 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010233}
10234
Tony Vroonba340e82009-02-02 19:01:30 +000010235
Kailang Yangdf694da2005-12-05 19:42:22 +010010236#define alc262_capture_mixer alc882_capture_mixer
10237#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10238
10239/*
10240 * generic initialization of ADC, input mixers and output mixers
10241 */
10242static struct hda_verb alc262_init_verbs[] = {
10243 /*
10244 * Unmute ADC0-2 and set the default input to mic-in
10245 */
10246 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10248 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10249 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10250 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10251 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10252
Takashi Iwaicb53c622007-08-10 17:21:45 +020010253 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010254 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010255 * Note: PASD motherboards uses the Line In 2 as the input for
10256 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010257 */
10258 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010259 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010264
10265 /*
10266 * Set up output mixers (0x0c - 0x0e)
10267 */
10268 /* set vol=0 to output mixers */
10269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10270 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10271 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10272 /* set up input amps for analog loopback */
10273 /* Amp Indices: DAC = 0, mixer = 1 */
10274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10276 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10280
10281 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10283 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10284 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10286 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10287
10288 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10291 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10292 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010293
Kailang Yangdf694da2005-12-05 19:42:22 +010010294 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10295 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010296
Kailang Yangdf694da2005-12-05 19:42:22 +010010297 /* FIXME: use matrix-type input source selection */
10298 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10299 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10300 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10304 /* Input mixer2 */
10305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10309 /* Input mixer3 */
10310 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010314
10315 { }
10316};
10317
Kailang Yang4e555fe2008-08-26 13:05:55 +020010318static struct hda_verb alc262_eapd_verbs[] = {
10319 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10320 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10321 { }
10322};
10323
Kailang Yangccc656c2006-10-17 12:32:26 +020010324static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10325 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10326 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10327 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10328
10329 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10331 {}
10332};
10333
Kailang Yang272a5272007-05-14 11:00:38 +020010334static struct hda_verb alc262_sony_unsol_verbs[] = {
10335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10337 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10338
10339 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010341 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010342};
10343
Kailang Yang4e555fe2008-08-26 13:05:55 +020010344static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10345 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10346 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10347 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010350 { } /* end */
10351};
10352
10353static struct hda_verb alc262_toshiba_s06_verbs[] = {
10354 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10356 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10357 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10358 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10359 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10360 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10361 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10362 {}
10363};
10364
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010365static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010366{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010367 struct alc_spec *spec = codec->spec;
10368
10369 spec->autocfg.hp_pins[0] = 0x15;
10370 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010371 spec->ext_mic.pin = 0x18;
10372 spec->ext_mic.mux_idx = 0;
10373 spec->int_mic.pin = 0x12;
10374 spec->int_mic.mux_idx = 9;
10375 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010376}
10377
Takashi Iwai834be882006-03-01 14:16:17 +010010378/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010379 * nec model
10380 * 0x15 = headphone
10381 * 0x16 = internal speaker
10382 * 0x18 = external mic
10383 */
10384
10385static struct snd_kcontrol_new alc262_nec_mixer[] = {
10386 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10387 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10388
10389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10392
10393 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10395 { } /* end */
10396};
10397
10398static struct hda_verb alc262_nec_verbs[] = {
10399 /* Unmute Speaker */
10400 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10401
10402 /* Headphone */
10403 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10404 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10405
10406 /* External mic to headphone */
10407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10408 /* External mic to speaker */
10409 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10410 {}
10411};
10412
10413/*
Takashi Iwai834be882006-03-01 14:16:17 +010010414 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010415 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10416 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010417 */
10418
10419#define ALC_HP_EVENT 0x37
10420
10421static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10422 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010424 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010426 {}
10427};
10428
Jiang zhe0e31daf2008-03-20 12:12:39 +010010429static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10430 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10431 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10432 {}
10433};
10434
Takashi Iwai834be882006-03-01 14:16:17 +010010435static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010436 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010437 .items = {
10438 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010439 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010440 { "CD", 0x4 },
10441 },
10442};
10443
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010444static struct hda_input_mux alc262_HP_capture_source = {
10445 .num_items = 5,
10446 .items = {
10447 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010448 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010449 { "Line", 0x2 },
10450 { "CD", 0x4 },
10451 { "AUX IN", 0x6 },
10452 },
10453};
10454
zhejiangaccbe492007-08-31 12:36:05 +020010455static struct hda_input_mux alc262_HP_D7000_capture_source = {
10456 .num_items = 4,
10457 .items = {
10458 { "Mic", 0x0 },
10459 { "Front Mic", 0x2 },
10460 { "Line", 0x1 },
10461 { "CD", 0x4 },
10462 },
10463};
10464
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010465/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010466static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10467{
10468 struct alc_spec *spec = codec->spec;
10469 unsigned int mute;
10470
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010471 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010472 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010473 /* need to execute and sync at first */
10474 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010475 /* check laptop HP jack */
10476 present = snd_hda_codec_read(codec, 0x14, 0,
10477 AC_VERB_GET_PIN_SENSE, 0);
10478 /* need to execute and sync at first */
10479 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10480 /* check docking HP jack */
10481 present |= snd_hda_codec_read(codec, 0x1b, 0,
10482 AC_VERB_GET_PIN_SENSE, 0);
10483 if (present & AC_PINSENSE_PRESENCE)
10484 spec->jack_present = 1;
10485 else
10486 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010487 spec->sense_updated = 1;
10488 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010489 /* unmute internal speaker only if both HPs are unplugged and
10490 * master switch is on
10491 */
10492 if (spec->jack_present)
10493 mute = HDA_AMP_MUTE;
10494 else
Takashi Iwai834be882006-03-01 14:16:17 +010010495 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010496 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10497 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010498}
10499
10500/* unsolicited event for HP jack sensing */
10501static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10502 unsigned int res)
10503{
10504 if ((res >> 26) != ALC_HP_EVENT)
10505 return;
10506 alc262_fujitsu_automute(codec, 1);
10507}
10508
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010509static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10510{
10511 alc262_fujitsu_automute(codec, 1);
10512}
10513
Takashi Iwai834be882006-03-01 14:16:17 +010010514/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010515static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10516 .ops = &snd_hda_bind_vol,
10517 .values = {
10518 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10519 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10520 0
10521 },
10522};
Takashi Iwai834be882006-03-01 14:16:17 +010010523
Jiang zhe0e31daf2008-03-20 12:12:39 +010010524/* mute/unmute internal speaker according to the hp jack and mute state */
10525static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10526{
10527 struct alc_spec *spec = codec->spec;
10528 unsigned int mute;
10529
10530 if (force || !spec->sense_updated) {
10531 unsigned int present_int_hp;
10532 /* need to execute and sync at first */
10533 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10534 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10535 AC_VERB_GET_PIN_SENSE, 0);
10536 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10537 spec->sense_updated = 1;
10538 }
10539 if (spec->jack_present) {
10540 /* mute internal speaker */
10541 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10542 HDA_AMP_MUTE, HDA_AMP_MUTE);
10543 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10544 HDA_AMP_MUTE, HDA_AMP_MUTE);
10545 } else {
10546 /* unmute internal speaker if necessary */
10547 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10548 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10549 HDA_AMP_MUTE, mute);
10550 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10551 HDA_AMP_MUTE, mute);
10552 }
10553}
10554
10555/* unsolicited event for HP jack sensing */
10556static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10557 unsigned int res)
10558{
10559 if ((res >> 26) != ALC_HP_EVENT)
10560 return;
10561 alc262_lenovo_3000_automute(codec, 1);
10562}
10563
Takashi Iwai8de56b72009-07-24 16:51:47 +020010564static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10565 int dir, int idx, long *valp)
10566{
10567 int i, change = 0;
10568
10569 for (i = 0; i < 2; i++, valp++)
10570 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10571 HDA_AMP_MUTE,
10572 *valp ? 0 : HDA_AMP_MUTE);
10573 return change;
10574}
10575
Takashi Iwai834be882006-03-01 14:16:17 +010010576/* bind hp and internal speaker mute (with plug check) */
10577static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10578 struct snd_ctl_elem_value *ucontrol)
10579{
10580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10581 long *valp = ucontrol->value.integer.value;
10582 int change;
10583
Takashi Iwai8de56b72009-07-24 16:51:47 +020010584 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10585 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010586 if (change)
10587 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010588 return change;
10589}
10590
10591static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010592 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010593 {
10594 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10595 .name = "Master Playback Switch",
10596 .info = snd_hda_mixer_amp_switch_info,
10597 .get = snd_hda_mixer_amp_switch_get,
10598 .put = alc262_fujitsu_master_sw_put,
10599 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10600 },
10601 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10602 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10603 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010606 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10607 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10608 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010609 { } /* end */
10610};
10611
Jiang zhe0e31daf2008-03-20 12:12:39 +010010612/* bind hp and internal speaker mute (with plug check) */
10613static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10614 struct snd_ctl_elem_value *ucontrol)
10615{
10616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10617 long *valp = ucontrol->value.integer.value;
10618 int change;
10619
Takashi Iwai8de56b72009-07-24 16:51:47 +020010620 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010621 if (change)
10622 alc262_lenovo_3000_automute(codec, 0);
10623 return change;
10624}
10625
10626static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10627 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10628 {
10629 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10630 .name = "Master Playback Switch",
10631 .info = snd_hda_mixer_amp_switch_info,
10632 .get = snd_hda_mixer_amp_switch_get,
10633 .put = alc262_lenovo_3000_master_sw_put,
10634 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10635 },
10636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10638 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10639 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10641 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10642 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10643 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10644 { } /* end */
10645};
10646
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010647static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10648 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010649 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10651 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10652 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10653 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10654 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10655 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10656 { } /* end */
10657};
10658
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010659/* additional init verbs for Benq laptops */
10660static struct hda_verb alc262_EAPD_verbs[] = {
10661 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10662 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10663 {}
10664};
10665
Kailang Yang83c34212007-07-05 11:43:05 +020010666static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10669
10670 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10671 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10672 {}
10673};
10674
Tobin Davisf651b502007-10-26 12:40:47 +020010675/* Samsung Q1 Ultra Vista model setup */
10676static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010677 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10678 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10681 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010682 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010683 { } /* end */
10684};
10685
10686static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010687 /* output mixer */
10688 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10689 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10690 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10691 /* speaker */
10692 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10693 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10695 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10696 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010698 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10699 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10700 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10701 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10702 /* internal mic */
10703 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10705 /* ADC, choose mic */
10706 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10707 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10708 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10709 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10710 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10712 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10713 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10714 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10715 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010716 {}
10717};
10718
Tobin Davisf651b502007-10-26 12:40:47 +020010719/* mute/unmute internal speaker according to the hp jack and mute state */
10720static void alc262_ultra_automute(struct hda_codec *codec)
10721{
10722 struct alc_spec *spec = codec->spec;
10723 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010724
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010725 mute = 0;
10726 /* auto-mute only when HP is used as HP */
10727 if (!spec->cur_mux[0]) {
10728 unsigned int present;
10729 /* need to execute and sync at first */
10730 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10731 present = snd_hda_codec_read(codec, 0x15, 0,
10732 AC_VERB_GET_PIN_SENSE, 0);
10733 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10734 if (spec->jack_present)
10735 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010736 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010737 /* mute/unmute internal speaker */
10738 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10739 HDA_AMP_MUTE, mute);
10740 /* mute/unmute HP */
10741 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10742 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010743}
10744
10745/* unsolicited event for HP jack sensing */
10746static void alc262_ultra_unsol_event(struct hda_codec *codec,
10747 unsigned int res)
10748{
10749 if ((res >> 26) != ALC880_HP_EVENT)
10750 return;
10751 alc262_ultra_automute(codec);
10752}
10753
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010754static struct hda_input_mux alc262_ultra_capture_source = {
10755 .num_items = 2,
10756 .items = {
10757 { "Mic", 0x1 },
10758 { "Headphone", 0x7 },
10759 },
10760};
10761
10762static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10763 struct snd_ctl_elem_value *ucontrol)
10764{
10765 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10766 struct alc_spec *spec = codec->spec;
10767 int ret;
10768
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010769 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010770 if (!ret)
10771 return 0;
10772 /* reprogram the HP pin as mic or HP according to the input source */
10773 snd_hda_codec_write_cache(codec, 0x15, 0,
10774 AC_VERB_SET_PIN_WIDGET_CONTROL,
10775 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10776 alc262_ultra_automute(codec); /* mute/unmute HP */
10777 return ret;
10778}
10779
10780static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10781 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10782 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10783 {
10784 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10785 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010786 .info = alc_mux_enum_info,
10787 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010788 .put = alc262_ultra_mux_enum_put,
10789 },
10790 { } /* end */
10791};
10792
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010793/* We use two mixers depending on the output pin; 0x16 is a mono output
10794 * and thus it's bound with a different mixer.
10795 * This function returns which mixer amp should be used.
10796 */
10797static int alc262_check_volbit(hda_nid_t nid)
10798{
10799 if (!nid)
10800 return 0;
10801 else if (nid == 0x16)
10802 return 2;
10803 else
10804 return 1;
10805}
10806
10807static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
10808 const char *pfx, int *vbits)
10809{
10810 char name[32];
10811 unsigned long val;
10812 int vbit;
10813
10814 vbit = alc262_check_volbit(nid);
10815 if (!vbit)
10816 return 0;
10817 if (*vbits & vbit) /* a volume control for this mixer already there */
10818 return 0;
10819 *vbits |= vbit;
10820 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
10821 if (vbit == 2)
10822 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
10823 else
10824 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
10825 return add_control(spec, ALC_CTL_WIDGET_VOL, name, val);
10826}
10827
10828static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
10829 const char *pfx)
10830{
10831 char name[32];
10832 unsigned long val;
10833
10834 if (!nid)
10835 return 0;
10836 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
10837 if (nid == 0x16)
10838 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
10839 else
10840 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
10841 return add_control(spec, ALC_CTL_WIDGET_MUTE, name, val);
10842}
10843
Kailang Yangdf694da2005-12-05 19:42:22 +010010844/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010845static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10846 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010847{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010848 const char *pfx;
10849 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010010850 int err;
10851
10852 spec->multiout.num_dacs = 1; /* only use one dac */
10853 spec->multiout.dac_nids = spec->private_dac_nids;
10854 spec->multiout.dac_nids[0] = 2;
10855
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010856 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
10857 pfx = "Master";
10858 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10859 pfx = "Speaker";
10860 else
10861 pfx = "Front";
10862 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
10863 if (err < 0)
10864 return err;
10865 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
10866 if (err < 0)
10867 return err;
10868 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
10869 if (err < 0)
10870 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010010871
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020010872 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
10873 alc262_check_volbit(cfg->speaker_pins[0]) |
10874 alc262_check_volbit(cfg->hp_pins[0]);
10875 if (vbits == 1 || vbits == 2)
10876 pfx = "Master"; /* only one mixer is used */
10877 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
10878 pfx = "Speaker";
10879 else
10880 pfx = "Front";
10881 vbits = 0;
10882 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
10883 if (err < 0)
10884 return err;
10885 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
10886 &vbits);
10887 if (err < 0)
10888 return err;
10889 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
10890 &vbits);
10891 if (err < 0)
10892 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010893 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010894}
10895
Takashi Iwai05f5f472009-08-25 13:10:18 +020010896#define alc262_auto_create_input_ctls \
10897 alc880_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010898
10899/*
10900 * generic initialization of ADC, input mixers and output mixers
10901 */
10902static struct hda_verb alc262_volume_init_verbs[] = {
10903 /*
10904 * Unmute ADC0-2 and set the default input to mic-in
10905 */
10906 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10907 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10908 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10909 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10910 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10911 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10912
Takashi Iwaicb53c622007-08-10 17:21:45 +020010913 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010914 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010915 * Note: PASD motherboards uses the Line In 2 as the input for
10916 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010917 */
10918 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010919 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10920 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10921 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010924
10925 /*
10926 * Set up output mixers (0x0c - 0x0f)
10927 */
10928 /* set vol=0 to output mixers */
10929 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10930 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10931 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010932
Kailang Yangdf694da2005-12-05 19:42:22 +010010933 /* set up input amps for analog loopback */
10934 /* Amp Indices: DAC = 0, mixer = 1 */
10935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10936 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10937 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10938 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10939 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10940 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10941
10942 /* FIXME: use matrix-type input source selection */
10943 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10944 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10948 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10949 /* Input mixer2 */
10950 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10951 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10952 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10953 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10954 /* Input mixer3 */
10955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10956 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10957 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10958 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10959
10960 { }
10961};
10962
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010963static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10964 /*
10965 * Unmute ADC0-2 and set the default input to mic-in
10966 */
10967 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10969 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10970 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10971 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10972 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10973
Takashi Iwaicb53c622007-08-10 17:21:45 +020010974 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010975 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010976 * Note: PASD motherboards uses the Line In 2 as the input for
10977 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010978 */
10979 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010980 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10981 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10982 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10983 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010987
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010988 /*
10989 * Set up output mixers (0x0c - 0x0e)
10990 */
10991 /* set vol=0 to output mixers */
10992 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10993 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10994 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10995
10996 /* set up input amps for analog loopback */
10997 /* Amp Indices: DAC = 0, mixer = 1 */
10998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10999 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11001 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11004
Takashi Iwaice875f02008-01-28 18:17:43 +010011005 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011006 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11007 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11008
11009 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11011
11012 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11014
11015 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11016 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11017 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11018 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11019 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11020
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011021 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011022 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11023 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011025 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11026 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11027
11028
11029 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011030 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11031 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11034 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11035 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11036 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11037 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011041 /* Input mixer2 */
11042 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011043 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11045 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11046 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11047 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11048 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11049 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011051 /* Input mixer3 */
11052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11054 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011061
Takashi Iwaice875f02008-01-28 18:17:43 +010011062 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11063
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011064 { }
11065};
11066
Kailang Yangcd7509a2007-01-26 18:33:17 +010011067static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11068 /*
11069 * Unmute ADC0-2 and set the default input to mic-in
11070 */
11071 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11072 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11073 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11075 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11076 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11077
Takashi Iwaicb53c622007-08-10 17:21:45 +020011078 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011079 * mixer widget
11080 * Note: PASD motherboards uses the Line In 2 as the input for front
11081 * panel mic (mic 2)
11082 */
11083 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11085 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11086 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11087 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11088 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011092 /*
11093 * Set up output mixers (0x0c - 0x0e)
11094 */
11095 /* set vol=0 to output mixers */
11096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11097 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11098 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11099
11100 /* set up input amps for analog loopback */
11101 /* Amp Indices: DAC = 0, mixer = 1 */
11102 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11104 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11107 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11108
11109
11110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11111 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11114 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11115 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11117
11118 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11119 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11120
11121 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11122 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11123
11124 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11125 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11126 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11128 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11129 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11130
11131 /* FIXME: use matrix-type input source selection */
11132 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11133 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11134 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11135 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11136 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11137 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11138 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11139 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11141 /* Input mixer2 */
11142 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11143 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11144 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11145 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11147 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11148 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11149 /* Input mixer3 */
11150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11155 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11157
Takashi Iwaice875f02008-01-28 18:17:43 +010011158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11159
Kailang Yangcd7509a2007-01-26 18:33:17 +010011160 { }
11161};
11162
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011163static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11164
11165 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11166 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11167 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11168
11169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11170 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11172 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11173
11174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11175 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11176 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11177 {}
11178};
11179
11180
Takashi Iwaicb53c622007-08-10 17:21:45 +020011181#ifdef CONFIG_SND_HDA_POWER_SAVE
11182#define alc262_loopbacks alc880_loopbacks
11183#endif
11184
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011185/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011186#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11187#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11188#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11189#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11190
11191/*
11192 * BIOS auto configuration
11193 */
11194static int alc262_parse_auto_config(struct hda_codec *codec)
11195{
11196 struct alc_spec *spec = codec->spec;
11197 int err;
11198 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11199
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011200 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11201 alc262_ignore);
11202 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011203 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011204 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011205 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011206 spec->multiout.max_channels = 2;
11207 spec->no_analog = 1;
11208 goto dig_only;
11209 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011210 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011211 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011212 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11213 if (err < 0)
11214 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011215 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011216 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011217 return err;
11218
11219 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11220
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011221 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011222 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011223 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011224 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011225 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011226 if (spec->autocfg.dig_in_pin)
11227 spec->dig_in_nid = ALC262_DIGIN_NID;
11228
Takashi Iwai603c4012008-07-30 15:01:44 +020011229 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011230 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011231
Takashi Iwaid88897e2008-10-31 15:01:37 +010011232 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011233 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011234 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011235
Takashi Iwai776e1842007-08-29 15:07:11 +020011236 err = alc_auto_add_mic_boost(codec);
11237 if (err < 0)
11238 return err;
11239
Takashi Iwai4a79ba342009-04-22 16:31:35 +020011240 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11241
Kailang Yangdf694da2005-12-05 19:42:22 +010011242 return 1;
11243}
11244
11245#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11246#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11247#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011248#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011249
11250
11251/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011252static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011253{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011254 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011255 alc262_auto_init_multi_out(codec);
11256 alc262_auto_init_hp_out(codec);
11257 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011258 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011259 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011260 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011261}
11262
11263/*
11264 * configuration and preset
11265 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011266static const char *alc262_models[ALC262_MODEL_LAST] = {
11267 [ALC262_BASIC] = "basic",
11268 [ALC262_HIPPO] = "hippo",
11269 [ALC262_HIPPO_1] = "hippo_1",
11270 [ALC262_FUJITSU] = "fujitsu",
11271 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011272 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011273 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011274 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011275 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011276 [ALC262_BENQ_T31] = "benq-t31",
11277 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011278 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011279 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011280 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011281 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011282 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011283 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011284 [ALC262_AUTO] = "auto",
11285};
11286
11287static struct snd_pci_quirk alc262_cfg_tbl[] = {
11288 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011289 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011290 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11291 ALC262_HP_BPC),
11292 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11293 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011294 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11295 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011296 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011297 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011298 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011299 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011300 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011301 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011302 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011303 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011304 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11305 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11306 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011307 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11308 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011309 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011310 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011311 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011312 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011313 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011314 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011315 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11316 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011317 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011318 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011319 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011320 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011321 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011322 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011323 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11324 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011325 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011326 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011327 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011328 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011329 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011330 {}
11331};
11332
11333static struct alc_config_preset alc262_presets[] = {
11334 [ALC262_BASIC] = {
11335 .mixers = { alc262_base_mixer },
11336 .init_verbs = { alc262_init_verbs },
11337 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11338 .dac_nids = alc262_dac_nids,
11339 .hp_nid = 0x03,
11340 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11341 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011342 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011343 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011344 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011345 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011346 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011347 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11348 .dac_nids = alc262_dac_nids,
11349 .hp_nid = 0x03,
11350 .dig_out_nid = ALC262_DIGOUT_NID,
11351 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11352 .channel_mode = alc262_modes,
11353 .input_mux = &alc262_capture_source,
11354 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011355 .setup = alc262_hippo_setup,
11356 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011357 },
11358 [ALC262_HIPPO_1] = {
11359 .mixers = { alc262_hippo1_mixer },
11360 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11361 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11362 .dac_nids = alc262_dac_nids,
11363 .hp_nid = 0x02,
11364 .dig_out_nid = ALC262_DIGOUT_NID,
11365 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11366 .channel_mode = alc262_modes,
11367 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011368 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011369 .setup = alc262_hippo1_setup,
11370 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011371 },
Takashi Iwai834be882006-03-01 14:16:17 +010011372 [ALC262_FUJITSU] = {
11373 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011374 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11375 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011376 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11377 .dac_nids = alc262_dac_nids,
11378 .hp_nid = 0x03,
11379 .dig_out_nid = ALC262_DIGOUT_NID,
11380 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11381 .channel_mode = alc262_modes,
11382 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011383 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011384 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011385 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011386 [ALC262_HP_BPC] = {
11387 .mixers = { alc262_HP_BPC_mixer },
11388 .init_verbs = { alc262_HP_BPC_init_verbs },
11389 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11390 .dac_nids = alc262_dac_nids,
11391 .hp_nid = 0x03,
11392 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11393 .channel_mode = alc262_modes,
11394 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011395 .unsol_event = alc262_hp_bpc_unsol_event,
11396 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011397 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011398 [ALC262_HP_BPC_D7000_WF] = {
11399 .mixers = { alc262_HP_BPC_WildWest_mixer },
11400 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11401 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11402 .dac_nids = alc262_dac_nids,
11403 .hp_nid = 0x03,
11404 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11405 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011406 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011407 .unsol_event = alc262_hp_wildwest_unsol_event,
11408 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011409 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011410 [ALC262_HP_BPC_D7000_WL] = {
11411 .mixers = { alc262_HP_BPC_WildWest_mixer,
11412 alc262_HP_BPC_WildWest_option_mixer },
11413 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11414 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11415 .dac_nids = alc262_dac_nids,
11416 .hp_nid = 0x03,
11417 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11418 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011419 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011420 .unsol_event = alc262_hp_wildwest_unsol_event,
11421 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011422 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011423 [ALC262_HP_TC_T5735] = {
11424 .mixers = { alc262_hp_t5735_mixer },
11425 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11426 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11427 .dac_nids = alc262_dac_nids,
11428 .hp_nid = 0x03,
11429 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11430 .channel_mode = alc262_modes,
11431 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011432 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011433 .setup = alc262_hp_t5735_setup,
11434 .init_hook = alc_automute_amp,
Kailang Yang8c427222008-01-10 13:03:59 +010011435 },
11436 [ALC262_HP_RP5700] = {
11437 .mixers = { alc262_hp_rp5700_mixer },
11438 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11439 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11440 .dac_nids = alc262_dac_nids,
11441 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11442 .channel_mode = alc262_modes,
11443 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011444 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011445 [ALC262_BENQ_ED8] = {
11446 .mixers = { alc262_base_mixer },
11447 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11448 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11449 .dac_nids = alc262_dac_nids,
11450 .hp_nid = 0x03,
11451 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11452 .channel_mode = alc262_modes,
11453 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011454 },
Kailang Yang272a5272007-05-14 11:00:38 +020011455 [ALC262_SONY_ASSAMD] = {
11456 .mixers = { alc262_sony_mixer },
11457 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11458 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11459 .dac_nids = alc262_dac_nids,
11460 .hp_nid = 0x02,
11461 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11462 .channel_mode = alc262_modes,
11463 .input_mux = &alc262_capture_source,
11464 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011465 .setup = alc262_hippo_setup,
11466 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020011467 },
11468 [ALC262_BENQ_T31] = {
11469 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011470 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11471 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011472 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11473 .dac_nids = alc262_dac_nids,
11474 .hp_nid = 0x03,
11475 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11476 .channel_mode = alc262_modes,
11477 .input_mux = &alc262_capture_source,
11478 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011479 .setup = alc262_hippo_setup,
11480 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020011481 },
Tobin Davisf651b502007-10-26 12:40:47 +020011482 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011483 .mixers = { alc262_ultra_mixer },
11484 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011485 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011486 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11487 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011488 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11489 .channel_mode = alc262_modes,
11490 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011491 .adc_nids = alc262_adc_nids, /* ADC0 */
11492 .capsrc_nids = alc262_capsrc_nids,
11493 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011494 .unsol_event = alc262_ultra_unsol_event,
11495 .init_hook = alc262_ultra_automute,
11496 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011497 [ALC262_LENOVO_3000] = {
11498 .mixers = { alc262_lenovo_3000_mixer },
11499 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11500 alc262_lenovo_3000_unsol_verbs },
11501 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11502 .dac_nids = alc262_dac_nids,
11503 .hp_nid = 0x03,
11504 .dig_out_nid = ALC262_DIGOUT_NID,
11505 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11506 .channel_mode = alc262_modes,
11507 .input_mux = &alc262_fujitsu_capture_source,
11508 .unsol_event = alc262_lenovo_3000_unsol_event,
11509 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011510 [ALC262_NEC] = {
11511 .mixers = { alc262_nec_mixer },
11512 .init_verbs = { alc262_nec_verbs },
11513 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11514 .dac_nids = alc262_dac_nids,
11515 .hp_nid = 0x03,
11516 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11517 .channel_mode = alc262_modes,
11518 .input_mux = &alc262_capture_source,
11519 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011520 [ALC262_TOSHIBA_S06] = {
11521 .mixers = { alc262_toshiba_s06_mixer },
11522 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11523 alc262_eapd_verbs },
11524 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11525 .capsrc_nids = alc262_dmic_capsrc_nids,
11526 .dac_nids = alc262_dac_nids,
11527 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011528 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011529 .dig_out_nid = ALC262_DIGOUT_NID,
11530 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11531 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011532 .unsol_event = alc_sku_unsol_event,
11533 .setup = alc262_toshiba_s06_setup,
11534 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020011535 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011536 [ALC262_TOSHIBA_RX1] = {
11537 .mixers = { alc262_toshiba_rx1_mixer },
11538 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11539 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11540 .dac_nids = alc262_dac_nids,
11541 .hp_nid = 0x03,
11542 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11543 .channel_mode = alc262_modes,
11544 .input_mux = &alc262_capture_source,
11545 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011546 .setup = alc262_hippo_setup,
11547 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011548 },
Tony Vroonba340e82009-02-02 19:01:30 +000011549 [ALC262_TYAN] = {
11550 .mixers = { alc262_tyan_mixer },
11551 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11552 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11553 .dac_nids = alc262_dac_nids,
11554 .hp_nid = 0x02,
11555 .dig_out_nid = ALC262_DIGOUT_NID,
11556 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11557 .channel_mode = alc262_modes,
11558 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011559 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011560 .setup = alc262_tyan_setup,
11561 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000011562 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011563};
11564
11565static int patch_alc262(struct hda_codec *codec)
11566{
11567 struct alc_spec *spec;
11568 int board_config;
11569 int err;
11570
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011571 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011572 if (spec == NULL)
11573 return -ENOMEM;
11574
11575 codec->spec = spec;
11576#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011577 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11578 * under-run
11579 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011580 {
11581 int tmp;
11582 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11583 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11584 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11585 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11586 }
11587#endif
11588
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011589 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11590
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011591 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11592 alc262_models,
11593 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011594
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011595 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011596 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11597 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011598 board_config = ALC262_AUTO;
11599 }
11600
11601 if (board_config == ALC262_AUTO) {
11602 /* automatic parse from the BIOS config */
11603 err = alc262_parse_auto_config(codec);
11604 if (err < 0) {
11605 alc_free(codec);
11606 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011607 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011608 printk(KERN_INFO
11609 "hda_codec: Cannot set up configuration "
11610 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011611 board_config = ALC262_BASIC;
11612 }
11613 }
11614
Takashi Iwai07eba612009-02-19 08:06:35 +010011615 if (!spec->no_analog) {
11616 err = snd_hda_attach_beep_device(codec, 0x1);
11617 if (err < 0) {
11618 alc_free(codec);
11619 return err;
11620 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011621 }
11622
Kailang Yangdf694da2005-12-05 19:42:22 +010011623 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011624 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011625
Kailang Yangdf694da2005-12-05 19:42:22 +010011626 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11627 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011628
Kailang Yangdf694da2005-12-05 19:42:22 +010011629 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11630 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11631
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011632 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011633 int i;
11634 /* check whether the digital-mic has to be supported */
11635 for (i = 0; i < spec->input_mux->num_items; i++) {
11636 if (spec->input_mux->items[i].index >= 9)
11637 break;
11638 }
11639 if (i < spec->input_mux->num_items) {
11640 /* use only ADC0 */
11641 spec->adc_nids = alc262_dmic_adc_nids;
11642 spec->num_adc_nids = 1;
11643 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011644 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011645 /* all analog inputs */
11646 /* check whether NID 0x07 is valid */
11647 unsigned int wcap = get_wcaps(codec, 0x07);
11648
11649 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011650 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011651 if (wcap != AC_WID_AUD_IN) {
11652 spec->adc_nids = alc262_adc_nids_alt;
11653 spec->num_adc_nids =
11654 ARRAY_SIZE(alc262_adc_nids_alt);
11655 spec->capsrc_nids = alc262_capsrc_nids_alt;
11656 } else {
11657 spec->adc_nids = alc262_adc_nids;
11658 spec->num_adc_nids =
11659 ARRAY_SIZE(alc262_adc_nids);
11660 spec->capsrc_nids = alc262_capsrc_nids;
11661 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011662 }
11663 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011664 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011665 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011666 if (!spec->no_analog)
11667 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011668
Takashi Iwai2134ea42008-01-10 16:53:55 +010011669 spec->vmaster_nid = 0x0c;
11670
Kailang Yangdf694da2005-12-05 19:42:22 +010011671 codec->patch_ops = alc_patch_ops;
11672 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011673 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011674#ifdef CONFIG_SND_HDA_POWER_SAVE
11675 if (!spec->loopback.amplist)
11676 spec->loopback.amplist = alc262_loopbacks;
11677#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011678 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011679
Kailang Yangdf694da2005-12-05 19:42:22 +010011680 return 0;
11681}
11682
Kailang Yangdf694da2005-12-05 19:42:22 +010011683/*
Kailang Yanga361d842007-06-05 12:30:55 +020011684 * ALC268 channel source setting (2 channel)
11685 */
11686#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11687#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011688
Kailang Yanga361d842007-06-05 12:30:55 +020011689static hda_nid_t alc268_dac_nids[2] = {
11690 /* front, hp */
11691 0x02, 0x03
11692};
11693
11694static hda_nid_t alc268_adc_nids[2] = {
11695 /* ADC0-1 */
11696 0x08, 0x07
11697};
11698
11699static hda_nid_t alc268_adc_nids_alt[1] = {
11700 /* ADC0 */
11701 0x08
11702};
11703
Takashi Iwaie1406342008-02-11 18:32:32 +010011704static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11705
Kailang Yanga361d842007-06-05 12:30:55 +020011706static struct snd_kcontrol_new alc268_base_mixer[] = {
11707 /* output mixer control */
11708 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11709 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11710 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11713 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11714 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011715 { }
11716};
11717
Takashi Iwai42171c12009-05-08 14:11:43 +020011718static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11719 /* output mixer control */
11720 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11721 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11722 ALC262_HIPPO_MASTER_SWITCH,
11723 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11724 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11725 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11726 { }
11727};
11728
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011729/* bind Beep switches of both NID 0x0f and 0x10 */
11730static struct hda_bind_ctls alc268_bind_beep_sw = {
11731 .ops = &snd_hda_bind_sw,
11732 .values = {
11733 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11734 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11735 0
11736 },
11737};
11738
11739static struct snd_kcontrol_new alc268_beep_mixer[] = {
11740 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11741 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11742 { }
11743};
11744
Kailang Yangd1a991a2007-08-15 16:21:59 +020011745static struct hda_verb alc268_eapd_verbs[] = {
11746 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11747 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11748 { }
11749};
11750
Takashi Iwaid2738092007-08-16 14:59:45 +020011751/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011752static struct hda_verb alc268_toshiba_verbs[] = {
11753 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11754 { } /* end */
11755};
11756
11757/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011758/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011759static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11760 .ops = &snd_hda_bind_vol,
11761 .values = {
11762 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11763 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11764 0
11765 },
11766};
11767
Takashi Iwai889c4392007-08-23 18:56:52 +020011768/* mute/unmute internal speaker according to the hp jack and mute state */
11769static void alc268_acer_automute(struct hda_codec *codec, int force)
11770{
11771 struct alc_spec *spec = codec->spec;
11772 unsigned int mute;
11773
11774 if (force || !spec->sense_updated) {
11775 unsigned int present;
11776 present = snd_hda_codec_read(codec, 0x14, 0,
11777 AC_VERB_GET_PIN_SENSE, 0);
11778 spec->jack_present = (present & 0x80000000) != 0;
11779 spec->sense_updated = 1;
11780 }
11781 if (spec->jack_present)
11782 mute = HDA_AMP_MUTE; /* mute internal speaker */
11783 else /* unmute internal speaker if necessary */
11784 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11785 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11786 HDA_AMP_MUTE, mute);
11787}
11788
11789
11790/* bind hp and internal speaker mute (with plug check) */
11791static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11792 struct snd_ctl_elem_value *ucontrol)
11793{
11794 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11795 long *valp = ucontrol->value.integer.value;
11796 int change;
11797
Takashi Iwai8de56b72009-07-24 16:51:47 +020011798 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011799 if (change)
11800 alc268_acer_automute(codec, 0);
11801 return change;
11802}
Takashi Iwaid2738092007-08-16 14:59:45 +020011803
Kailang Yang8ef355d2008-08-26 13:10:22 +020011804static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11805 /* output mixer control */
11806 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11807 {
11808 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11809 .name = "Master Playback Switch",
11810 .info = snd_hda_mixer_amp_switch_info,
11811 .get = snd_hda_mixer_amp_switch_get,
11812 .put = alc268_acer_master_sw_put,
11813 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11814 },
11815 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11816 { }
11817};
11818
Takashi Iwaid2738092007-08-16 14:59:45 +020011819static struct snd_kcontrol_new alc268_acer_mixer[] = {
11820 /* output mixer control */
11821 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11822 {
11823 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11824 .name = "Master Playback Switch",
11825 .info = snd_hda_mixer_amp_switch_info,
11826 .get = snd_hda_mixer_amp_switch_get,
11827 .put = alc268_acer_master_sw_put,
11828 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11829 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011830 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11831 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11832 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011833 { }
11834};
11835
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011836static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11837 /* output mixer control */
11838 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11839 {
11840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11841 .name = "Master Playback Switch",
11842 .info = snd_hda_mixer_amp_switch_info,
11843 .get = snd_hda_mixer_amp_switch_get,
11844 .put = alc268_acer_master_sw_put,
11845 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11846 },
11847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11848 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11849 { }
11850};
11851
Kailang Yang8ef355d2008-08-26 13:10:22 +020011852static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11853 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11855 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11856 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11857 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11858 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11859 { }
11860};
11861
Takashi Iwaid2738092007-08-16 14:59:45 +020011862static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11864 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011867 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11868 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011869 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11870 { }
11871};
11872
11873/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011874#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011875#define alc268_toshiba_setup alc262_hippo_setup
11876#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020011877
11878static void alc268_acer_unsol_event(struct hda_codec *codec,
11879 unsigned int res)
11880{
Takashi Iwai889c4392007-08-23 18:56:52 +020011881 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011882 return;
11883 alc268_acer_automute(codec, 1);
11884}
11885
Takashi Iwai889c4392007-08-23 18:56:52 +020011886static void alc268_acer_init_hook(struct hda_codec *codec)
11887{
11888 alc268_acer_automute(codec, 1);
11889}
11890
Kailang Yang8ef355d2008-08-26 13:10:22 +020011891/* toggle speaker-output according to the hp-jack state */
11892static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11893{
11894 unsigned int present;
11895 unsigned char bits;
11896
11897 present = snd_hda_codec_read(codec, 0x15, 0,
11898 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11899 bits = present ? AMP_IN_MUTE(0) : 0;
11900 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11901 AMP_IN_MUTE(0), bits);
11902 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11903 AMP_IN_MUTE(0), bits);
11904}
11905
Kailang Yang8ef355d2008-08-26 13:10:22 +020011906static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11907 unsigned int res)
11908{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011909 switch (res >> 26) {
11910 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020011911 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011912 break;
11913 case ALC880_MIC_EVENT:
11914 alc_mic_automute(codec);
11915 break;
11916 }
11917}
11918
11919static void alc268_acer_lc_setup(struct hda_codec *codec)
11920{
11921 struct alc_spec *spec = codec->spec;
11922 spec->ext_mic.pin = 0x18;
11923 spec->ext_mic.mux_idx = 0;
11924 spec->int_mic.pin = 0x12;
11925 spec->int_mic.mux_idx = 6;
11926 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020011927}
11928
11929static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11930{
11931 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011932 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020011933}
11934
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011935static struct snd_kcontrol_new alc268_dell_mixer[] = {
11936 /* output mixer control */
11937 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11938 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11939 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11940 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11941 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11942 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11943 { }
11944};
11945
11946static struct hda_verb alc268_dell_verbs[] = {
11947 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11949 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011950 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011951 { }
11952};
11953
11954/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011955static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011956{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011957 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011958
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011959 spec->autocfg.hp_pins[0] = 0x15;
11960 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011961 spec->ext_mic.pin = 0x18;
11962 spec->ext_mic.mux_idx = 0;
11963 spec->int_mic.pin = 0x19;
11964 spec->int_mic.mux_idx = 1;
11965 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011966}
11967
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011968static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11969 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11970 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11971 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11972 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11973 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11974 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11975 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11976 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11977 { }
11978};
11979
11980static struct hda_verb alc267_quanta_il1_verbs[] = {
11981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11982 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11983 { }
11984};
11985
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011986static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011987{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011988 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011989 spec->autocfg.hp_pins[0] = 0x15;
11990 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011991 spec->ext_mic.pin = 0x18;
11992 spec->ext_mic.mux_idx = 0;
11993 spec->int_mic.pin = 0x19;
11994 spec->int_mic.mux_idx = 1;
11995 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011996}
11997
Kailang Yanga361d842007-06-05 12:30:55 +020011998/*
11999 * generic initialization of ADC, input mixers and output mixers
12000 */
12001static struct hda_verb alc268_base_init_verbs[] = {
12002 /* Unmute DAC0-1 and set vol = 0 */
12003 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012004 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012005
12006 /*
12007 * Set up output mixers (0x0c - 0x0e)
12008 */
12009 /* set vol=0 to output mixers */
12010 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012011 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12012
12013 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12015
12016 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12017 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12018 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12019 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12020 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12022 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12023 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12024
12025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12027 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12028 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012029 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012030
12031 /* set PCBEEP vol = 0, mute connections */
12032 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12033 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12034 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012035
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012036 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012037
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012038 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12039 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12040 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012042
Kailang Yanga361d842007-06-05 12:30:55 +020012043 { }
12044};
12045
12046/*
12047 * generic initialization of ADC, input mixers and output mixers
12048 */
12049static struct hda_verb alc268_volume_init_verbs[] = {
12050 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012051 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12052 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012053
12054 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12055 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12056 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12057 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12058 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12059
Kailang Yanga361d842007-06-05 12:30:55 +020012060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12062 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12063
12064 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012065 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012066
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012067 /* set PCBEEP vol = 0, mute connections */
12068 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12069 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12070 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012071
12072 { }
12073};
12074
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012075static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12076 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12077 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12078 { } /* end */
12079};
12080
Kailang Yanga361d842007-06-05 12:30:55 +020012081static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12082 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12083 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012084 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012085 { } /* end */
12086};
12087
12088static struct snd_kcontrol_new alc268_capture_mixer[] = {
12089 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12090 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12091 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12092 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012093 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012094 { } /* end */
12095};
12096
12097static struct hda_input_mux alc268_capture_source = {
12098 .num_items = 4,
12099 .items = {
12100 { "Mic", 0x0 },
12101 { "Front Mic", 0x1 },
12102 { "Line", 0x2 },
12103 { "CD", 0x3 },
12104 },
12105};
12106
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012107static struct hda_input_mux alc268_acer_capture_source = {
12108 .num_items = 3,
12109 .items = {
12110 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012111 { "Internal Mic", 0x1 },
12112 { "Line", 0x2 },
12113 },
12114};
12115
12116static struct hda_input_mux alc268_acer_dmic_capture_source = {
12117 .num_items = 3,
12118 .items = {
12119 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012120 { "Internal Mic", 0x6 },
12121 { "Line", 0x2 },
12122 },
12123};
12124
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012125#ifdef CONFIG_SND_DEBUG
12126static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012127 /* Volume widgets */
12128 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12129 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12130 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12131 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12132 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12133 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12134 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12135 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12136 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12137 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12138 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12139 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12140 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012141 /* The below appears problematic on some hardwares */
12142 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012143 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12144 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12145 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12146 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12147
12148 /* Modes for retasking pin widgets */
12149 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12150 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12151 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12152 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12153
12154 /* Controls for GPIO pins, assuming they are configured as outputs */
12155 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12156 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12157 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12158 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12159
12160 /* Switches to allow the digital SPDIF output pin to be enabled.
12161 * The ALC268 does not have an SPDIF input.
12162 */
12163 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12164
12165 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12166 * this output to turn on an external amplifier.
12167 */
12168 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12169 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12170
12171 { } /* end */
12172};
12173#endif
12174
Kailang Yanga361d842007-06-05 12:30:55 +020012175/* create input playback/capture controls for the given pin */
12176static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12177 const char *ctlname, int idx)
12178{
12179 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012180 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012181 int err;
12182
12183 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012184 switch (nid) {
12185 case 0x14:
12186 case 0x16:
12187 dac = 0x02;
12188 break;
12189 case 0x15:
12190 dac = 0x03;
12191 break;
12192 default:
12193 return 0;
12194 }
12195 if (spec->multiout.dac_nids[0] != dac &&
12196 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012197 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012198 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012199 HDA_OUTPUT));
12200 if (err < 0)
12201 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012202 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12203 }
12204
Kailang Yanga361d842007-06-05 12:30:55 +020012205 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012206 if (nid != 0x16)
12207 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012208 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012209 else /* mono */
12210 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12211 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012212 if (err < 0)
12213 return err;
12214 return 0;
12215}
12216
12217/* add playback controls from the parsed DAC table */
12218static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12219 const struct auto_pin_cfg *cfg)
12220{
12221 hda_nid_t nid;
12222 int err;
12223
Kailang Yanga361d842007-06-05 12:30:55 +020012224 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012225
12226 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012227 if (nid) {
12228 const char *name;
12229 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12230 name = "Speaker";
12231 else
12232 name = "Front";
12233 err = alc268_new_analog_output(spec, nid, name, 0);
12234 if (err < 0)
12235 return err;
12236 }
Kailang Yanga361d842007-06-05 12:30:55 +020012237
12238 nid = cfg->speaker_pins[0];
12239 if (nid == 0x1d) {
12240 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12241 "Speaker Playback Volume",
12242 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12243 if (err < 0)
12244 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012245 } else {
12246 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12247 if (err < 0)
12248 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012249 }
12250 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012251 if (nid) {
12252 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12253 if (err < 0)
12254 return err;
12255 }
Kailang Yanga361d842007-06-05 12:30:55 +020012256
12257 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12258 if (nid == 0x16) {
12259 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12260 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012261 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012262 if (err < 0)
12263 return err;
12264 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012265 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012266}
12267
12268/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012269static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012270 const struct auto_pin_cfg *cfg)
12271{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012272 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012273}
12274
12275static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12276{
12277 struct alc_spec *spec = codec->spec;
12278 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12279 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12280 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12281 unsigned int dac_vol1, dac_vol2;
12282
12283 if (speaker_nid) {
12284 snd_hda_codec_write(codec, speaker_nid, 0,
12285 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12286 snd_hda_codec_write(codec, 0x0f, 0,
12287 AC_VERB_SET_AMP_GAIN_MUTE,
12288 AMP_IN_UNMUTE(1));
12289 snd_hda_codec_write(codec, 0x10, 0,
12290 AC_VERB_SET_AMP_GAIN_MUTE,
12291 AMP_IN_UNMUTE(1));
12292 } else {
12293 snd_hda_codec_write(codec, 0x0f, 0,
12294 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12295 snd_hda_codec_write(codec, 0x10, 0,
12296 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12297 }
12298
12299 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012300 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012301 dac_vol2 = AMP_OUT_ZERO;
12302 else if (line_nid == 0x15)
12303 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012304 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012305 dac_vol2 = AMP_OUT_ZERO;
12306 else if (hp_nid == 0x15)
12307 dac_vol1 = AMP_OUT_ZERO;
12308 if (line_nid != 0x16 || hp_nid != 0x16 ||
12309 spec->autocfg.line_out_pins[1] != 0x16 ||
12310 spec->autocfg.line_out_pins[2] != 0x16)
12311 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12312
12313 snd_hda_codec_write(codec, 0x02, 0,
12314 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12315 snd_hda_codec_write(codec, 0x03, 0,
12316 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12317}
12318
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012319/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012320#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12321#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012322#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012323#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12324
12325/*
12326 * BIOS auto configuration
12327 */
12328static int alc268_parse_auto_config(struct hda_codec *codec)
12329{
12330 struct alc_spec *spec = codec->spec;
12331 int err;
12332 static hda_nid_t alc268_ignore[] = { 0 };
12333
12334 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12335 alc268_ignore);
12336 if (err < 0)
12337 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012338 if (!spec->autocfg.line_outs) {
12339 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12340 spec->multiout.max_channels = 2;
12341 spec->no_analog = 1;
12342 goto dig_only;
12343 }
Kailang Yanga361d842007-06-05 12:30:55 +020012344 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012345 }
Kailang Yanga361d842007-06-05 12:30:55 +020012346 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12347 if (err < 0)
12348 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012349 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012350 if (err < 0)
12351 return err;
12352
12353 spec->multiout.max_channels = 2;
12354
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012355 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012356 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012357 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012358 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012359 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12360 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012361 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012362 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012363
Takashi Iwai892981f2009-03-02 08:04:35 +010012364 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012365 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012366
Takashi Iwaid88897e2008-10-31 15:01:37 +010012367 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012368 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012369 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012370
Takashi Iwai776e1842007-08-29 15:07:11 +020012371 err = alc_auto_add_mic_boost(codec);
12372 if (err < 0)
12373 return err;
12374
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012375 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12376
Kailang Yanga361d842007-06-05 12:30:55 +020012377 return 1;
12378}
12379
12380#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12381#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12382#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12383
12384/* init callback for auto-configuration model -- overriding the default init */
12385static void alc268_auto_init(struct hda_codec *codec)
12386{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012387 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012388 alc268_auto_init_multi_out(codec);
12389 alc268_auto_init_hp_out(codec);
12390 alc268_auto_init_mono_speaker_out(codec);
12391 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012392 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012393 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012394}
12395
12396/*
12397 * configuration and preset
12398 */
12399static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012400 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012401 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012402 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012403 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012404 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012405 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012406 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012407 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012408#ifdef CONFIG_SND_DEBUG
12409 [ALC268_TEST] = "test",
12410#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012411 [ALC268_AUTO] = "auto",
12412};
12413
12414static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012415 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012416 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012417 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012418 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012419 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012420 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12421 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012422 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012423 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012424 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12425 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012426 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012427 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012428 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012429 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012430 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012431 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012432 {}
12433};
12434
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012435/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12436static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12437 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12438 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12439 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12440 ALC268_TOSHIBA),
12441 {}
12442};
12443
Kailang Yanga361d842007-06-05 12:30:55 +020012444static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012445 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012446 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
12447 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012448 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12449 alc267_quanta_il1_verbs },
12450 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12451 .dac_nids = alc268_dac_nids,
12452 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12453 .adc_nids = alc268_adc_nids_alt,
12454 .hp_nid = 0x03,
12455 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12456 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012457 .unsol_event = alc_sku_unsol_event,
12458 .setup = alc267_quanta_il1_setup,
12459 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012460 },
Kailang Yanga361d842007-06-05 12:30:55 +020012461 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012462 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12463 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012464 .init_verbs = { alc268_base_init_verbs },
12465 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12466 .dac_nids = alc268_dac_nids,
12467 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12468 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012469 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012470 .hp_nid = 0x03,
12471 .dig_out_nid = ALC268_DIGOUT_NID,
12472 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12473 .channel_mode = alc268_modes,
12474 .input_mux = &alc268_capture_source,
12475 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012476 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012477 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012478 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012479 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12480 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012481 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12482 .dac_nids = alc268_dac_nids,
12483 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12484 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012485 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012486 .hp_nid = 0x03,
12487 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12488 .channel_mode = alc268_modes,
12489 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012490 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012491 .setup = alc268_toshiba_setup,
12492 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020012493 },
12494 [ALC268_ACER] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012495 .mixers = { alc268_acer_mixer, alc268_capture_nosrc_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012496 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012497 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12498 alc268_acer_verbs },
12499 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12500 .dac_nids = alc268_dac_nids,
12501 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12502 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012503 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012504 .hp_nid = 0x02,
12505 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12506 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012507 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012508 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012509 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012510 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012511 [ALC268_ACER_DMIC] = {
12512 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12513 alc268_beep_mixer },
12514 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12515 alc268_acer_verbs },
12516 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12517 .dac_nids = alc268_dac_nids,
12518 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12519 .adc_nids = alc268_adc_nids_alt,
12520 .capsrc_nids = alc268_capsrc_nids,
12521 .hp_nid = 0x02,
12522 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12523 .channel_mode = alc268_modes,
12524 .input_mux = &alc268_acer_dmic_capture_source,
12525 .unsol_event = alc268_acer_unsol_event,
12526 .init_hook = alc268_acer_init_hook,
12527 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012528 [ALC268_ACER_ASPIRE_ONE] = {
12529 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012530 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012531 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012532 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12533 alc268_acer_aspire_one_verbs },
12534 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12535 .dac_nids = alc268_dac_nids,
12536 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12537 .adc_nids = alc268_adc_nids_alt,
12538 .capsrc_nids = alc268_capsrc_nids,
12539 .hp_nid = 0x03,
12540 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12541 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012542 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012543 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012544 .init_hook = alc268_acer_lc_init_hook,
12545 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012546 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012547 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
12548 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012549 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12550 alc268_dell_verbs },
12551 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12552 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012553 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12554 .adc_nids = alc268_adc_nids_alt,
12555 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012556 .hp_nid = 0x02,
12557 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12558 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012559 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012560 .setup = alc268_dell_setup,
12561 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012562 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012563 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012564 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12565 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012566 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12567 alc268_toshiba_verbs },
12568 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12569 .dac_nids = alc268_dac_nids,
12570 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12571 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012572 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012573 .hp_nid = 0x03,
12574 .dig_out_nid = ALC268_DIGOUT_NID,
12575 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12576 .channel_mode = alc268_modes,
12577 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012578 .setup = alc268_toshiba_setup,
12579 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012580 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012581#ifdef CONFIG_SND_DEBUG
12582 [ALC268_TEST] = {
12583 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12584 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12585 alc268_volume_init_verbs },
12586 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12587 .dac_nids = alc268_dac_nids,
12588 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12589 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012590 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012591 .hp_nid = 0x03,
12592 .dig_out_nid = ALC268_DIGOUT_NID,
12593 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12594 .channel_mode = alc268_modes,
12595 .input_mux = &alc268_capture_source,
12596 },
12597#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012598};
12599
12600static int patch_alc268(struct hda_codec *codec)
12601{
12602 struct alc_spec *spec;
12603 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012604 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012605
12606 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12607 if (spec == NULL)
12608 return -ENOMEM;
12609
12610 codec->spec = spec;
12611
12612 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12613 alc268_models,
12614 alc268_cfg_tbl);
12615
Takashi Iwai3abf2f32009-08-19 20:05:02 +020012616 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12617 board_config = snd_hda_check_board_codec_sid_config(codec,
12618 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12619
Kailang Yanga361d842007-06-05 12:30:55 +020012620 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012621 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12622 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012623 board_config = ALC268_AUTO;
12624 }
12625
12626 if (board_config == ALC268_AUTO) {
12627 /* automatic parse from the BIOS config */
12628 err = alc268_parse_auto_config(codec);
12629 if (err < 0) {
12630 alc_free(codec);
12631 return err;
12632 } else if (!err) {
12633 printk(KERN_INFO
12634 "hda_codec: Cannot set up configuration "
12635 "from BIOS. Using base mode...\n");
12636 board_config = ALC268_3ST;
12637 }
12638 }
12639
12640 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012641 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012642
Kailang Yanga361d842007-06-05 12:30:55 +020012643 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12644 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012645 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012646
Kailang Yanga361d842007-06-05 12:30:55 +020012647 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12648
Takashi Iwai22971e32009-02-10 11:56:44 +010012649 has_beep = 0;
12650 for (i = 0; i < spec->num_mixers; i++) {
12651 if (spec->mixers[i] == alc268_beep_mixer) {
12652 has_beep = 1;
12653 break;
12654 }
12655 }
12656
12657 if (has_beep) {
12658 err = snd_hda_attach_beep_device(codec, 0x1);
12659 if (err < 0) {
12660 alc_free(codec);
12661 return err;
12662 }
12663 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12664 /* override the amp caps for beep generator */
12665 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012666 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12667 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12668 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12669 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012670 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012671
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012672 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012673 /* check whether NID 0x07 is valid */
12674 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012675 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012676
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012677 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012678 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012679 if (spec->auto_mic ||
12680 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012681 spec->adc_nids = alc268_adc_nids_alt;
12682 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012683 if (spec->auto_mic || spec->input_mux->num_items == 1)
12684 add_mixer(spec, alc268_capture_nosrc_mixer);
12685 else
12686 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012687 } else {
12688 spec->adc_nids = alc268_adc_nids;
12689 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012690 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012691 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012692 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012693 /* set default input source */
12694 for (i = 0; i < spec->num_adc_nids; i++)
12695 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12696 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012697 i < spec->num_mux_defs ?
12698 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010012699 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012700 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012701
12702 spec->vmaster_nid = 0x02;
12703
Kailang Yanga361d842007-06-05 12:30:55 +020012704 codec->patch_ops = alc_patch_ops;
12705 if (board_config == ALC268_AUTO)
12706 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012707
Takashi Iwaidaead532008-11-28 12:55:36 +010012708 codec->proc_widget_hook = print_realtek_coef;
12709
Kailang Yanga361d842007-06-05 12:30:55 +020012710 return 0;
12711}
12712
12713/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012714 * ALC269 channel source setting (2 channel)
12715 */
12716#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12717
12718#define alc269_dac_nids alc260_dac_nids
12719
12720static hda_nid_t alc269_adc_nids[1] = {
12721 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012722 0x08,
12723};
12724
Takashi Iwaie01bf502008-08-21 16:25:07 +020012725static hda_nid_t alc269_capsrc_nids[1] = {
12726 0x23,
12727};
12728
12729/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12730 * not a mux!
12731 */
12732
Kailang Yangf6a92242007-12-13 16:52:54 +010012733#define alc269_modes alc260_modes
12734#define alc269_capture_source alc880_lg_lw_capture_source
12735
12736static struct snd_kcontrol_new alc269_base_mixer[] = {
12737 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12738 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12739 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12740 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12744 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12745 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12746 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12748 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12749 { } /* end */
12750};
12751
Kailang Yang60db6b52008-08-26 13:13:00 +020012752static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12753 /* output mixer control */
12754 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12755 {
12756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12757 .name = "Master Playback Switch",
12758 .info = snd_hda_mixer_amp_switch_info,
12759 .get = snd_hda_mixer_amp_switch_get,
12760 .put = alc268_acer_master_sw_put,
12761 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12762 },
12763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12765 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12766 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12767 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12768 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012769 { }
12770};
12771
Tony Vroon64154832008-11-06 15:08:49 +000012772static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12773 /* output mixer control */
12774 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12775 {
12776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12777 .name = "Master Playback Switch",
12778 .info = snd_hda_mixer_amp_switch_info,
12779 .get = snd_hda_mixer_amp_switch_get,
12780 .put = alc268_acer_master_sw_put,
12781 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12782 },
12783 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12786 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12787 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12788 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12789 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12790 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12791 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012792 { }
12793};
12794
Kailang Yangf53281e2008-07-18 12:36:43 +020012795static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012796 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012797 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012799 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012800 { } /* end */
12801};
12802
Kailang Yangf6a92242007-12-13 16:52:54 +010012803/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012804static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12805 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12806 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12808 { } /* end */
12809};
12810
12811/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012812#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012813
Kailang Yang60db6b52008-08-26 13:13:00 +020012814static struct hda_verb alc269_quanta_fl1_verbs[] = {
12815 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12816 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12818 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12819 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12820 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12821 { }
12822};
12823
Tony Vroon64154832008-11-06 15:08:49 +000012824static struct hda_verb alc269_lifebook_verbs[] = {
12825 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12826 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12827 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12828 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12829 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12831 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12832 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12833 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12834 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12835 { }
12836};
12837
Kailang Yang60db6b52008-08-26 13:13:00 +020012838/* toggle speaker-output according to the hp-jack state */
12839static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12840{
12841 unsigned int present;
12842 unsigned char bits;
12843
12844 present = snd_hda_codec_read(codec, 0x15, 0,
12845 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12846 bits = present ? AMP_IN_MUTE(0) : 0;
12847 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12848 AMP_IN_MUTE(0), bits);
12849 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12850 AMP_IN_MUTE(0), bits);
12851
12852 snd_hda_codec_write(codec, 0x20, 0,
12853 AC_VERB_SET_COEF_INDEX, 0x0c);
12854 snd_hda_codec_write(codec, 0x20, 0,
12855 AC_VERB_SET_PROC_COEF, 0x680);
12856
12857 snd_hda_codec_write(codec, 0x20, 0,
12858 AC_VERB_SET_COEF_INDEX, 0x0c);
12859 snd_hda_codec_write(codec, 0x20, 0,
12860 AC_VERB_SET_PROC_COEF, 0x480);
12861}
12862
Tony Vroon64154832008-11-06 15:08:49 +000012863/* toggle speaker-output according to the hp-jacks state */
12864static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12865{
12866 unsigned int present;
12867 unsigned char bits;
12868
12869 /* Check laptop headphone socket */
12870 present = snd_hda_codec_read(codec, 0x15, 0,
12871 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12872
12873 /* Check port replicator headphone socket */
12874 present |= snd_hda_codec_read(codec, 0x1a, 0,
12875 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12876
12877 bits = present ? AMP_IN_MUTE(0) : 0;
12878 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12879 AMP_IN_MUTE(0), bits);
12880 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12881 AMP_IN_MUTE(0), bits);
12882
12883 snd_hda_codec_write(codec, 0x20, 0,
12884 AC_VERB_SET_COEF_INDEX, 0x0c);
12885 snd_hda_codec_write(codec, 0x20, 0,
12886 AC_VERB_SET_PROC_COEF, 0x680);
12887
12888 snd_hda_codec_write(codec, 0x20, 0,
12889 AC_VERB_SET_COEF_INDEX, 0x0c);
12890 snd_hda_codec_write(codec, 0x20, 0,
12891 AC_VERB_SET_PROC_COEF, 0x480);
12892}
12893
Tony Vroon64154832008-11-06 15:08:49 +000012894static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12895{
12896 unsigned int present_laptop;
12897 unsigned int present_dock;
12898
12899 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12900 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12901
12902 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12903 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12904
12905 /* Laptop mic port overrides dock mic port, design decision */
12906 if (present_dock)
12907 snd_hda_codec_write(codec, 0x23, 0,
12908 AC_VERB_SET_CONNECT_SEL, 0x3);
12909 if (present_laptop)
12910 snd_hda_codec_write(codec, 0x23, 0,
12911 AC_VERB_SET_CONNECT_SEL, 0x0);
12912 if (!present_dock && !present_laptop)
12913 snd_hda_codec_write(codec, 0x23, 0,
12914 AC_VERB_SET_CONNECT_SEL, 0x1);
12915}
12916
Kailang Yang60db6b52008-08-26 13:13:00 +020012917static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12918 unsigned int res)
12919{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012920 switch (res >> 26) {
12921 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020012922 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012923 break;
12924 case ALC880_MIC_EVENT:
12925 alc_mic_automute(codec);
12926 break;
12927 }
Kailang Yang60db6b52008-08-26 13:13:00 +020012928}
12929
Tony Vroon64154832008-11-06 15:08:49 +000012930static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12931 unsigned int res)
12932{
12933 if ((res >> 26) == ALC880_HP_EVENT)
12934 alc269_lifebook_speaker_automute(codec);
12935 if ((res >> 26) == ALC880_MIC_EVENT)
12936 alc269_lifebook_mic_autoswitch(codec);
12937}
12938
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012939static void alc269_quanta_fl1_setup(struct hda_codec *codec)
12940{
12941 struct alc_spec *spec = codec->spec;
12942 spec->ext_mic.pin = 0x18;
12943 spec->ext_mic.mux_idx = 0;
12944 spec->int_mic.pin = 0x19;
12945 spec->int_mic.mux_idx = 1;
12946 spec->auto_mic = 1;
12947}
12948
Kailang Yang60db6b52008-08-26 13:13:00 +020012949static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12950{
12951 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012952 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020012953}
12954
Tony Vroon64154832008-11-06 15:08:49 +000012955static void alc269_lifebook_init_hook(struct hda_codec *codec)
12956{
12957 alc269_lifebook_speaker_automute(codec);
12958 alc269_lifebook_mic_autoswitch(codec);
12959}
12960
Kailang Yang60db6b52008-08-26 13:13:00 +020012961static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12962 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12963 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12964 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12966 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12967 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12969 {}
12970};
12971
12972static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12974 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12975 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12976 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12977 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12978 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12979 {}
12980};
12981
12982/* toggle speaker-output according to the hp-jack state */
12983static void alc269_speaker_automute(struct hda_codec *codec)
12984{
12985 unsigned int present;
12986 unsigned char bits;
12987
12988 present = snd_hda_codec_read(codec, 0x15, 0,
12989 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12990 bits = present ? AMP_IN_MUTE(0) : 0;
12991 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12992 AMP_IN_MUTE(0), bits);
12993 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12994 AMP_IN_MUTE(0), bits);
12995}
12996
Kailang Yang60db6b52008-08-26 13:13:00 +020012997/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012998static void alc269_eeepc_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020012999 unsigned int res)
13000{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013001 switch (res >> 26) {
13002 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013003 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013004 break;
13005 case ALC880_MIC_EVENT:
13006 alc_mic_automute(codec);
13007 break;
13008 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013009}
13010
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013011static void alc269_eeepc_dmic_setup(struct hda_codec *codec)
13012{
13013 struct alc_spec *spec = codec->spec;
13014 spec->ext_mic.pin = 0x18;
13015 spec->ext_mic.mux_idx = 0;
13016 spec->int_mic.pin = 0x12;
13017 spec->int_mic.mux_idx = 5;
13018 spec->auto_mic = 1;
13019}
13020
13021static void alc269_eeepc_amic_setup(struct hda_codec *codec)
13022{
13023 struct alc_spec *spec = codec->spec;
13024 spec->ext_mic.pin = 0x18;
13025 spec->ext_mic.mux_idx = 0;
13026 spec->int_mic.pin = 0x19;
13027 spec->int_mic.mux_idx = 1;
13028 spec->auto_mic = 1;
13029}
13030
13031static void alc269_eeepc_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013032{
13033 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013034 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013035}
13036
Kailang Yangf6a92242007-12-13 16:52:54 +010013037/*
13038 * generic initialization of ADC, input mixers and output mixers
13039 */
13040static struct hda_verb alc269_init_verbs[] = {
13041 /*
13042 * Unmute ADC0 and set the default input to mic-in
13043 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013044 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013045
13046 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13047 * analog-loopback mixer widget
13048 * Note: PASD motherboards uses the Line In 2 as the input for
13049 * front panel mic (mic 2)
13050 */
13051 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13057
13058 /*
13059 * Set up output mixers (0x0c - 0x0e)
13060 */
13061 /* set vol=0 to output mixers */
13062 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13064
13065 /* set up input amps for analog loopback */
13066 /* Amp Indices: DAC = 0, mixer = 1 */
13067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13073
13074 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13075 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13076 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13078 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13079 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13080 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13081
13082 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13083 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13086 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13089
13090 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13091 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13092
13093 /* FIXME: use matrix-type input source selection */
13094 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13095 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013098 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13100
13101 /* set EAPD */
13102 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13103 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13104 { }
13105};
13106
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013107#define alc269_auto_create_multi_out_ctls \
13108 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013109#define alc269_auto_create_input_ctls \
13110 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013111
13112#ifdef CONFIG_SND_HDA_POWER_SAVE
13113#define alc269_loopbacks alc880_loopbacks
13114#endif
13115
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013116/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013117#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13118#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13119#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13120#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13121
Takashi Iwaif03d3112009-03-05 14:18:16 +010013122static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13123 .substreams = 1,
13124 .channels_min = 2,
13125 .channels_max = 8,
13126 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13127 /* NID is set in alc_build_pcms */
13128 .ops = {
13129 .open = alc880_playback_pcm_open,
13130 .prepare = alc880_playback_pcm_prepare,
13131 .cleanup = alc880_playback_pcm_cleanup
13132 },
13133};
13134
13135static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13136 .substreams = 1,
13137 .channels_min = 2,
13138 .channels_max = 2,
13139 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13140 /* NID is set in alc_build_pcms */
13141};
13142
Kailang Yangf6a92242007-12-13 16:52:54 +010013143/*
13144 * BIOS auto configuration
13145 */
13146static int alc269_parse_auto_config(struct hda_codec *codec)
13147{
13148 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013149 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013150 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13151
13152 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13153 alc269_ignore);
13154 if (err < 0)
13155 return err;
13156
13157 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13158 if (err < 0)
13159 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013160 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013161 if (err < 0)
13162 return err;
13163
13164 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13165
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013166 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013167 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13168
Takashi Iwai603c4012008-07-30 15:01:44 +020013169 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013170 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013171
Takashi Iwaid88897e2008-10-31 15:01:37 +010013172 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013173 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013174 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013175 /* set default input source */
13176 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13177 0, AC_VERB_SET_CONNECT_SEL,
13178 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013179
13180 err = alc_auto_add_mic_boost(codec);
13181 if (err < 0)
13182 return err;
13183
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013184 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013185 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013186
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013187 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13188
Kailang Yangf6a92242007-12-13 16:52:54 +010013189 return 1;
13190}
13191
13192#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13193#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13194#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13195
13196
13197/* init callback for auto-configuration model -- overriding the default init */
13198static void alc269_auto_init(struct hda_codec *codec)
13199{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013200 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013201 alc269_auto_init_multi_out(codec);
13202 alc269_auto_init_hp_out(codec);
13203 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013204 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013205 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013206}
13207
13208/*
13209 * configuration and preset
13210 */
13211static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013212 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013213 [ALC269_QUANTA_FL1] = "quanta",
13214 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013215 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013216 [ALC269_FUJITSU] = "fujitsu",
13217 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013218};
13219
13220static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013221 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013222 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13223 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013224 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13225 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13226 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13227 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13228 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13229 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013230 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13231 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013232 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13233 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013234 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013235 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013236 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013237 {}
13238};
13239
13240static struct alc_config_preset alc269_presets[] = {
13241 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013242 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013243 .init_verbs = { alc269_init_verbs },
13244 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13245 .dac_nids = alc269_dac_nids,
13246 .hp_nid = 0x03,
13247 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13248 .channel_mode = alc269_modes,
13249 .input_mux = &alc269_capture_source,
13250 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013251 [ALC269_QUANTA_FL1] = {
13252 .mixers = { alc269_quanta_fl1_mixer },
13253 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13254 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13255 .dac_nids = alc269_dac_nids,
13256 .hp_nid = 0x03,
13257 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13258 .channel_mode = alc269_modes,
13259 .input_mux = &alc269_capture_source,
13260 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013261 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013262 .init_hook = alc269_quanta_fl1_init_hook,
13263 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013264 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013265 .mixers = { alc269_eeepc_mixer },
13266 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013267 .init_verbs = { alc269_init_verbs,
13268 alc269_eeepc_amic_init_verbs },
13269 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13270 .dac_nids = alc269_dac_nids,
13271 .hp_nid = 0x03,
13272 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13273 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013274 .unsol_event = alc269_eeepc_unsol_event,
13275 .setup = alc269_eeepc_amic_setup,
13276 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013277 },
13278 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013279 .mixers = { alc269_eeepc_mixer },
13280 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013281 .init_verbs = { alc269_init_verbs,
13282 alc269_eeepc_dmic_init_verbs },
13283 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13284 .dac_nids = alc269_dac_nids,
13285 .hp_nid = 0x03,
13286 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13287 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013288 .unsol_event = alc269_eeepc_unsol_event,
13289 .setup = alc269_eeepc_dmic_setup,
13290 .init_hook = alc269_eeepc_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020013291 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013292 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013293 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013294 .cap_mixer = alc269_epc_capture_mixer,
13295 .init_verbs = { alc269_init_verbs,
13296 alc269_eeepc_dmic_init_verbs },
13297 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13298 .dac_nids = alc269_dac_nids,
13299 .hp_nid = 0x03,
13300 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13301 .channel_mode = alc269_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013302 .unsol_event = alc269_eeepc_unsol_event,
13303 .setup = alc269_eeepc_dmic_setup,
13304 .init_hook = alc269_eeepc_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010013305 },
Tony Vroon64154832008-11-06 15:08:49 +000013306 [ALC269_LIFEBOOK] = {
13307 .mixers = { alc269_lifebook_mixer },
13308 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13309 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13310 .dac_nids = alc269_dac_nids,
13311 .hp_nid = 0x03,
13312 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13313 .channel_mode = alc269_modes,
13314 .input_mux = &alc269_capture_source,
13315 .unsol_event = alc269_lifebook_unsol_event,
13316 .init_hook = alc269_lifebook_init_hook,
13317 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013318};
13319
13320static int patch_alc269(struct hda_codec *codec)
13321{
13322 struct alc_spec *spec;
13323 int board_config;
13324 int err;
13325
13326 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13327 if (spec == NULL)
13328 return -ENOMEM;
13329
13330 codec->spec = spec;
13331
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013332 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13333
Kailang Yangf6a92242007-12-13 16:52:54 +010013334 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13335 alc269_models,
13336 alc269_cfg_tbl);
13337
13338 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013339 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13340 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013341 board_config = ALC269_AUTO;
13342 }
13343
13344 if (board_config == ALC269_AUTO) {
13345 /* automatic parse from the BIOS config */
13346 err = alc269_parse_auto_config(codec);
13347 if (err < 0) {
13348 alc_free(codec);
13349 return err;
13350 } else if (!err) {
13351 printk(KERN_INFO
13352 "hda_codec: Cannot set up configuration "
13353 "from BIOS. Using base mode...\n");
13354 board_config = ALC269_BASIC;
13355 }
13356 }
13357
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013358 err = snd_hda_attach_beep_device(codec, 0x1);
13359 if (err < 0) {
13360 alc_free(codec);
13361 return err;
13362 }
13363
Kailang Yangf6a92242007-12-13 16:52:54 +010013364 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013365 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013366
Takashi Iwaif03d3112009-03-05 14:18:16 +010013367 if (codec->subsystem_id == 0x17aa3bf8) {
13368 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13369 * fix the sample rate of analog I/O to 44.1kHz
13370 */
13371 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13372 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13373 } else {
13374 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13375 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13376 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013377 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13378 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13379
13380 spec->adc_nids = alc269_adc_nids;
13381 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013382 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013383 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013384 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013385 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013386
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013387 spec->vmaster_nid = 0x02;
13388
Kailang Yangf6a92242007-12-13 16:52:54 +010013389 codec->patch_ops = alc_patch_ops;
13390 if (board_config == ALC269_AUTO)
13391 spec->init_hook = alc269_auto_init;
13392#ifdef CONFIG_SND_HDA_POWER_SAVE
13393 if (!spec->loopback.amplist)
13394 spec->loopback.amplist = alc269_loopbacks;
13395#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013396 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013397
13398 return 0;
13399}
13400
13401/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013402 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13403 */
13404
13405/*
13406 * set the path ways for 2 channel output
13407 * need to set the codec line out and mic 1 pin widgets to inputs
13408 */
13409static struct hda_verb alc861_threestack_ch2_init[] = {
13410 /* set pin widget 1Ah (line in) for input */
13411 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013412 /* set pin widget 18h (mic1/2) for input, for mic also enable
13413 * the vref
13414 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013415 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13416
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013417 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13418#if 0
13419 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13420 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13421#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013422 { } /* end */
13423};
13424/*
13425 * 6ch mode
13426 * need to set the codec line out and mic 1 pin widgets to outputs
13427 */
13428static struct hda_verb alc861_threestack_ch6_init[] = {
13429 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13430 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13431 /* set pin widget 18h (mic1) for output (CLFE)*/
13432 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13433
13434 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013435 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013436
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013437 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13438#if 0
13439 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13440 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13441#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013442 { } /* end */
13443};
13444
13445static struct hda_channel_mode alc861_threestack_modes[2] = {
13446 { 2, alc861_threestack_ch2_init },
13447 { 6, alc861_threestack_ch6_init },
13448};
Takashi Iwai22309c32006-08-09 16:57:28 +020013449/* Set mic1 as input and unmute the mixer */
13450static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13451 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13452 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13453 { } /* end */
13454};
13455/* Set mic1 as output and mute mixer */
13456static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13457 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13458 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13459 { } /* end */
13460};
13461
13462static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13463 { 2, alc861_uniwill_m31_ch2_init },
13464 { 4, alc861_uniwill_m31_ch4_init },
13465};
Kailang Yangdf694da2005-12-05 19:42:22 +010013466
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013467/* Set mic1 and line-in as input and unmute the mixer */
13468static struct hda_verb alc861_asus_ch2_init[] = {
13469 /* set pin widget 1Ah (line in) for input */
13470 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013471 /* set pin widget 18h (mic1/2) for input, for mic also enable
13472 * the vref
13473 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013474 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13475
13476 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13477#if 0
13478 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13479 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13480#endif
13481 { } /* end */
13482};
13483/* Set mic1 nad line-in as output and mute mixer */
13484static struct hda_verb alc861_asus_ch6_init[] = {
13485 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13486 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13487 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13488 /* set pin widget 18h (mic1) for output (CLFE)*/
13489 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13490 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13491 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13492 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13493
13494 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13495#if 0
13496 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13497 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13498#endif
13499 { } /* end */
13500};
13501
13502static struct hda_channel_mode alc861_asus_modes[2] = {
13503 { 2, alc861_asus_ch2_init },
13504 { 6, alc861_asus_ch6_init },
13505};
13506
Kailang Yangdf694da2005-12-05 19:42:22 +010013507/* patch-ALC861 */
13508
13509static struct snd_kcontrol_new alc861_base_mixer[] = {
13510 /* output mixer control */
13511 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13512 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13513 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13514 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13515 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13516
13517 /*Input mixer control */
13518 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13519 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13520 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13521 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13522 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13523 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13524 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13525 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13526 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13527 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013528
Kailang Yangdf694da2005-12-05 19:42:22 +010013529 { } /* end */
13530};
13531
13532static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13533 /* output mixer control */
13534 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13535 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13536 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13537 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13538 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13539
13540 /* Input mixer control */
13541 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13542 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13543 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13544 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13545 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13546 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13547 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13548 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13549 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013551
Kailang Yangdf694da2005-12-05 19:42:22 +010013552 {
13553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13554 .name = "Channel Mode",
13555 .info = alc_ch_mode_info,
13556 .get = alc_ch_mode_get,
13557 .put = alc_ch_mode_put,
13558 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13559 },
13560 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013561};
13562
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013563static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013564 /* output mixer control */
13565 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13567 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013568
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013569 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013570};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013571
Takashi Iwai22309c32006-08-09 16:57:28 +020013572static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13573 /* output mixer control */
13574 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13575 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13576 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13577 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13578 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13579
13580 /* Input mixer control */
13581 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13582 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13583 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13584 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13585 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13586 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13588 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13589 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013591
Takashi Iwai22309c32006-08-09 16:57:28 +020013592 {
13593 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13594 .name = "Channel Mode",
13595 .info = alc_ch_mode_info,
13596 .get = alc_ch_mode_get,
13597 .put = alc_ch_mode_put,
13598 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13599 },
13600 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013601};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013602
13603static struct snd_kcontrol_new alc861_asus_mixer[] = {
13604 /* output mixer control */
13605 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13606 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13607 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13608 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13609 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13610
13611 /* Input mixer control */
13612 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13613 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13614 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13615 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13616 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13617 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13619 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013621 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13622
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013623 {
13624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13625 .name = "Channel Mode",
13626 .info = alc_ch_mode_info,
13627 .get = alc_ch_mode_get,
13628 .put = alc_ch_mode_put,
13629 .private_value = ARRAY_SIZE(alc861_asus_modes),
13630 },
13631 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013632};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013633
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013634/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013635static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013636 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13637 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013638 { }
13639};
13640
Kailang Yangdf694da2005-12-05 19:42:22 +010013641/*
13642 * generic initialization of ADC, input mixers and output mixers
13643 */
13644static struct hda_verb alc861_base_init_verbs[] = {
13645 /*
13646 * Unmute ADC0 and set the default input to mic-in
13647 */
13648 /* port-A for surround (rear panel) */
13649 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13650 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13651 /* port-B for mic-in (rear panel) with vref */
13652 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13653 /* port-C for line-in (rear panel) */
13654 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13655 /* port-D for Front */
13656 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13657 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13658 /* port-E for HP out (front panel) */
13659 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13660 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013661 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013662 /* port-F for mic-in (front panel) with vref */
13663 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13664 /* port-G for CLFE (rear panel) */
13665 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13666 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13667 /* port-H for side (rear panel) */
13668 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13669 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13670 /* CD-in */
13671 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13672 /* route front mic to ADC1*/
13673 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13674 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013675
Kailang Yangdf694da2005-12-05 19:42:22 +010013676 /* Unmute DAC0~3 & spdif out*/
13677 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13678 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13679 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13680 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013682
Kailang Yangdf694da2005-12-05 19:42:22 +010013683 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13684 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13685 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13686 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13687 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013688
Kailang Yangdf694da2005-12-05 19:42:22 +010013689 /* Unmute Stereo Mixer 15 */
13690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13692 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013693 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013694
13695 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13696 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13697 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13698 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13699 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13700 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13701 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13702 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013703 /* hp used DAC 3 (Front) */
13704 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013705 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13706
13707 { }
13708};
13709
13710static struct hda_verb alc861_threestack_init_verbs[] = {
13711 /*
13712 * Unmute ADC0 and set the default input to mic-in
13713 */
13714 /* port-A for surround (rear panel) */
13715 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13716 /* port-B for mic-in (rear panel) with vref */
13717 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13718 /* port-C for line-in (rear panel) */
13719 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13720 /* port-D for Front */
13721 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13722 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13723 /* port-E for HP out (front panel) */
13724 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13725 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013726 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013727 /* port-F for mic-in (front panel) with vref */
13728 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13729 /* port-G for CLFE (rear panel) */
13730 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13731 /* port-H for side (rear panel) */
13732 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13733 /* CD-in */
13734 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13735 /* route front mic to ADC1*/
13736 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13738 /* Unmute DAC0~3 & spdif out*/
13739 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13740 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13741 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13742 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13743 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013744
Kailang Yangdf694da2005-12-05 19:42:22 +010013745 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13746 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13747 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13748 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13749 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013750
Kailang Yangdf694da2005-12-05 19:42:22 +010013751 /* Unmute Stereo Mixer 15 */
13752 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13754 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013755 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013756
13757 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13759 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13760 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13761 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13762 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13763 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13764 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013765 /* hp used DAC 3 (Front) */
13766 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013767 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13768 { }
13769};
Takashi Iwai22309c32006-08-09 16:57:28 +020013770
13771static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13772 /*
13773 * Unmute ADC0 and set the default input to mic-in
13774 */
13775 /* port-A for surround (rear panel) */
13776 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13777 /* port-B for mic-in (rear panel) with vref */
13778 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13779 /* port-C for line-in (rear panel) */
13780 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13781 /* port-D for Front */
13782 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13783 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13784 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013785 /* this has to be set to VREF80 */
13786 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013787 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013788 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013789 /* port-F for mic-in (front panel) with vref */
13790 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13791 /* port-G for CLFE (rear panel) */
13792 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13793 /* port-H for side (rear panel) */
13794 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13795 /* CD-in */
13796 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13797 /* route front mic to ADC1*/
13798 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13799 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13800 /* Unmute DAC0~3 & spdif out*/
13801 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13802 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13803 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13804 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13805 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013806
Takashi Iwai22309c32006-08-09 16:57:28 +020013807 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13808 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13809 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13810 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13811 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013812
Takashi Iwai22309c32006-08-09 16:57:28 +020013813 /* Unmute Stereo Mixer 15 */
13814 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13815 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013818
13819 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13821 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13822 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13825 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013827 /* hp used DAC 3 (Front) */
13828 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13830 { }
13831};
13832
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013833static struct hda_verb alc861_asus_init_verbs[] = {
13834 /*
13835 * Unmute ADC0 and set the default input to mic-in
13836 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013837 /* port-A for surround (rear panel)
13838 * according to codec#0 this is the HP jack
13839 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013840 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13841 /* route front PCM to HP */
13842 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13843 /* port-B for mic-in (rear panel) with vref */
13844 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13845 /* port-C for line-in (rear panel) */
13846 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13847 /* port-D for Front */
13848 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13849 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13850 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013851 /* this has to be set to VREF80 */
13852 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013853 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013854 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013855 /* port-F for mic-in (front panel) with vref */
13856 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13857 /* port-G for CLFE (rear panel) */
13858 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13859 /* port-H for side (rear panel) */
13860 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13861 /* CD-in */
13862 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13863 /* route front mic to ADC1*/
13864 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13865 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13866 /* Unmute DAC0~3 & spdif out*/
13867 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13868 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13869 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13870 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13872 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13873 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13874 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13875 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13876 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013877
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013878 /* Unmute Stereo Mixer 15 */
13879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013882 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013883
13884 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13885 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13886 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13887 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13888 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13890 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13891 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013892 /* hp used DAC 3 (Front) */
13893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013894 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13895 { }
13896};
13897
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013898/* additional init verbs for ASUS laptops */
13899static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13900 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13901 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13902 { }
13903};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013904
Kailang Yangdf694da2005-12-05 19:42:22 +010013905/*
13906 * generic initialization of ADC, input mixers and output mixers
13907 */
13908static struct hda_verb alc861_auto_init_verbs[] = {
13909 /*
13910 * Unmute ADC0 and set the default input to mic-in
13911 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013912 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013913 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013914
Kailang Yangdf694da2005-12-05 19:42:22 +010013915 /* Unmute DAC0~3 & spdif out*/
13916 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13917 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13918 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13919 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013921
Kailang Yangdf694da2005-12-05 19:42:22 +010013922 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13923 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13924 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13925 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13926 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013927
Kailang Yangdf694da2005-12-05 19:42:22 +010013928 /* Unmute Stereo Mixer 15 */
13929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13932 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13933
Takashi Iwai1c209302009-07-22 15:17:45 +020013934 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13935 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13936 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13937 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13938 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13939 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13940 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13941 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013942
13943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13944 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013945 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13946 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013947 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13948 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020013949 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13950 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013951
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013952 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013953
13954 { }
13955};
13956
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013957static struct hda_verb alc861_toshiba_init_verbs[] = {
13958 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013959
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013960 { }
13961};
13962
13963/* toggle speaker-output according to the hp-jack state */
13964static void alc861_toshiba_automute(struct hda_codec *codec)
13965{
13966 unsigned int present;
13967
13968 present = snd_hda_codec_read(codec, 0x0f, 0,
13969 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013970 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13971 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13972 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13973 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013974}
13975
13976static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13977 unsigned int res)
13978{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013979 if ((res >> 26) == ALC880_HP_EVENT)
13980 alc861_toshiba_automute(codec);
13981}
13982
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013983/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013984#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13985#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13986#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13987#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13988
13989
13990#define ALC861_DIGOUT_NID 0x07
13991
13992static struct hda_channel_mode alc861_8ch_modes[1] = {
13993 { 8, NULL }
13994};
13995
13996static hda_nid_t alc861_dac_nids[4] = {
13997 /* front, surround, clfe, side */
13998 0x03, 0x06, 0x05, 0x04
13999};
14000
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014001static hda_nid_t alc660_dac_nids[3] = {
14002 /* front, clfe, surround */
14003 0x03, 0x05, 0x06
14004};
14005
Kailang Yangdf694da2005-12-05 19:42:22 +010014006static hda_nid_t alc861_adc_nids[1] = {
14007 /* ADC0-2 */
14008 0x08,
14009};
14010
14011static struct hda_input_mux alc861_capture_source = {
14012 .num_items = 5,
14013 .items = {
14014 { "Mic", 0x0 },
14015 { "Front Mic", 0x3 },
14016 { "Line", 0x1 },
14017 { "CD", 0x4 },
14018 { "Mixer", 0x5 },
14019 },
14020};
14021
Takashi Iwai1c209302009-07-22 15:17:45 +020014022static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14023{
14024 struct alc_spec *spec = codec->spec;
14025 hda_nid_t mix, srcs[5];
14026 int i, j, num;
14027
14028 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14029 return 0;
14030 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14031 if (num < 0)
14032 return 0;
14033 for (i = 0; i < num; i++) {
14034 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014035 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014036 if (type != AC_WID_AUD_OUT)
14037 continue;
14038 for (j = 0; j < spec->multiout.num_dacs; j++)
14039 if (spec->multiout.dac_nids[j] == srcs[i])
14040 break;
14041 if (j >= spec->multiout.num_dacs)
14042 return srcs[i];
14043 }
14044 return 0;
14045}
14046
Kailang Yangdf694da2005-12-05 19:42:22 +010014047/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014048static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014049 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014050{
Takashi Iwai1c209302009-07-22 15:17:45 +020014051 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014052 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014053 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014054
14055 spec->multiout.dac_nids = spec->private_dac_nids;
14056 for (i = 0; i < cfg->line_outs; i++) {
14057 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014058 dac = alc861_look_for_dac(codec, nid);
14059 if (!dac)
14060 continue;
14061 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014062 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014063 return 0;
14064}
14065
Takashi Iwai1c209302009-07-22 15:17:45 +020014066static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14067 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014068{
14069 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014070 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14071 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14072 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14073}
14074
14075/* add playback controls from the parsed DAC table */
14076static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14077 const struct auto_pin_cfg *cfg)
14078{
14079 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014080 static const char *chname[4] = {
14081 "Front", "Surround", NULL /*CLFE*/, "Side"
14082 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014083 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014084 int i, err;
14085
14086 if (cfg->line_outs == 1) {
14087 const char *pfx = NULL;
14088 if (!cfg->hp_outs)
14089 pfx = "Master";
14090 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14091 pfx = "Speaker";
14092 if (pfx) {
14093 nid = spec->multiout.dac_nids[0];
14094 return alc861_create_out_sw(codec, pfx, nid, 3);
14095 }
14096 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014097
14098 for (i = 0; i < cfg->line_outs; i++) {
14099 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014100 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014101 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014102 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014103 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014104 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014105 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014106 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014107 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014108 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014109 return err;
14110 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014111 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014112 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014113 return err;
14114 }
14115 }
14116 return 0;
14117}
14118
Takashi Iwai1c209302009-07-22 15:17:45 +020014119static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014120{
Takashi Iwai1c209302009-07-22 15:17:45 +020014121 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014122 int err;
14123 hda_nid_t nid;
14124
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014125 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014126 return 0;
14127
14128 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014129 nid = alc861_look_for_dac(codec, pin);
14130 if (nid) {
14131 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14132 if (err < 0)
14133 return err;
14134 spec->multiout.hp_nid = nid;
14135 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014136 }
14137 return 0;
14138}
14139
14140/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014141static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014142 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014143{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014144 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014145}
14146
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014147static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14148 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014149 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014150{
Takashi Iwai1c209302009-07-22 15:17:45 +020014151 hda_nid_t mix, srcs[5];
14152 int i, num;
14153
Jacek Luczak564c5be2008-05-03 18:41:23 +020014154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14155 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014156 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014157 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014158 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14159 return;
14160 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14161 if (num < 0)
14162 return;
14163 for (i = 0; i < num; i++) {
14164 unsigned int mute;
14165 if (srcs[i] == dac || srcs[i] == 0x15)
14166 mute = AMP_IN_UNMUTE(i);
14167 else
14168 mute = AMP_IN_MUTE(i);
14169 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14170 mute);
14171 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014172}
14173
14174static void alc861_auto_init_multi_out(struct hda_codec *codec)
14175{
14176 struct alc_spec *spec = codec->spec;
14177 int i;
14178
14179 for (i = 0; i < spec->autocfg.line_outs; i++) {
14180 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014181 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014182 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014183 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014184 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014185 }
14186}
14187
14188static void alc861_auto_init_hp_out(struct hda_codec *codec)
14189{
14190 struct alc_spec *spec = codec->spec;
14191 hda_nid_t pin;
14192
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014193 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014194 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014195 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014196 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014197 pin = spec->autocfg.speaker_pins[0];
14198 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014199 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14200 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014201}
14202
14203static void alc861_auto_init_analog_input(struct hda_codec *codec)
14204{
14205 struct alc_spec *spec = codec->spec;
14206 int i;
14207
14208 for (i = 0; i < AUTO_PIN_LAST; i++) {
14209 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014210 if (nid >= 0x0c && nid <= 0x11)
14211 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014212 }
14213}
14214
14215/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014216/* return 1 if successful, 0 if the proper config is not found,
14217 * or a negative error code
14218 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014219static int alc861_parse_auto_config(struct hda_codec *codec)
14220{
14221 struct alc_spec *spec = codec->spec;
14222 int err;
14223 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14224
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014225 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14226 alc861_ignore);
14227 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014228 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014229 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014230 return 0; /* can't find valid BIOS pin config */
14231
Takashi Iwai1c209302009-07-22 15:17:45 +020014232 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014233 if (err < 0)
14234 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014235 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014236 if (err < 0)
14237 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014238 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014239 if (err < 0)
14240 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014241 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014242 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014243 return err;
14244
14245 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14246
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014247 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014248 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14249
Takashi Iwai603c4012008-07-30 15:01:44 +020014250 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014251 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014252
Takashi Iwaid88897e2008-10-31 15:01:37 +010014253 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014254
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014255 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014256 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014257
14258 spec->adc_nids = alc861_adc_nids;
14259 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014260 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014261
Takashi Iwai4a79ba342009-04-22 16:31:35 +020014262 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14263
Kailang Yangdf694da2005-12-05 19:42:22 +010014264 return 1;
14265}
14266
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014267/* additional initialization for auto-configuration model */
14268static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014269{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014270 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014271 alc861_auto_init_multi_out(codec);
14272 alc861_auto_init_hp_out(codec);
14273 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014274 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014275 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014276}
14277
Takashi Iwaicb53c622007-08-10 17:21:45 +020014278#ifdef CONFIG_SND_HDA_POWER_SAVE
14279static struct hda_amp_list alc861_loopbacks[] = {
14280 { 0x15, HDA_INPUT, 0 },
14281 { 0x15, HDA_INPUT, 1 },
14282 { 0x15, HDA_INPUT, 2 },
14283 { 0x15, HDA_INPUT, 3 },
14284 { } /* end */
14285};
14286#endif
14287
Kailang Yangdf694da2005-12-05 19:42:22 +010014288
14289/*
14290 * configuration and preset
14291 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014292static const char *alc861_models[ALC861_MODEL_LAST] = {
14293 [ALC861_3ST] = "3stack",
14294 [ALC660_3ST] = "3stack-660",
14295 [ALC861_3ST_DIG] = "3stack-dig",
14296 [ALC861_6ST_DIG] = "6stack-dig",
14297 [ALC861_UNIWILL_M31] = "uniwill-m31",
14298 [ALC861_TOSHIBA] = "toshiba",
14299 [ALC861_ASUS] = "asus",
14300 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14301 [ALC861_AUTO] = "auto",
14302};
14303
14304static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014305 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014306 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14307 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14308 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014309 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014310 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014311 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014312 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14313 * Any other models that need this preset?
14314 */
14315 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014316 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14317 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014318 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14319 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14320 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14321 /* FIXME: the below seems conflict */
14322 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14323 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14324 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014325 {}
14326};
14327
14328static struct alc_config_preset alc861_presets[] = {
14329 [ALC861_3ST] = {
14330 .mixers = { alc861_3ST_mixer },
14331 .init_verbs = { alc861_threestack_init_verbs },
14332 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14333 .dac_nids = alc861_dac_nids,
14334 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14335 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014336 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014337 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14338 .adc_nids = alc861_adc_nids,
14339 .input_mux = &alc861_capture_source,
14340 },
14341 [ALC861_3ST_DIG] = {
14342 .mixers = { alc861_base_mixer },
14343 .init_verbs = { alc861_threestack_init_verbs },
14344 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14345 .dac_nids = alc861_dac_nids,
14346 .dig_out_nid = ALC861_DIGOUT_NID,
14347 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14348 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014349 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014350 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14351 .adc_nids = alc861_adc_nids,
14352 .input_mux = &alc861_capture_source,
14353 },
14354 [ALC861_6ST_DIG] = {
14355 .mixers = { alc861_base_mixer },
14356 .init_verbs = { alc861_base_init_verbs },
14357 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14358 .dac_nids = alc861_dac_nids,
14359 .dig_out_nid = ALC861_DIGOUT_NID,
14360 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14361 .channel_mode = alc861_8ch_modes,
14362 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14363 .adc_nids = alc861_adc_nids,
14364 .input_mux = &alc861_capture_source,
14365 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014366 [ALC660_3ST] = {
14367 .mixers = { alc861_3ST_mixer },
14368 .init_verbs = { alc861_threestack_init_verbs },
14369 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14370 .dac_nids = alc660_dac_nids,
14371 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14372 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014373 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014374 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14375 .adc_nids = alc861_adc_nids,
14376 .input_mux = &alc861_capture_source,
14377 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014378 [ALC861_UNIWILL_M31] = {
14379 .mixers = { alc861_uniwill_m31_mixer },
14380 .init_verbs = { alc861_uniwill_m31_init_verbs },
14381 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14382 .dac_nids = alc861_dac_nids,
14383 .dig_out_nid = ALC861_DIGOUT_NID,
14384 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14385 .channel_mode = alc861_uniwill_m31_modes,
14386 .need_dac_fix = 1,
14387 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14388 .adc_nids = alc861_adc_nids,
14389 .input_mux = &alc861_capture_source,
14390 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014391 [ALC861_TOSHIBA] = {
14392 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014393 .init_verbs = { alc861_base_init_verbs,
14394 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014395 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14396 .dac_nids = alc861_dac_nids,
14397 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14398 .channel_mode = alc883_3ST_2ch_modes,
14399 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14400 .adc_nids = alc861_adc_nids,
14401 .input_mux = &alc861_capture_source,
14402 .unsol_event = alc861_toshiba_unsol_event,
14403 .init_hook = alc861_toshiba_automute,
14404 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014405 [ALC861_ASUS] = {
14406 .mixers = { alc861_asus_mixer },
14407 .init_verbs = { alc861_asus_init_verbs },
14408 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14409 .dac_nids = alc861_dac_nids,
14410 .dig_out_nid = ALC861_DIGOUT_NID,
14411 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14412 .channel_mode = alc861_asus_modes,
14413 .need_dac_fix = 1,
14414 .hp_nid = 0x06,
14415 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14416 .adc_nids = alc861_adc_nids,
14417 .input_mux = &alc861_capture_source,
14418 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014419 [ALC861_ASUS_LAPTOP] = {
14420 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14421 .init_verbs = { alc861_asus_init_verbs,
14422 alc861_asus_laptop_init_verbs },
14423 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14424 .dac_nids = alc861_dac_nids,
14425 .dig_out_nid = ALC861_DIGOUT_NID,
14426 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14427 .channel_mode = alc883_3ST_2ch_modes,
14428 .need_dac_fix = 1,
14429 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14430 .adc_nids = alc861_adc_nids,
14431 .input_mux = &alc861_capture_source,
14432 },
14433};
Kailang Yangdf694da2005-12-05 19:42:22 +010014434
14435
14436static int patch_alc861(struct hda_codec *codec)
14437{
14438 struct alc_spec *spec;
14439 int board_config;
14440 int err;
14441
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014442 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014443 if (spec == NULL)
14444 return -ENOMEM;
14445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014446 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014447
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014448 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14449 alc861_models,
14450 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014451
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014452 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014453 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14454 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014455 board_config = ALC861_AUTO;
14456 }
14457
14458 if (board_config == ALC861_AUTO) {
14459 /* automatic parse from the BIOS config */
14460 err = alc861_parse_auto_config(codec);
14461 if (err < 0) {
14462 alc_free(codec);
14463 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014464 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014465 printk(KERN_INFO
14466 "hda_codec: Cannot set up configuration "
14467 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014468 board_config = ALC861_3ST_DIG;
14469 }
14470 }
14471
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014472 err = snd_hda_attach_beep_device(codec, 0x23);
14473 if (err < 0) {
14474 alc_free(codec);
14475 return err;
14476 }
14477
Kailang Yangdf694da2005-12-05 19:42:22 +010014478 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014479 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014480
Kailang Yangdf694da2005-12-05 19:42:22 +010014481 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14482 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14483
Kailang Yangdf694da2005-12-05 19:42:22 +010014484 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14485 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14486
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014487 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14488
Takashi Iwai2134ea42008-01-10 16:53:55 +010014489 spec->vmaster_nid = 0x03;
14490
Kailang Yangdf694da2005-12-05 19:42:22 +010014491 codec->patch_ops = alc_patch_ops;
14492 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014493 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014494#ifdef CONFIG_SND_HDA_POWER_SAVE
14495 if (!spec->loopback.amplist)
14496 spec->loopback.amplist = alc861_loopbacks;
14497#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014498 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014499
Kailang Yangdf694da2005-12-05 19:42:22 +010014500 return 0;
14501}
14502
14503/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014504 * ALC861-VD support
14505 *
14506 * Based on ALC882
14507 *
14508 * In addition, an independent DAC
14509 */
14510#define ALC861VD_DIGOUT_NID 0x06
14511
14512static hda_nid_t alc861vd_dac_nids[4] = {
14513 /* front, surr, clfe, side surr */
14514 0x02, 0x03, 0x04, 0x05
14515};
14516
14517/* dac_nids for ALC660vd are in a different order - according to
14518 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014519 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014520 * of ALC660vd codecs, but for now there is only 3stack mixer
14521 * - and it is the same as in 861vd.
14522 * adc_nids in ALC660vd are (is) the same as in 861vd
14523 */
14524static hda_nid_t alc660vd_dac_nids[3] = {
14525 /* front, rear, clfe, rear_surr */
14526 0x02, 0x04, 0x03
14527};
14528
14529static hda_nid_t alc861vd_adc_nids[1] = {
14530 /* ADC0 */
14531 0x09,
14532};
14533
Takashi Iwaie1406342008-02-11 18:32:32 +010014534static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14535
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014536/* input MUX */
14537/* FIXME: should be a matrix-type input source selection */
14538static struct hda_input_mux alc861vd_capture_source = {
14539 .num_items = 4,
14540 .items = {
14541 { "Mic", 0x0 },
14542 { "Front Mic", 0x1 },
14543 { "Line", 0x2 },
14544 { "CD", 0x4 },
14545 },
14546};
14547
Kailang Yang272a5272007-05-14 11:00:38 +020014548static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014549 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014550 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014551 { "Ext Mic", 0x0 },
14552 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014553 },
14554};
14555
Kailang Yangd1a991a2007-08-15 16:21:59 +020014556static struct hda_input_mux alc861vd_hp_capture_source = {
14557 .num_items = 2,
14558 .items = {
14559 { "Front Mic", 0x0 },
14560 { "ATAPI Mic", 0x1 },
14561 },
14562};
14563
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014564/*
14565 * 2ch mode
14566 */
14567static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14568 { 2, NULL }
14569};
14570
14571/*
14572 * 6ch mode
14573 */
14574static struct hda_verb alc861vd_6stack_ch6_init[] = {
14575 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14576 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14577 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14578 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14579 { } /* end */
14580};
14581
14582/*
14583 * 8ch mode
14584 */
14585static struct hda_verb alc861vd_6stack_ch8_init[] = {
14586 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14587 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14588 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14589 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14590 { } /* end */
14591};
14592
14593static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14594 { 6, alc861vd_6stack_ch6_init },
14595 { 8, alc861vd_6stack_ch8_init },
14596};
14597
14598static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14599 {
14600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14601 .name = "Channel Mode",
14602 .info = alc_ch_mode_info,
14603 .get = alc_ch_mode_get,
14604 .put = alc_ch_mode_put,
14605 },
14606 { } /* end */
14607};
14608
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014609/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14610 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14611 */
14612static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14613 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14614 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14615
14616 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14617 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14618
14619 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14620 HDA_OUTPUT),
14621 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14622 HDA_OUTPUT),
14623 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14624 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14625
14626 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14627 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14628
14629 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14630
14631 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14634
14635 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14636 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14637 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14638
14639 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14640 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14641
14642 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14643 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14644
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014645 { } /* end */
14646};
14647
14648static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14649 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14650 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14651
14652 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14653
14654 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14657
14658 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14659 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14660 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14661
14662 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14663 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14664
14665 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14666 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14667
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014668 { } /* end */
14669};
14670
Kailang Yangbdd148a2007-05-08 15:19:08 +020014671static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14672 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14673 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14674 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14675
14676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14677
14678 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14681
14682 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14683 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14684 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14685
14686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14688
14689 { } /* end */
14690};
14691
Tobin Davisb419f342008-03-07 11:57:51 +010014692/* Pin assignment: Speaker=0x14, HP = 0x15,
14693 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014694 */
14695static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014696 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14697 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014698 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14699 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014700 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14701 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14702 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14703 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14704 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14705 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014706 { } /* end */
14707};
14708
Kailang Yangd1a991a2007-08-15 16:21:59 +020014709/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14710 * Front Mic=0x18, ATAPI Mic = 0x19,
14711 */
14712static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14713 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14714 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14715 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14716 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14717 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14718 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14719 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14720 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014721
Kailang Yangd1a991a2007-08-15 16:21:59 +020014722 { } /* end */
14723};
14724
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014725/*
14726 * generic initialization of ADC, input mixers and output mixers
14727 */
14728static struct hda_verb alc861vd_volume_init_verbs[] = {
14729 /*
14730 * Unmute ADC0 and set the default input to mic-in
14731 */
14732 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14734
14735 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14736 * the analog-loopback mixer widget
14737 */
14738 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014739 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14740 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14741 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14742 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14743 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014744
14745 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014750
14751 /*
14752 * Set up output mixers (0x02 - 0x05)
14753 */
14754 /* set vol=0 to output mixers */
14755 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14756 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14757 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14758 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14759
14760 /* set up input amps for analog loopback */
14761 /* Amp Indices: DAC = 0, mixer = 1 */
14762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14768 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14769 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14770
14771 { }
14772};
14773
14774/*
14775 * 3-stack pin configuration:
14776 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14777 */
14778static struct hda_verb alc861vd_3stack_init_verbs[] = {
14779 /*
14780 * Set pin mode and muting
14781 */
14782 /* set front pin widgets 0x14 for output */
14783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14785 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14786
14787 /* Mic (rear) pin: input vref at 80% */
14788 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14789 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14790 /* Front Mic pin: input vref at 80% */
14791 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14792 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14793 /* Line In pin: input */
14794 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14796 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14797 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14799 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14800 /* CD pin widget for input */
14801 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14802
14803 { }
14804};
14805
14806/*
14807 * 6-stack pin configuration:
14808 */
14809static struct hda_verb alc861vd_6stack_init_verbs[] = {
14810 /*
14811 * Set pin mode and muting
14812 */
14813 /* set front pin widgets 0x14 for output */
14814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14816 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14817
14818 /* Rear Pin: output 1 (0x0d) */
14819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14822 /* CLFE Pin: output 2 (0x0e) */
14823 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14824 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14825 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14826 /* Side Pin: output 3 (0x0f) */
14827 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14828 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14829 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14830
14831 /* Mic (rear) pin: input vref at 80% */
14832 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14833 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14834 /* Front Mic pin: input vref at 80% */
14835 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14836 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14837 /* Line In pin: input */
14838 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14839 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14840 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14841 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14842 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14843 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14844 /* CD pin widget for input */
14845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14846
14847 { }
14848};
14849
Kailang Yangbdd148a2007-05-08 15:19:08 +020014850static struct hda_verb alc861vd_eapd_verbs[] = {
14851 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14852 { }
14853};
14854
Kailang Yangf9423e72008-05-27 12:32:25 +020014855static struct hda_verb alc660vd_eapd_verbs[] = {
14856 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14857 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14858 { }
14859};
14860
Kailang Yangbdd148a2007-05-08 15:19:08 +020014861static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14862 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14863 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14865 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014866 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014867 {}
14868};
14869
Kailang Yangbdd148a2007-05-08 15:19:08 +020014870static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14871{
14872 unsigned int present;
14873 unsigned char bits;
14874
14875 present = snd_hda_codec_read(codec, 0x18, 0,
14876 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014877 bits = present ? HDA_AMP_MUTE : 0;
14878 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14879 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014880}
14881
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014882static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020014883{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014884 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014885 spec->autocfg.hp_pins[0] = 0x1b;
14886 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014887}
14888
14889static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
14890{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014891 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014892 alc861vd_lenovo_mic_automute(codec);
14893}
14894
14895static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14896 unsigned int res)
14897{
14898 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020014899 case ALC880_MIC_EVENT:
14900 alc861vd_lenovo_mic_automute(codec);
14901 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014902 default:
14903 alc_automute_amp_unsol_event(codec, res);
14904 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020014905 }
14906}
14907
Kailang Yang272a5272007-05-14 11:00:38 +020014908static struct hda_verb alc861vd_dallas_verbs[] = {
14909 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14910 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14911 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14912 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14913
14914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14920 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14921 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014922
Kailang Yang272a5272007-05-14 11:00:38 +020014923 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14924 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14926 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14927 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14928 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14929 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14931
14932 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14933 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14936 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14938 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14939 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14940
14941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14944 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14945
14946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014947 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014948 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14949
14950 { } /* end */
14951};
14952
14953/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014954static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020014955{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014956 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020014957
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020014958 spec->autocfg.hp_pins[0] = 0x15;
14959 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020014960}
14961
Takashi Iwaicb53c622007-08-10 17:21:45 +020014962#ifdef CONFIG_SND_HDA_POWER_SAVE
14963#define alc861vd_loopbacks alc880_loopbacks
14964#endif
14965
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014966/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014967#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14968#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14969#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14970#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14971
14972/*
14973 * configuration and preset
14974 */
14975static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14976 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014977 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014978 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014979 [ALC861VD_3ST] = "3stack",
14980 [ALC861VD_3ST_DIG] = "3stack-digout",
14981 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014982 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014983 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014984 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014985 [ALC861VD_AUTO] = "auto",
14986};
14987
14988static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014989 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14990 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014991 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014992 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014993 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014994 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014995 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014996 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014997 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020014998 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014999 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015000 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015001 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015002 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015003 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015004 {}
15005};
15006
15007static struct alc_config_preset alc861vd_presets[] = {
15008 [ALC660VD_3ST] = {
15009 .mixers = { alc861vd_3st_mixer },
15010 .init_verbs = { alc861vd_volume_init_verbs,
15011 alc861vd_3stack_init_verbs },
15012 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15013 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015014 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15015 .channel_mode = alc861vd_3stack_2ch_modes,
15016 .input_mux = &alc861vd_capture_source,
15017 },
Mike Crash6963f842007-06-25 12:12:51 +020015018 [ALC660VD_3ST_DIG] = {
15019 .mixers = { alc861vd_3st_mixer },
15020 .init_verbs = { alc861vd_volume_init_verbs,
15021 alc861vd_3stack_init_verbs },
15022 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15023 .dac_nids = alc660vd_dac_nids,
15024 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015025 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15026 .channel_mode = alc861vd_3stack_2ch_modes,
15027 .input_mux = &alc861vd_capture_source,
15028 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015029 [ALC861VD_3ST] = {
15030 .mixers = { alc861vd_3st_mixer },
15031 .init_verbs = { alc861vd_volume_init_verbs,
15032 alc861vd_3stack_init_verbs },
15033 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15034 .dac_nids = alc861vd_dac_nids,
15035 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15036 .channel_mode = alc861vd_3stack_2ch_modes,
15037 .input_mux = &alc861vd_capture_source,
15038 },
15039 [ALC861VD_3ST_DIG] = {
15040 .mixers = { alc861vd_3st_mixer },
15041 .init_verbs = { alc861vd_volume_init_verbs,
15042 alc861vd_3stack_init_verbs },
15043 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15044 .dac_nids = alc861vd_dac_nids,
15045 .dig_out_nid = ALC861VD_DIGOUT_NID,
15046 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15047 .channel_mode = alc861vd_3stack_2ch_modes,
15048 .input_mux = &alc861vd_capture_source,
15049 },
15050 [ALC861VD_6ST_DIG] = {
15051 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15052 .init_verbs = { alc861vd_volume_init_verbs,
15053 alc861vd_6stack_init_verbs },
15054 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15055 .dac_nids = alc861vd_dac_nids,
15056 .dig_out_nid = ALC861VD_DIGOUT_NID,
15057 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15058 .channel_mode = alc861vd_6stack_modes,
15059 .input_mux = &alc861vd_capture_source,
15060 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015061 [ALC861VD_LENOVO] = {
15062 .mixers = { alc861vd_lenovo_mixer },
15063 .init_verbs = { alc861vd_volume_init_verbs,
15064 alc861vd_3stack_init_verbs,
15065 alc861vd_eapd_verbs,
15066 alc861vd_lenovo_unsol_verbs },
15067 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15068 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015069 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15070 .channel_mode = alc861vd_3stack_2ch_modes,
15071 .input_mux = &alc861vd_capture_source,
15072 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015073 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015074 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015075 },
Kailang Yang272a5272007-05-14 11:00:38 +020015076 [ALC861VD_DALLAS] = {
15077 .mixers = { alc861vd_dallas_mixer },
15078 .init_verbs = { alc861vd_dallas_verbs },
15079 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15080 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015081 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15082 .channel_mode = alc861vd_3stack_2ch_modes,
15083 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015084 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015085 .setup = alc861vd_dallas_setup,
15086 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015087 },
15088 [ALC861VD_HP] = {
15089 .mixers = { alc861vd_hp_mixer },
15090 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15091 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15092 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015093 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015094 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15095 .channel_mode = alc861vd_3stack_2ch_modes,
15096 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015097 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015098 .setup = alc861vd_dallas_setup,
15099 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015100 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015101 [ALC660VD_ASUS_V1S] = {
15102 .mixers = { alc861vd_lenovo_mixer },
15103 .init_verbs = { alc861vd_volume_init_verbs,
15104 alc861vd_3stack_init_verbs,
15105 alc861vd_eapd_verbs,
15106 alc861vd_lenovo_unsol_verbs },
15107 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15108 .dac_nids = alc660vd_dac_nids,
15109 .dig_out_nid = ALC861VD_DIGOUT_NID,
15110 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15111 .channel_mode = alc861vd_3stack_2ch_modes,
15112 .input_mux = &alc861vd_capture_source,
15113 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015114 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015115 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015116 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015117};
15118
15119/*
15120 * BIOS auto configuration
15121 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015122static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15123 const struct auto_pin_cfg *cfg)
15124{
15125 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
15126}
15127
15128
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15130 hda_nid_t nid, int pin_type, int dac_idx)
15131{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015132 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015133}
15134
15135static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15136{
15137 struct alc_spec *spec = codec->spec;
15138 int i;
15139
15140 for (i = 0; i <= HDA_SIDE; i++) {
15141 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015142 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015143 if (nid)
15144 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015145 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015146 }
15147}
15148
15149
15150static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15151{
15152 struct alc_spec *spec = codec->spec;
15153 hda_nid_t pin;
15154
15155 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015156 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015157 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015158 pin = spec->autocfg.speaker_pins[0];
15159 if (pin)
15160 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015161}
15162
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015163#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15164
15165static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15166{
15167 struct alc_spec *spec = codec->spec;
15168 int i;
15169
15170 for (i = 0; i < AUTO_PIN_LAST; i++) {
15171 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015172 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015173 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015174 if (nid != ALC861VD_PIN_CD_NID &&
15175 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015176 snd_hda_codec_write(codec, nid, 0,
15177 AC_VERB_SET_AMP_GAIN_MUTE,
15178 AMP_OUT_MUTE);
15179 }
15180 }
15181}
15182
Takashi Iwaif511b012008-08-15 16:46:42 +020015183#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15184
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015185#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15186#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15187
15188/* add playback controls from the parsed DAC table */
15189/* Based on ALC880 version. But ALC861VD has separate,
15190 * different NIDs for mute/unmute switch and volume control */
15191static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15192 const struct auto_pin_cfg *cfg)
15193{
15194 char name[32];
15195 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15196 hda_nid_t nid_v, nid_s;
15197 int i, err;
15198
15199 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015200 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015201 continue;
15202 nid_v = alc861vd_idx_to_mixer_vol(
15203 alc880_dac_to_idx(
15204 spec->multiout.dac_nids[i]));
15205 nid_s = alc861vd_idx_to_mixer_switch(
15206 alc880_dac_to_idx(
15207 spec->multiout.dac_nids[i]));
15208
15209 if (i == 2) {
15210 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015211 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15212 "Center Playback Volume",
15213 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15214 HDA_OUTPUT));
15215 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015216 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015217 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15218 "LFE Playback Volume",
15219 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15220 HDA_OUTPUT));
15221 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015222 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223 err = add_control(spec, ALC_CTL_BIND_MUTE,
15224 "Center Playback Switch",
15225 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15226 HDA_INPUT));
15227 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015228 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015229 err = add_control(spec, ALC_CTL_BIND_MUTE,
15230 "LFE Playback Switch",
15231 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15232 HDA_INPUT));
15233 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015234 return err;
15235 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015236 const char *pfx;
15237 if (cfg->line_outs == 1 &&
15238 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
15239 if (!cfg->hp_pins)
15240 pfx = "Speaker";
15241 else
15242 pfx = "PCM";
15243 } else
15244 pfx = chname[i];
15245 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015246 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15247 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15248 HDA_OUTPUT));
15249 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015250 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020015251 if (cfg->line_outs == 1 &&
15252 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15253 pfx = "Speaker";
15254 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015255 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015256 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015257 HDA_INPUT));
15258 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015259 return err;
15260 }
15261 }
15262 return 0;
15263}
15264
15265/* add playback controls for speaker and HP outputs */
15266/* Based on ALC880 version. But ALC861VD has separate,
15267 * different NIDs for mute/unmute switch and volume control */
15268static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15269 hda_nid_t pin, const char *pfx)
15270{
15271 hda_nid_t nid_v, nid_s;
15272 int err;
15273 char name[32];
15274
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015275 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015276 return 0;
15277
15278 if (alc880_is_fixed_pin(pin)) {
15279 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15280 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015281 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015282 spec->multiout.hp_nid = nid_v;
15283 else
15284 spec->multiout.extra_out_nid[0] = nid_v;
15285 /* control HP volume/switch on the output mixer amp */
15286 nid_v = alc861vd_idx_to_mixer_vol(
15287 alc880_fixed_pin_idx(pin));
15288 nid_s = alc861vd_idx_to_mixer_switch(
15289 alc880_fixed_pin_idx(pin));
15290
15291 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015292 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15293 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15294 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015295 return err;
15296 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015297 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15298 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15299 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015300 return err;
15301 } else if (alc880_is_multi_pin(pin)) {
15302 /* set manual connection */
15303 /* we have only a switch on HP-out PIN */
15304 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015305 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15306 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15307 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015308 return err;
15309 }
15310 return 0;
15311}
15312
15313/* parse the BIOS configuration and set up the alc_spec
15314 * return 1 if successful, 0 if the proper config is not found,
15315 * or a negative error code
15316 * Based on ALC880 version - had to change it to override
15317 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15318static int alc861vd_parse_auto_config(struct hda_codec *codec)
15319{
15320 struct alc_spec *spec = codec->spec;
15321 int err;
15322 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15323
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015324 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15325 alc861vd_ignore);
15326 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015327 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015328 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015329 return 0; /* can't find valid BIOS pin config */
15330
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015331 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15332 if (err < 0)
15333 return err;
15334 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15335 if (err < 0)
15336 return err;
15337 err = alc861vd_auto_create_extra_out(spec,
15338 spec->autocfg.speaker_pins[0],
15339 "Speaker");
15340 if (err < 0)
15341 return err;
15342 err = alc861vd_auto_create_extra_out(spec,
15343 spec->autocfg.hp_pins[0],
15344 "Headphone");
15345 if (err < 0)
15346 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015347 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 return err;
15350
15351 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15352
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015353 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015354 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15355
Takashi Iwai603c4012008-07-30 15:01:44 +020015356 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015357 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015358
Takashi Iwaid88897e2008-10-31 15:01:37 +010015359 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015360
15361 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015362 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015363
Takashi Iwai776e1842007-08-29 15:07:11 +020015364 err = alc_auto_add_mic_boost(codec);
15365 if (err < 0)
15366 return err;
15367
Takashi Iwai4a79ba342009-04-22 16:31:35 +020015368 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15369
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015370 return 1;
15371}
15372
15373/* additional initialization for auto-configuration model */
15374static void alc861vd_auto_init(struct hda_codec *codec)
15375{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015376 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015377 alc861vd_auto_init_multi_out(codec);
15378 alc861vd_auto_init_hp_out(codec);
15379 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015380 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015381 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015382 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015383}
15384
15385static int patch_alc861vd(struct hda_codec *codec)
15386{
15387 struct alc_spec *spec;
15388 int err, board_config;
15389
15390 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15391 if (spec == NULL)
15392 return -ENOMEM;
15393
15394 codec->spec = spec;
15395
15396 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15397 alc861vd_models,
15398 alc861vd_cfg_tbl);
15399
15400 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015401 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15402 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015403 board_config = ALC861VD_AUTO;
15404 }
15405
15406 if (board_config == ALC861VD_AUTO) {
15407 /* automatic parse from the BIOS config */
15408 err = alc861vd_parse_auto_config(codec);
15409 if (err < 0) {
15410 alc_free(codec);
15411 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015412 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015413 printk(KERN_INFO
15414 "hda_codec: Cannot set up configuration "
15415 "from BIOS. Using base mode...\n");
15416 board_config = ALC861VD_3ST;
15417 }
15418 }
15419
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015420 err = snd_hda_attach_beep_device(codec, 0x23);
15421 if (err < 0) {
15422 alc_free(codec);
15423 return err;
15424 }
15425
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015426 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015427 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015428
Kailang Yang2f893282008-05-27 12:14:47 +020015429 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015430 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015431 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015432 }
15433
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015434 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15435 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15436
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015437 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15438 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15439
Takashi Iwaidd704692009-08-11 08:45:11 +020015440 if (!spec->adc_nids) {
15441 spec->adc_nids = alc861vd_adc_nids;
15442 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15443 }
15444 if (!spec->capsrc_nids)
15445 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015446
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015447 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015448 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015449
Takashi Iwai2134ea42008-01-10 16:53:55 +010015450 spec->vmaster_nid = 0x02;
15451
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015452 codec->patch_ops = alc_patch_ops;
15453
15454 if (board_config == ALC861VD_AUTO)
15455 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015456#ifdef CONFIG_SND_HDA_POWER_SAVE
15457 if (!spec->loopback.amplist)
15458 spec->loopback.amplist = alc861vd_loopbacks;
15459#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015460 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015461
15462 return 0;
15463}
15464
15465/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015466 * ALC662 support
15467 *
15468 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15469 * configuration. Each pin widget can choose any input DACs and a mixer.
15470 * Each ADC is connected from a mixer of all inputs. This makes possible
15471 * 6-channel independent captures.
15472 *
15473 * In addition, an independent DAC for the multi-playback (not used in this
15474 * driver yet).
15475 */
15476#define ALC662_DIGOUT_NID 0x06
15477#define ALC662_DIGIN_NID 0x0a
15478
15479static hda_nid_t alc662_dac_nids[4] = {
15480 /* front, rear, clfe, rear_surr */
15481 0x02, 0x03, 0x04
15482};
15483
Kailang Yang622e84c2009-04-21 07:39:04 +020015484static hda_nid_t alc272_dac_nids[2] = {
15485 0x02, 0x03
15486};
15487
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015488static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015489 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015490 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015491};
Takashi Iwaie1406342008-02-11 18:32:32 +010015492
Kailang Yang622e84c2009-04-21 07:39:04 +020015493static hda_nid_t alc272_adc_nids[1] = {
15494 /* ADC1-2 */
15495 0x08,
15496};
15497
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015498static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015499static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15500
Takashi Iwaie1406342008-02-11 18:32:32 +010015501
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015502/* input MUX */
15503/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015504static struct hda_input_mux alc662_capture_source = {
15505 .num_items = 4,
15506 .items = {
15507 { "Mic", 0x0 },
15508 { "Front Mic", 0x1 },
15509 { "Line", 0x2 },
15510 { "CD", 0x4 },
15511 },
15512};
15513
15514static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15515 .num_items = 2,
15516 .items = {
15517 { "Mic", 0x1 },
15518 { "Line", 0x2 },
15519 },
15520};
Kailang Yang291702f2007-10-16 14:28:03 +020015521
Kailang Yang6dda9f42008-05-27 12:05:31 +020015522static struct hda_input_mux alc663_capture_source = {
15523 .num_items = 3,
15524 .items = {
15525 { "Mic", 0x0 },
15526 { "Front Mic", 0x1 },
15527 { "Line", 0x2 },
15528 },
15529};
15530
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015531#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020015532static struct hda_input_mux alc272_nc10_capture_source = {
15533 .num_items = 16,
15534 .items = {
15535 { "Autoselect Mic", 0x0 },
15536 { "Internal Mic", 0x1 },
15537 { "In-0x02", 0x2 },
15538 { "In-0x03", 0x3 },
15539 { "In-0x04", 0x4 },
15540 { "In-0x05", 0x5 },
15541 { "In-0x06", 0x6 },
15542 { "In-0x07", 0x7 },
15543 { "In-0x08", 0x8 },
15544 { "In-0x09", 0x9 },
15545 { "In-0x0a", 0x0a },
15546 { "In-0x0b", 0x0b },
15547 { "In-0x0c", 0x0c },
15548 { "In-0x0d", 0x0d },
15549 { "In-0x0e", 0x0e },
15550 { "In-0x0f", 0x0f },
15551 },
15552};
15553#endif
15554
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015555/*
15556 * 2ch mode
15557 */
15558static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15559 { 2, NULL }
15560};
15561
15562/*
15563 * 2ch mode
15564 */
15565static struct hda_verb alc662_3ST_ch2_init[] = {
15566 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15567 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15568 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15569 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15570 { } /* end */
15571};
15572
15573/*
15574 * 6ch mode
15575 */
15576static struct hda_verb alc662_3ST_ch6_init[] = {
15577 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15578 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15579 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15580 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15581 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15582 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15583 { } /* end */
15584};
15585
15586static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15587 { 2, alc662_3ST_ch2_init },
15588 { 6, alc662_3ST_ch6_init },
15589};
15590
15591/*
15592 * 2ch mode
15593 */
15594static struct hda_verb alc662_sixstack_ch6_init[] = {
15595 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15596 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15598 { } /* end */
15599};
15600
15601/*
15602 * 6ch mode
15603 */
15604static struct hda_verb alc662_sixstack_ch8_init[] = {
15605 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15606 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15607 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15608 { } /* end */
15609};
15610
15611static struct hda_channel_mode alc662_5stack_modes[2] = {
15612 { 2, alc662_sixstack_ch6_init },
15613 { 6, alc662_sixstack_ch8_init },
15614};
15615
15616/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15617 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15618 */
15619
15620static struct snd_kcontrol_new alc662_base_mixer[] = {
15621 /* output mixer control */
15622 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015623 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015624 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015625 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015626 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015628 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15629 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15631
15632 /*Input mixer control */
15633 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15634 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15635 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15636 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15637 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15638 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15639 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015641 { } /* end */
15642};
15643
15644static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15645 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015646 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015647 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15648 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15649 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15650 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15651 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15654 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15655 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015656 { } /* end */
15657};
15658
15659static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15660 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015661 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015662 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015663 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015664 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15665 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015666 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15667 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15669 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15670 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15671 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15672 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015677 { } /* end */
15678};
15679
15680static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15681 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15682 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015683 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15684 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015685 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15686 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15687 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015690 { } /* end */
15691};
15692
Kailang Yang291702f2007-10-16 14:28:03 +020015693static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015694 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15695 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015696
15697 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15698 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15699 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15700
15701 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15702 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15703 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15704 { } /* end */
15705};
15706
Kailang Yang8c427222008-01-10 13:03:59 +010015707static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015708 ALC262_HIPPO_MASTER_SWITCH,
15709 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015710 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015711 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15712 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015713 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15714 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15715 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15717 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15718 { } /* end */
15719};
15720
Kailang Yangf1d4e282008-08-26 14:03:29 +020015721static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15722 .ops = &snd_hda_bind_vol,
15723 .values = {
15724 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15725 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15726 0
15727 },
15728};
15729
15730static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15731 .ops = &snd_hda_bind_sw,
15732 .values = {
15733 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15734 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15735 0
15736 },
15737};
15738
Kailang Yang6dda9f42008-05-27 12:05:31 +020015739static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015740 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15741 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15744 { } /* end */
15745};
15746
15747static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15748 .ops = &snd_hda_bind_sw,
15749 .values = {
15750 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15751 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15752 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15753 0
15754 },
15755};
15756
15757static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15758 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15759 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15762 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15763 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15764
15765 { } /* end */
15766};
15767
15768static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15769 .ops = &snd_hda_bind_sw,
15770 .values = {
15771 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15772 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15773 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15774 0
15775 },
15776};
15777
15778static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15779 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15780 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15783 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15784 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15785 { } /* end */
15786};
15787
15788static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015789 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15790 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15794 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15795 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15796 { } /* end */
15797};
15798
15799static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15800 .ops = &snd_hda_bind_vol,
15801 .values = {
15802 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15803 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15804 0
15805 },
15806};
15807
15808static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15809 .ops = &snd_hda_bind_sw,
15810 .values = {
15811 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15812 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15813 0
15814 },
15815};
15816
15817static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15818 HDA_BIND_VOL("Master Playback Volume",
15819 &alc663_asus_two_bind_master_vol),
15820 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15821 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015822 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015825 { } /* end */
15826};
15827
15828static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15829 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15830 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15831 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15832 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015835 { } /* end */
15836};
15837
15838static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15839 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15840 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15841 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15842 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15843 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15844
15845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15847 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15848 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15849 { } /* end */
15850};
15851
15852static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15853 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15854 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15856
15857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15859 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15860 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15861 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15862 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15863 { } /* end */
15864};
15865
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015866static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15867 {
15868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15869 .name = "Channel Mode",
15870 .info = alc_ch_mode_info,
15871 .get = alc_ch_mode_get,
15872 .put = alc_ch_mode_put,
15873 },
15874 { } /* end */
15875};
15876
15877static struct hda_verb alc662_init_verbs[] = {
15878 /* ADC: mute amp left and right */
15879 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15880 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15881 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15882
Takashi Iwaicb53c622007-08-10 17:21:45 +020015883 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15884 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15885 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15886 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15887 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015888
Kailang Yangb60dd392007-09-20 12:50:29 +020015889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15894 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015895
15896 /* Front Pin: output 0 (0x0c) */
15897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15898 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15899
15900 /* Rear Pin: output 1 (0x0d) */
15901 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15902 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15903
15904 /* CLFE Pin: output 2 (0x0e) */
15905 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15906 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15907
15908 /* Mic (rear) pin: input vref at 80% */
15909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15911 /* Front Mic pin: input vref at 80% */
15912 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15913 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15914 /* Line In pin: input */
15915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15917 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15918 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15919 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15920 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15921 /* CD pin widget for input */
15922 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15923
15924 /* FIXME: use matrix-type input source selection */
15925 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15926 /* Input mixer */
15927 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020015928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015929
15930 /* always trun on EAPD */
15931 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15932 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15933
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015934 { }
15935};
15936
15937static struct hda_verb alc662_sue_init_verbs[] = {
15938 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15939 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015940 {}
15941};
15942
15943static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15944 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15945 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15946 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015947};
15948
Kailang Yang8c427222008-01-10 13:03:59 +010015949/* Set Unsolicited Event*/
15950static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15952 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15953 {}
15954};
15955
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015956/*
15957 * generic initialization of ADC, input mixers and output mixers
15958 */
15959static struct hda_verb alc662_auto_init_verbs[] = {
15960 /*
15961 * Unmute ADC and set the default input to mic-in
15962 */
15963 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15964 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15965
15966 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15967 * mixer widget
15968 * Note: PASD motherboards uses the Line In 2 as the input for front
15969 * panel mic (mic 2)
15970 */
15971 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015972 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15973 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15974 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15975 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15976 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015977
15978 /*
15979 * Set up output mixers (0x0c - 0x0f)
15980 */
15981 /* set vol=0 to output mixers */
15982 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15983 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15984 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15985
15986 /* set up input amps for analog loopback */
15987 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015988 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15990 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15991 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15992 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15993 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015994
15995
15996 /* FIXME: use matrix-type input source selection */
15997 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15998 /* Input mixer */
15999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016000 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016001 { }
16002};
16003
Takashi Iwai24fb9172008-09-02 14:48:20 +020016004/* additional verbs for ALC663 */
16005static struct hda_verb alc663_auto_init_verbs[] = {
16006 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16007 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16008 { }
16009};
16010
Kailang Yang6dda9f42008-05-27 12:05:31 +020016011static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016014 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16015 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016016 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016019 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16020 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16021 {}
16022};
16023
Kailang Yangf1d4e282008-08-26 14:03:29 +020016024static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16025 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16026 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16027 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16028 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16029 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16030 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16031 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16032 {}
16033};
16034
16035static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16036 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16037 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16038 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16039 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16042 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16043 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16044 {}
16045};
16046
16047static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16048 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16049 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16050 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16052 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16054 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16055 {}
16056};
16057
16058static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16059 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16060 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16061 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16062 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16065 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16068 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16069 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16071 {}
16072};
16073
16074static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16075 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16076 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16077 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16078 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16086 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16087 {}
16088};
16089
Kailang Yang6dda9f42008-05-27 12:05:31 +020016090static struct hda_verb alc663_g71v_init_verbs[] = {
16091 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16092 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16093 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16094
16095 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16096 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16097 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16098
16099 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16101 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16102 {}
16103};
16104
16105static struct hda_verb alc663_g50v_init_verbs[] = {
16106 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16107 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16108 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16109
16110 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16111 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16112 {}
16113};
16114
Kailang Yangf1d4e282008-08-26 14:03:29 +020016115static struct hda_verb alc662_ecs_init_verbs[] = {
16116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16118 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16119 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16120 {}
16121};
16122
Kailang Yang622e84c2009-04-21 07:39:04 +020016123static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16124 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16125 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16126 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16128 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16129 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16130 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16133 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16134 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16135 {}
16136};
16137
16138static struct hda_verb alc272_dell_init_verbs[] = {
16139 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16140 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16142 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16143 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16144 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16145 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16146 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16148 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16149 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16150 {}
16151};
16152
Kailang Yangf1d4e282008-08-26 14:03:29 +020016153static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16154 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16155 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16156 { } /* end */
16157};
16158
Kailang Yang622e84c2009-04-21 07:39:04 +020016159static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16160 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16161 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16162 { } /* end */
16163};
16164
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016165static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16166{
16167 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016168 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016169
16170 present = snd_hda_codec_read(codec, 0x14, 0,
16171 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016172 bits = present ? HDA_AMP_MUTE : 0;
16173 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16174 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016175}
16176
16177static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16178{
16179 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016180 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016181
16182 present = snd_hda_codec_read(codec, 0x1b, 0,
16183 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016184 bits = present ? HDA_AMP_MUTE : 0;
16185 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16186 HDA_AMP_MUTE, bits);
16187 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16188 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016189}
16190
16191static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16192 unsigned int res)
16193{
16194 if ((res >> 26) == ALC880_HP_EVENT)
16195 alc662_lenovo_101e_all_automute(codec);
16196 if ((res >> 26) == ALC880_FRONT_EVENT)
16197 alc662_lenovo_101e_ispeaker_automute(codec);
16198}
16199
Kailang Yang291702f2007-10-16 14:28:03 +020016200/* unsolicited event for HP jack sensing */
16201static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16202 unsigned int res)
16203{
Kailang Yang291702f2007-10-16 14:28:03 +020016204 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016205 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016206 else
16207 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016208}
16209
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016210static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020016211{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016212 struct alc_spec *spec = codec->spec;
16213
16214 alc262_hippo1_setup(codec);
16215 spec->ext_mic.pin = 0x18;
16216 spec->ext_mic.mux_idx = 0;
16217 spec->int_mic.pin = 0x19;
16218 spec->int_mic.mux_idx = 1;
16219 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020016220}
16221
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016222static void alc662_eeepc_inithook(struct hda_codec *codec)
16223{
16224 alc262_hippo_automute(codec);
16225 alc_mic_automute(codec);
16226}
16227
16228static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010016229{
Takashi Iwai42171c12009-05-08 14:11:43 +020016230 struct alc_spec *spec = codec->spec;
16231
16232 spec->autocfg.hp_pins[0] = 0x14;
16233 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010016234}
16235
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016236#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
16237
Kailang Yang6dda9f42008-05-27 12:05:31 +020016238static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16239{
16240 unsigned int present;
16241 unsigned char bits;
16242
16243 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016244 AC_VERB_GET_PIN_SENSE, 0)
16245 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016246 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016247 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16248 AMP_IN_MUTE(0), bits);
16249 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16250 AMP_IN_MUTE(0), bits);
16251}
16252
16253static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16254{
16255 unsigned int present;
16256 unsigned char bits;
16257
16258 present = snd_hda_codec_read(codec, 0x21, 0,
16259 AC_VERB_GET_PIN_SENSE, 0)
16260 & AC_PINSENSE_PRESENCE;
16261 bits = present ? HDA_AMP_MUTE : 0;
16262 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16263 AMP_IN_MUTE(0), bits);
16264 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16265 AMP_IN_MUTE(0), bits);
16266 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16267 AMP_IN_MUTE(0), bits);
16268 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16269 AMP_IN_MUTE(0), bits);
16270}
16271
16272static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16273{
16274 unsigned int present;
16275 unsigned char bits;
16276
16277 present = snd_hda_codec_read(codec, 0x15, 0,
16278 AC_VERB_GET_PIN_SENSE, 0)
16279 & AC_PINSENSE_PRESENCE;
16280 bits = present ? HDA_AMP_MUTE : 0;
16281 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16282 AMP_IN_MUTE(0), bits);
16283 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16284 AMP_IN_MUTE(0), bits);
16285 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16286 AMP_IN_MUTE(0), bits);
16287 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16288 AMP_IN_MUTE(0), bits);
16289}
16290
16291static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16292{
16293 unsigned int present;
16294 unsigned char bits;
16295
16296 present = snd_hda_codec_read(codec, 0x1b, 0,
16297 AC_VERB_GET_PIN_SENSE, 0)
16298 & AC_PINSENSE_PRESENCE;
16299 bits = present ? 0 : PIN_OUT;
16300 snd_hda_codec_write(codec, 0x14, 0,
16301 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16302}
16303
16304static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16305{
16306 unsigned int present1, present2;
16307
16308 present1 = snd_hda_codec_read(codec, 0x21, 0,
16309 AC_VERB_GET_PIN_SENSE, 0)
16310 & AC_PINSENSE_PRESENCE;
16311 present2 = snd_hda_codec_read(codec, 0x15, 0,
16312 AC_VERB_GET_PIN_SENSE, 0)
16313 & AC_PINSENSE_PRESENCE;
16314
16315 if (present1 || present2) {
16316 snd_hda_codec_write_cache(codec, 0x14, 0,
16317 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16318 } else {
16319 snd_hda_codec_write_cache(codec, 0x14, 0,
16320 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16321 }
16322}
16323
16324static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16325{
16326 unsigned int present1, present2;
16327
16328 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16329 AC_VERB_GET_PIN_SENSE, 0)
16330 & AC_PINSENSE_PRESENCE;
16331 present2 = snd_hda_codec_read(codec, 0x15, 0,
16332 AC_VERB_GET_PIN_SENSE, 0)
16333 & AC_PINSENSE_PRESENCE;
16334
16335 if (present1 || present2) {
16336 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16337 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16338 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16339 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16340 } else {
16341 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16342 AMP_IN_MUTE(0), 0);
16343 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16344 AMP_IN_MUTE(0), 0);
16345 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016346}
16347
Kailang Yang6dda9f42008-05-27 12:05:31 +020016348static void alc663_m51va_unsol_event(struct hda_codec *codec,
16349 unsigned int res)
16350{
16351 switch (res >> 26) {
16352 case ALC880_HP_EVENT:
16353 alc663_m51va_speaker_automute(codec);
16354 break;
16355 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016356 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016357 break;
16358 }
16359}
16360
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016361static void alc663_m51va_setup(struct hda_codec *codec)
16362{
16363 struct alc_spec *spec = codec->spec;
16364 spec->ext_mic.pin = 0x18;
16365 spec->ext_mic.mux_idx = 0;
16366 spec->int_mic.pin = 0x12;
16367 spec->int_mic.mux_idx = 1;
16368 spec->auto_mic = 1;
16369}
16370
Kailang Yang6dda9f42008-05-27 12:05:31 +020016371static void alc663_m51va_inithook(struct hda_codec *codec)
16372{
16373 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016374 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016375}
16376
Kailang Yangf1d4e282008-08-26 14:03:29 +020016377/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016378#define alc663_mode1_unsol_event alc663_m51va_unsol_event
16379#define alc663_mode1_setup alc663_m51va_setup
16380#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020016381
Kailang Yangf1d4e282008-08-26 14:03:29 +020016382/* ***************** Mode2 ******************************/
16383static void alc662_mode2_unsol_event(struct hda_codec *codec,
16384 unsigned int res)
16385{
16386 switch (res >> 26) {
16387 case ALC880_HP_EVENT:
16388 alc662_f5z_speaker_automute(codec);
16389 break;
16390 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016391 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016392 break;
16393 }
16394}
16395
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016396#define alc662_mode2_setup alc663_m51va_setup
16397
Kailang Yangf1d4e282008-08-26 14:03:29 +020016398static void alc662_mode2_inithook(struct hda_codec *codec)
16399{
16400 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016401 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016402}
16403/* ***************** Mode3 ******************************/
16404static void alc663_mode3_unsol_event(struct hda_codec *codec,
16405 unsigned int res)
16406{
16407 switch (res >> 26) {
16408 case ALC880_HP_EVENT:
16409 alc663_two_hp_m1_speaker_automute(codec);
16410 break;
16411 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016412 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016413 break;
16414 }
16415}
16416
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016417#define alc663_mode3_setup alc663_m51va_setup
16418
Kailang Yangf1d4e282008-08-26 14:03:29 +020016419static void alc663_mode3_inithook(struct hda_codec *codec)
16420{
16421 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016422 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016423}
16424/* ***************** Mode4 ******************************/
16425static void alc663_mode4_unsol_event(struct hda_codec *codec,
16426 unsigned int res)
16427{
16428 switch (res >> 26) {
16429 case ALC880_HP_EVENT:
16430 alc663_21jd_two_speaker_automute(codec);
16431 break;
16432 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016433 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016434 break;
16435 }
16436}
16437
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016438#define alc663_mode4_setup alc663_m51va_setup
16439
Kailang Yangf1d4e282008-08-26 14:03:29 +020016440static void alc663_mode4_inithook(struct hda_codec *codec)
16441{
16442 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016443 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016444}
16445/* ***************** Mode5 ******************************/
16446static void alc663_mode5_unsol_event(struct hda_codec *codec,
16447 unsigned int res)
16448{
16449 switch (res >> 26) {
16450 case ALC880_HP_EVENT:
16451 alc663_15jd_two_speaker_automute(codec);
16452 break;
16453 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016454 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016455 break;
16456 }
16457}
16458
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016459#define alc663_mode5_setup alc663_m51va_setup
16460
Kailang Yangf1d4e282008-08-26 14:03:29 +020016461static void alc663_mode5_inithook(struct hda_codec *codec)
16462{
16463 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016464 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016465}
16466/* ***************** Mode6 ******************************/
16467static void alc663_mode6_unsol_event(struct hda_codec *codec,
16468 unsigned int res)
16469{
16470 switch (res >> 26) {
16471 case ALC880_HP_EVENT:
16472 alc663_two_hp_m2_speaker_automute(codec);
16473 break;
16474 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016475 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016476 break;
16477 }
16478}
16479
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016480#define alc663_mode6_setup alc663_m51va_setup
16481
Kailang Yangf1d4e282008-08-26 14:03:29 +020016482static void alc663_mode6_inithook(struct hda_codec *codec)
16483{
16484 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016485 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020016486}
16487
Kailang Yang6dda9f42008-05-27 12:05:31 +020016488static void alc663_g71v_hp_automute(struct hda_codec *codec)
16489{
16490 unsigned int present;
16491 unsigned char bits;
16492
16493 present = snd_hda_codec_read(codec, 0x21, 0,
16494 AC_VERB_GET_PIN_SENSE, 0)
16495 & AC_PINSENSE_PRESENCE;
16496 bits = present ? HDA_AMP_MUTE : 0;
16497 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16498 HDA_AMP_MUTE, bits);
16499 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16500 HDA_AMP_MUTE, bits);
16501}
16502
16503static void alc663_g71v_front_automute(struct hda_codec *codec)
16504{
16505 unsigned int present;
16506 unsigned char bits;
16507
16508 present = snd_hda_codec_read(codec, 0x15, 0,
16509 AC_VERB_GET_PIN_SENSE, 0)
16510 & AC_PINSENSE_PRESENCE;
16511 bits = present ? HDA_AMP_MUTE : 0;
16512 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16513 HDA_AMP_MUTE, bits);
16514}
16515
16516static void alc663_g71v_unsol_event(struct hda_codec *codec,
16517 unsigned int res)
16518{
16519 switch (res >> 26) {
16520 case ALC880_HP_EVENT:
16521 alc663_g71v_hp_automute(codec);
16522 break;
16523 case ALC880_FRONT_EVENT:
16524 alc663_g71v_front_automute(codec);
16525 break;
16526 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016527 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016528 break;
16529 }
16530}
16531
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016532#define alc663_g71v_setup alc663_m51va_setup
16533
Kailang Yang6dda9f42008-05-27 12:05:31 +020016534static void alc663_g71v_inithook(struct hda_codec *codec)
16535{
16536 alc663_g71v_front_automute(codec);
16537 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016538 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016539}
16540
16541static void alc663_g50v_unsol_event(struct hda_codec *codec,
16542 unsigned int res)
16543{
16544 switch (res >> 26) {
16545 case ALC880_HP_EVENT:
16546 alc663_m51va_speaker_automute(codec);
16547 break;
16548 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016549 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016550 break;
16551 }
16552}
16553
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016554#define alc663_g50v_setup alc663_m51va_setup
16555
Kailang Yang6dda9f42008-05-27 12:05:31 +020016556static void alc663_g50v_inithook(struct hda_codec *codec)
16557{
16558 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016559 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020016560}
16561
Kailang Yangf1d4e282008-08-26 14:03:29 +020016562static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16563 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016564 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016565
16566 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16567 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16568 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16569
16570 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16571 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16572 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16573 { } /* end */
16574};
16575
Chris Pockelé9541ba12009-05-12 08:08:53 +020016576static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16577 /* Master Playback automatically created from Speaker and Headphone */
16578 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16579 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16580 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16581 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16582
16583 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16584 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16585 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16586
16587 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16588 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16589 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16590 { } /* end */
16591};
16592
Takashi Iwaicb53c622007-08-10 17:21:45 +020016593#ifdef CONFIG_SND_HDA_POWER_SAVE
16594#define alc662_loopbacks alc880_loopbacks
16595#endif
16596
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016597
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016598/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016599#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16600#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16601#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16602#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16603
16604/*
16605 * configuration and preset
16606 */
16607static const char *alc662_models[ALC662_MODEL_LAST] = {
16608 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16609 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16610 [ALC662_3ST_6ch] = "3stack-6ch",
16611 [ALC662_5ST_DIG] = "6stack-dig",
16612 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016613 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016614 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016615 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016616 [ALC663_ASUS_M51VA] = "m51va",
16617 [ALC663_ASUS_G71V] = "g71v",
16618 [ALC663_ASUS_H13] = "h13",
16619 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016620 [ALC663_ASUS_MODE1] = "asus-mode1",
16621 [ALC662_ASUS_MODE2] = "asus-mode2",
16622 [ALC663_ASUS_MODE3] = "asus-mode3",
16623 [ALC663_ASUS_MODE4] = "asus-mode4",
16624 [ALC663_ASUS_MODE5] = "asus-mode5",
16625 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016626 [ALC272_DELL] = "dell",
16627 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016628 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016629 [ALC662_AUTO] = "auto",
16630};
16631
16632static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016633 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016634 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16635 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016636 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16637 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16638 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16639 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16640 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16641 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16642 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16643 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16644 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16645 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16646 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16647 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016648 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16649 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16650 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016651 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16652 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16653 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16654 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016655 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016656 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16657 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016658 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016659 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16660 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16661 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016662 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16663 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16664 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016665 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16666 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16667 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016668 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016669 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16670 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016671 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016672 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016673 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016674 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16675 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16676 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016677 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016678 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16679 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016680 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016681 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016682 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016683 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016684 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16685 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016686 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016687 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16688 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016689 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016690 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016691 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016692 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016693 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016694 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16695 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016696 {}
16697};
16698
16699static struct alc_config_preset alc662_presets[] = {
16700 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016701 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016702 .init_verbs = { alc662_init_verbs },
16703 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16704 .dac_nids = alc662_dac_nids,
16705 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016706 .dig_in_nid = ALC662_DIGIN_NID,
16707 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16708 .channel_mode = alc662_3ST_2ch_modes,
16709 .input_mux = &alc662_capture_source,
16710 },
16711 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016712 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016713 .init_verbs = { alc662_init_verbs },
16714 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16715 .dac_nids = alc662_dac_nids,
16716 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016717 .dig_in_nid = ALC662_DIGIN_NID,
16718 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16719 .channel_mode = alc662_3ST_6ch_modes,
16720 .need_dac_fix = 1,
16721 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016722 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016723 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016724 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016725 .init_verbs = { alc662_init_verbs },
16726 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16727 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016728 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16729 .channel_mode = alc662_3ST_6ch_modes,
16730 .need_dac_fix = 1,
16731 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016732 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016733 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016734 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016735 .init_verbs = { alc662_init_verbs },
16736 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16737 .dac_nids = alc662_dac_nids,
16738 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016739 .dig_in_nid = ALC662_DIGIN_NID,
16740 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16741 .channel_mode = alc662_5stack_modes,
16742 .input_mux = &alc662_capture_source,
16743 },
16744 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016745 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016746 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16747 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16748 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016749 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16750 .channel_mode = alc662_3ST_2ch_modes,
16751 .input_mux = &alc662_lenovo_101e_capture_source,
16752 .unsol_event = alc662_lenovo_101e_unsol_event,
16753 .init_hook = alc662_lenovo_101e_all_automute,
16754 },
Kailang Yang291702f2007-10-16 14:28:03 +020016755 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016756 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016757 .init_verbs = { alc662_init_verbs,
16758 alc662_eeepc_sue_init_verbs },
16759 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16760 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016761 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16762 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020016763 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016764 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020016765 .init_hook = alc662_eeepc_inithook,
16766 },
Kailang Yang8c427222008-01-10 13:03:59 +010016767 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016768 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016769 alc662_chmode_mixer },
16770 .init_verbs = { alc662_init_verbs,
16771 alc662_eeepc_ep20_sue_init_verbs },
16772 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16773 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016774 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16775 .channel_mode = alc662_3ST_6ch_modes,
16776 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016777 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016778 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010016779 .init_hook = alc662_eeepc_ep20_inithook,
16780 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016781 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016782 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016783 .init_verbs = { alc662_init_verbs,
16784 alc662_ecs_init_verbs },
16785 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16786 .dac_nids = alc662_dac_nids,
16787 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16788 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016789 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016790 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016791 .init_hook = alc662_eeepc_inithook,
16792 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016793 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016794 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016795 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16796 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16797 .dac_nids = alc662_dac_nids,
16798 .dig_out_nid = ALC662_DIGOUT_NID,
16799 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16800 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016801 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016802 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016803 .init_hook = alc663_m51va_inithook,
16804 },
16805 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016806 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016807 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16808 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16809 .dac_nids = alc662_dac_nids,
16810 .dig_out_nid = ALC662_DIGOUT_NID,
16811 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16812 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016813 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016814 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016815 .init_hook = alc663_g71v_inithook,
16816 },
16817 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016818 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016819 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16820 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16821 .dac_nids = alc662_dac_nids,
16822 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16823 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016824 .unsol_event = alc663_m51va_unsol_event,
16825 .init_hook = alc663_m51va_inithook,
16826 },
16827 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016828 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016829 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16830 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16831 .dac_nids = alc662_dac_nids,
16832 .dig_out_nid = ALC662_DIGOUT_NID,
16833 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16834 .channel_mode = alc662_3ST_6ch_modes,
16835 .input_mux = &alc663_capture_source,
16836 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016837 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020016838 .init_hook = alc663_g50v_inithook,
16839 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016840 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016841 .mixers = { alc663_m51va_mixer },
16842 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016843 .init_verbs = { alc662_init_verbs,
16844 alc663_21jd_amic_init_verbs },
16845 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16846 .hp_nid = 0x03,
16847 .dac_nids = alc662_dac_nids,
16848 .dig_out_nid = ALC662_DIGOUT_NID,
16849 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16850 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016851 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016852 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016853 .init_hook = alc663_mode1_inithook,
16854 },
16855 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016856 .mixers = { alc662_1bjd_mixer },
16857 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016858 .init_verbs = { alc662_init_verbs,
16859 alc662_1bjd_amic_init_verbs },
16860 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16861 .dac_nids = alc662_dac_nids,
16862 .dig_out_nid = ALC662_DIGOUT_NID,
16863 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16864 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016865 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016866 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016867 .init_hook = alc662_mode2_inithook,
16868 },
16869 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016870 .mixers = { alc663_two_hp_m1_mixer },
16871 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016872 .init_verbs = { alc662_init_verbs,
16873 alc663_two_hp_amic_m1_init_verbs },
16874 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16875 .hp_nid = 0x03,
16876 .dac_nids = alc662_dac_nids,
16877 .dig_out_nid = ALC662_DIGOUT_NID,
16878 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16879 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016880 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016881 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016882 .init_hook = alc663_mode3_inithook,
16883 },
16884 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016885 .mixers = { alc663_asus_21jd_clfe_mixer },
16886 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016887 .init_verbs = { alc662_init_verbs,
16888 alc663_21jd_amic_init_verbs},
16889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16890 .hp_nid = 0x03,
16891 .dac_nids = alc662_dac_nids,
16892 .dig_out_nid = ALC662_DIGOUT_NID,
16893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16894 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016895 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016896 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016897 .init_hook = alc663_mode4_inithook,
16898 },
16899 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016900 .mixers = { alc663_asus_15jd_clfe_mixer },
16901 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016902 .init_verbs = { alc662_init_verbs,
16903 alc663_15jd_amic_init_verbs },
16904 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16905 .hp_nid = 0x03,
16906 .dac_nids = alc662_dac_nids,
16907 .dig_out_nid = ALC662_DIGOUT_NID,
16908 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16909 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016910 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016911 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016912 .init_hook = alc663_mode5_inithook,
16913 },
16914 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016915 .mixers = { alc663_two_hp_m2_mixer },
16916 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016917 .init_verbs = { alc662_init_verbs,
16918 alc663_two_hp_amic_m2_init_verbs },
16919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16920 .hp_nid = 0x03,
16921 .dac_nids = alc662_dac_nids,
16922 .dig_out_nid = ALC662_DIGOUT_NID,
16923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16924 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016925 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016926 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016927 .init_hook = alc663_mode6_inithook,
16928 },
Kailang Yang622e84c2009-04-21 07:39:04 +020016929 [ALC272_DELL] = {
16930 .mixers = { alc663_m51va_mixer },
16931 .cap_mixer = alc272_auto_capture_mixer,
16932 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
16933 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16934 .dac_nids = alc662_dac_nids,
16935 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16936 .adc_nids = alc272_adc_nids,
16937 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
16938 .capsrc_nids = alc272_capsrc_nids,
16939 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020016940 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016941 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020016942 .init_hook = alc663_m51va_inithook,
16943 },
16944 [ALC272_DELL_ZM1] = {
16945 .mixers = { alc663_m51va_mixer },
16946 .cap_mixer = alc662_auto_capture_mixer,
16947 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
16948 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16949 .dac_nids = alc662_dac_nids,
16950 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16951 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016952 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020016953 .capsrc_nids = alc662_capsrc_nids,
16954 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020016955 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016956 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020016957 .init_hook = alc663_m51va_inithook,
16958 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020016959 [ALC272_SAMSUNG_NC10] = {
16960 .mixers = { alc272_nc10_mixer },
16961 .init_verbs = { alc662_init_verbs,
16962 alc663_21jd_amic_init_verbs },
16963 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
16964 .dac_nids = alc272_dac_nids,
16965 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16966 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016967 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020016968 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016969 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020016970 .init_hook = alc663_mode4_inithook,
16971 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016972};
16973
16974
16975/*
16976 * BIOS auto configuration
16977 */
16978
16979/* add playback controls from the parsed DAC table */
16980static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16981 const struct auto_pin_cfg *cfg)
16982{
16983 char name[32];
16984 static const char *chname[4] = {
16985 "Front", "Surround", NULL /*CLFE*/, "Side"
16986 };
16987 hda_nid_t nid;
16988 int i, err;
16989
16990 for (i = 0; i < cfg->line_outs; i++) {
16991 if (!spec->multiout.dac_nids[i])
16992 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016993 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016994 if (i == 2) {
16995 /* Center/LFE */
16996 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16997 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016998 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16999 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017000 if (err < 0)
17001 return err;
17002 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17003 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017004 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17005 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017006 if (err < 0)
17007 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017008 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017009 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017010 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017011 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017012 if (err < 0)
17013 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017014 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017015 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017016 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017017 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017018 if (err < 0)
17019 return err;
17020 } else {
17021 sprintf(name, "%s Playback Volume", chname[i]);
17022 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017023 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17024 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017025 if (err < 0)
17026 return err;
17027 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017028 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17029 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17030 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017031 if (err < 0)
17032 return err;
17033 }
17034 }
17035 return 0;
17036}
17037
17038/* add playback controls for speaker and HP outputs */
17039static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17040 const char *pfx)
17041{
17042 hda_nid_t nid;
17043 int err;
17044 char name[32];
17045
17046 if (!pin)
17047 return 0;
17048
Takashi Iwai24fb9172008-09-02 14:48:20 +020017049 if (pin == 0x17) {
17050 /* ALC663 has a mono output pin on 0x17 */
17051 sprintf(name, "%s Playback Switch", pfx);
17052 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17053 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17054 return err;
17055 }
17056
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017057 if (alc880_is_fixed_pin(pin)) {
17058 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017059 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017060 /* specify the DAC as the extra output */
17061 if (!spec->multiout.hp_nid)
17062 spec->multiout.hp_nid = nid;
17063 else
17064 spec->multiout.extra_out_nid[0] = nid;
17065 /* control HP volume/switch on the output mixer amp */
17066 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17067 sprintf(name, "%s Playback Volume", pfx);
17068 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17069 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17070 if (err < 0)
17071 return err;
17072 sprintf(name, "%s Playback Switch", pfx);
17073 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17074 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17075 if (err < 0)
17076 return err;
17077 } else if (alc880_is_multi_pin(pin)) {
17078 /* set manual connection */
17079 /* we have only a switch on HP-out PIN */
17080 sprintf(name, "%s Playback Switch", pfx);
17081 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17082 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17083 if (err < 0)
17084 return err;
17085 }
17086 return 0;
17087}
17088
17089/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017090#define alc662_auto_create_input_ctls \
17091 alc880_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017092
17093static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17094 hda_nid_t nid, int pin_type,
17095 int dac_idx)
17096{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017097 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017098 /* need the manual connection? */
17099 if (alc880_is_multi_pin(nid)) {
17100 struct alc_spec *spec = codec->spec;
17101 int idx = alc880_multi_pin_idx(nid);
17102 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17103 AC_VERB_SET_CONNECT_SEL,
17104 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17105 }
17106}
17107
17108static void alc662_auto_init_multi_out(struct hda_codec *codec)
17109{
17110 struct alc_spec *spec = codec->spec;
17111 int i;
17112
17113 for (i = 0; i <= HDA_SIDE; i++) {
17114 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017115 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017116 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017117 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017118 i);
17119 }
17120}
17121
17122static void alc662_auto_init_hp_out(struct hda_codec *codec)
17123{
17124 struct alc_spec *spec = codec->spec;
17125 hda_nid_t pin;
17126
17127 pin = spec->autocfg.hp_pins[0];
17128 if (pin) /* connect to front */
17129 /* use dac 0 */
17130 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017131 pin = spec->autocfg.speaker_pins[0];
17132 if (pin)
17133 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017134}
17135
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017136#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17137
17138static void alc662_auto_init_analog_input(struct hda_codec *codec)
17139{
17140 struct alc_spec *spec = codec->spec;
17141 int i;
17142
17143 for (i = 0; i < AUTO_PIN_LAST; i++) {
17144 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020017145 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017146 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017147 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017148 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017149 snd_hda_codec_write(codec, nid, 0,
17150 AC_VERB_SET_AMP_GAIN_MUTE,
17151 AMP_OUT_MUTE);
17152 }
17153 }
17154}
17155
Takashi Iwaif511b012008-08-15 16:46:42 +020017156#define alc662_auto_init_input_src alc882_auto_init_input_src
17157
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017158static int alc662_parse_auto_config(struct hda_codec *codec)
17159{
17160 struct alc_spec *spec = codec->spec;
17161 int err;
17162 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17163
17164 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17165 alc662_ignore);
17166 if (err < 0)
17167 return err;
17168 if (!spec->autocfg.line_outs)
17169 return 0; /* can't find valid BIOS pin config */
17170
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017171 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17172 if (err < 0)
17173 return err;
17174 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17175 if (err < 0)
17176 return err;
17177 err = alc662_auto_create_extra_out(spec,
17178 spec->autocfg.speaker_pins[0],
17179 "Speaker");
17180 if (err < 0)
17181 return err;
17182 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17183 "Headphone");
17184 if (err < 0)
17185 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017186 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017187 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017188 return err;
17189
17190 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17191
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017192 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017193 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17194
Takashi Iwai603c4012008-07-30 15:01:44 +020017195 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017196 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017197
17198 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017199 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017200
Takashi Iwaid88897e2008-10-31 15:01:37 +010017201 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017202 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017203 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017204
17205 err = alc_auto_add_mic_boost(codec);
17206 if (err < 0)
17207 return err;
17208
Takashi Iwai4a79ba342009-04-22 16:31:35 +020017209 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17210
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017211 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017212}
17213
17214/* additional initialization for auto-configuration model */
17215static void alc662_auto_init(struct hda_codec *codec)
17216{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017217 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017218 alc662_auto_init_multi_out(codec);
17219 alc662_auto_init_hp_out(codec);
17220 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017221 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017222 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017223 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017224}
17225
17226static int patch_alc662(struct hda_codec *codec)
17227{
17228 struct alc_spec *spec;
17229 int err, board_config;
17230
17231 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17232 if (!spec)
17233 return -ENOMEM;
17234
17235 codec->spec = spec;
17236
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017237 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17238
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017239 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17240 alc662_models,
17241 alc662_cfg_tbl);
17242 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017243 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17244 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017245 board_config = ALC662_AUTO;
17246 }
17247
17248 if (board_config == ALC662_AUTO) {
17249 /* automatic parse from the BIOS config */
17250 err = alc662_parse_auto_config(codec);
17251 if (err < 0) {
17252 alc_free(codec);
17253 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017254 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017255 printk(KERN_INFO
17256 "hda_codec: Cannot set up configuration "
17257 "from BIOS. Using base mode...\n");
17258 board_config = ALC662_3ST_2ch_DIG;
17259 }
17260 }
17261
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017262 err = snd_hda_attach_beep_device(codec, 0x1);
17263 if (err < 0) {
17264 alc_free(codec);
17265 return err;
17266 }
17267
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017268 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017269 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017270
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017271 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17272 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17273
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017274 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17275 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17276
Takashi Iwaidd704692009-08-11 08:45:11 +020017277 if (!spec->adc_nids) {
17278 spec->adc_nids = alc662_adc_nids;
17279 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17280 }
17281 if (!spec->capsrc_nids)
17282 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017283
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017284 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017285 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017286 if (codec->vendor_id == 0x10ec0662)
17287 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17288 else
17289 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017290
Takashi Iwai2134ea42008-01-10 16:53:55 +010017291 spec->vmaster_nid = 0x02;
17292
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017293 codec->patch_ops = alc_patch_ops;
17294 if (board_config == ALC662_AUTO)
17295 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017296#ifdef CONFIG_SND_HDA_POWER_SAVE
17297 if (!spec->loopback.amplist)
17298 spec->loopback.amplist = alc662_loopbacks;
17299#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017300 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017301
17302 return 0;
17303}
17304
17305/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017306 * patch entries
17307 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017308static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017309 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017310 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017311 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017312 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017313 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017314 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017315 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017316 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017317 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17318 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17319 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017320 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017321 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017322 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17323 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017324 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017325 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017326 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017327 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017328 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017329 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017330 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017331 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017332 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017333 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017334 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017335 .patch = patch_alc882 },
17336 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17337 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017338 {} /* terminator */
17339};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017340
17341MODULE_ALIAS("snd-hda-codec-id:10ec*");
17342
17343MODULE_LICENSE("GPL");
17344MODULE_DESCRIPTION("Realtek HD-audio codec");
17345
17346static struct hda_codec_preset_list realtek_list = {
17347 .preset = snd_hda_preset_realtek,
17348 .owner = THIS_MODULE,
17349};
17350
17351static int __init patch_realtek_init(void)
17352{
17353 return snd_hda_add_codec_preset(&realtek_list);
17354}
17355
17356static void __exit patch_realtek_exit(void)
17357{
17358 snd_hda_delete_codec_preset(&realtek_list);
17359}
17360
17361module_init(patch_realtek_init)
17362module_exit(patch_realtek_exit)