blob: b2e097bdc59c023c092c0ca648078f558574a365 [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Avdoninbab282b2006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200223 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100225 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200226 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200227 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200228 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200231 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100232 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100233 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100234 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100235 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800236 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200237 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200238 ALC889A_INTEL,
239 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200242 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200244 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200245 ALC882_AUTO,
246 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247};
248
Kailang Yangdf694da2005-12-05 19:42:22 +0100249/* for GPIO Poll */
250#define GPIO_MASK 0x03
251
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200252/* extra amp-initialization sequence types */
253enum {
254 ALC_INIT_NONE,
255 ALC_INIT_DEFAULT,
256 ALC_INIT_GPIO1,
257 ALC_INIT_GPIO2,
258 ALC_INIT_GPIO3,
259};
260
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 Iwai4a79ba32009-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Iwai4a79ba32009-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 Iwai4a79ba32009-04-22 16:31:35 +02001094 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001095
Takashi Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-04-22 16:31:35 +02001169}
Kailang Yangea1fb292008-08-26 12:58:38 +02001170
Takashi Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-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 Iwai4a79ba32009-04-22 16:31:35 +02001341 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001342 }
1343
Takashi Iwai4a79ba32009-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 Iwai4a79ba32009-04-22 16:31:35 +02001346 return 1;
1347}
Kailang Yangea1fb292008-08-26 12:58:38 +02001348
Takashi Iwai4a79ba32009-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 Iwai4a79ba32009-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
Wu Fengguang6732bd02009-07-30 09:19:14 +02001540static void alc889_automute_init(struct hda_codec *codec)
1541{
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;
1550 alc_automute_amp(codec);
1551}
1552
1553static void alc889_intel_init_hook(struct hda_codec *codec)
1554{
1555 alc889_coef_init(codec);
1556 alc889_automute_init(codec);
1557}
1558
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001559static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1560{
1561 struct alc_spec *spec = codec->spec;
1562
1563 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1564 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1565 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1566 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1567 alc_automute_amp(codec);
1568}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001569
1570/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001571 * ALC888 Acer Aspire 4930G model
1572 */
1573
1574static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1575/* Front Mic: set to PIN_IN (empty by default) */
1576 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1577/* Unselect Front Mic by default in input mixer 3 */
1578 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001579/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001580 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1581/* Connect Internal HP to front */
1582 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1583 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1584 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1585/* Connect HP out to front */
1586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1587 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1588 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1589 { }
1590};
1591
Hector Martin3b315d72009-06-02 10:54:19 +02001592/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001593 * ALC888 Acer Aspire 6530G model
1594 */
1595
1596static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1597/* Bias voltage on for external mic port */
1598 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001599/* Front Mic: set to PIN_IN (empty by default) */
1600 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1601/* Unselect Front Mic by default in input mixer 3 */
1602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001603/* Enable unsolicited event for HP jack */
1604 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1605/* Enable speaker output */
1606 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1607 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1608/* Enable headphone output */
1609 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1612 { }
1613};
1614
1615/*
Hector Martin018df412009-06-04 00:13:40 +02001616 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001617 */
1618
Hector Martin018df412009-06-04 00:13:40 +02001619static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001620/* Front Mic: set to PIN_IN (empty by default) */
1621 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1622/* Unselect Front Mic by default in input mixer 3 */
1623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1624/* Enable unsolicited event for HP jack */
1625 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1626/* Connect Internal Front to Front */
1627 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1628 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1629 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1630/* Connect Internal Rear to Rear */
1631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1634/* Connect Internal CLFE to CLFE */
1635 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1637 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1638/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001639 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001640 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1642/* Enable all DACs */
1643/* DAC DISABLE/MUTE 1? */
1644/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1645 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1646 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1647/* DAC DISABLE/MUTE 2? */
1648/* some bit here disables the other DACs. Init=0x4900 */
1649 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1650 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1651/* Enable amplifiers */
1652 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1653 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001654/* DMIC fix
1655 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1656 * which makes the stereo useless. However, either the mic or the ALC889
1657 * makes the signal become a difference/sum signal instead of standard
1658 * stereo, which is annoying. So instead we flip this bit which makes the
1659 * codec replicate the sum signal to both channels, turning it into a
1660 * normal mono mic.
1661 */
1662/* DMIC_CONTROL? Init value = 0x0001 */
1663 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1664 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001665 { }
1666};
1667
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001668static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001669 /* Front mic only available on one ADC */
1670 {
1671 .num_items = 4,
1672 .items = {
1673 { "Mic", 0x0 },
1674 { "Line", 0x2 },
1675 { "CD", 0x4 },
1676 { "Front Mic", 0xb },
1677 },
1678 },
1679 {
1680 .num_items = 3,
1681 .items = {
1682 { "Mic", 0x0 },
1683 { "Line", 0x2 },
1684 { "CD", 0x4 },
1685 },
1686 }
1687};
1688
Tony Vroond2fd4b02009-06-21 00:40:10 +01001689static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1690 /* Interal mic only available on one ADC */
1691 {
Tony Vroon684a8842009-06-26 09:27:50 +01001692 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001693 .items = {
1694 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001695 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001696 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001697 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001698 { "Int Mic", 0xb },
1699 },
1700 },
1701 {
Tony Vroon684a8842009-06-26 09:27:50 +01001702 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001703 .items = {
1704 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001705 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001706 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001707 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001708 },
1709 }
1710};
1711
Hector Martin018df412009-06-04 00:13:40 +02001712static struct hda_input_mux alc889_capture_sources[3] = {
1713 /* Digital mic only available on first "ADC" */
1714 {
1715 .num_items = 5,
1716 .items = {
1717 { "Mic", 0x0 },
1718 { "Line", 0x2 },
1719 { "CD", 0x4 },
1720 { "Front Mic", 0xb },
1721 { "Input Mix", 0xa },
1722 },
1723 },
1724 {
1725 .num_items = 4,
1726 .items = {
1727 { "Mic", 0x0 },
1728 { "Line", 0x2 },
1729 { "CD", 0x4 },
1730 { "Input Mix", 0xa },
1731 },
1732 },
1733 {
1734 .num_items = 4,
1735 .items = {
1736 { "Mic", 0x0 },
1737 { "Line", 0x2 },
1738 { "CD", 0x4 },
1739 { "Input Mix", 0xa },
1740 },
1741 }
1742};
1743
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001744static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001745 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1746 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1748 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1749 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1750 HDA_OUTPUT),
1751 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1752 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1753 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1754 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1755 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1758 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1759 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001763 { } /* end */
1764};
1765
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001766static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001767{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001768 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001769
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001770 spec->autocfg.hp_pins[0] = 0x15;
1771 spec->autocfg.speaker_pins[0] = 0x14;
1772 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001773}
1774
Emilio López320d5922009-06-25 08:18:44 +02001775static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1776{
1777 struct alc_spec *spec = codec->spec;
1778
1779 spec->autocfg.hp_pins[0] = 0x15;
1780 spec->autocfg.speaker_pins[0] = 0x14;
1781 spec->autocfg.speaker_pins[1] = 0x16;
1782 spec->autocfg.speaker_pins[2] = 0x17;
1783 alc_automute_amp(codec);
1784}
1785
Hector Martin018df412009-06-04 00:13:40 +02001786static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001787{
1788 struct alc_spec *spec = codec->spec;
1789
1790 spec->autocfg.hp_pins[0] = 0x15;
1791 spec->autocfg.speaker_pins[0] = 0x14;
1792 spec->autocfg.speaker_pins[1] = 0x16;
1793 spec->autocfg.speaker_pins[2] = 0x1b;
1794 alc_automute_amp(codec);
1795}
1796
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001797/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001798 * ALC880 3-stack model
1799 *
1800 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001801 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1802 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803 */
1804
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001805static hda_nid_t alc880_dac_nids[4] = {
1806 /* front, rear, clfe, rear_surr */
1807 0x02, 0x05, 0x04, 0x03
1808};
1809
1810static hda_nid_t alc880_adc_nids[3] = {
1811 /* ADC0-2 */
1812 0x07, 0x08, 0x09,
1813};
1814
1815/* The datasheet says the node 0x07 is connected from inputs,
1816 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001817 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001819static hda_nid_t alc880_adc_nids_alt[2] = {
1820 /* ADC1-2 */
1821 0x08, 0x09,
1822};
1823
1824#define ALC880_DIGOUT_NID 0x06
1825#define ALC880_DIGIN_NID 0x0a
1826
1827static struct hda_input_mux alc880_capture_source = {
1828 .num_items = 4,
1829 .items = {
1830 { "Mic", 0x0 },
1831 { "Front Mic", 0x3 },
1832 { "Line", 0x2 },
1833 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001835};
1836
1837/* channel source setting (2/6 channel selection for 3-stack) */
1838/* 2ch mode */
1839static struct hda_verb alc880_threestack_ch2_init[] = {
1840 /* set line-in to input, mute it */
1841 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1842 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1843 /* set mic-in to input vref 80%, mute it */
1844 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1845 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 { } /* end */
1847};
1848
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001849/* 6ch mode */
1850static struct hda_verb alc880_threestack_ch6_init[] = {
1851 /* set line-in to output, unmute it */
1852 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1853 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1854 /* set mic-in to output, unmute it */
1855 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1856 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1857 { } /* end */
1858};
1859
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001860static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861 { 2, alc880_threestack_ch2_init },
1862 { 6, alc880_threestack_ch6_init },
1863};
1864
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001865static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001867 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001869 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1871 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1873 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1880 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001883 {
1884 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1885 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001886 .info = alc_ch_mode_info,
1887 .get = alc_ch_mode_get,
1888 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001889 },
1890 { } /* end */
1891};
1892
1893/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001894static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1895 struct snd_ctl_elem_info *uinfo)
1896{
1897 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1898 struct alc_spec *spec = codec->spec;
1899 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001900
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001901 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001902 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1903 HDA_INPUT);
1904 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001905 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001906 return err;
1907}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001909static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1910 unsigned int size, unsigned int __user *tlv)
1911{
1912 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1913 struct alc_spec *spec = codec->spec;
1914 int err;
1915
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001916 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001917 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1918 HDA_INPUT);
1919 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001920 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001921 return err;
1922}
1923
1924typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1925 struct snd_ctl_elem_value *ucontrol);
1926
1927static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1928 struct snd_ctl_elem_value *ucontrol,
1929 getput_call_t func)
1930{
1931 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1932 struct alc_spec *spec = codec->spec;
1933 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1934 int err;
1935
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001936 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001937 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1938 3, 0, HDA_INPUT);
1939 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001940 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001941 return err;
1942}
1943
1944static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1945 struct snd_ctl_elem_value *ucontrol)
1946{
1947 return alc_cap_getput_caller(kcontrol, ucontrol,
1948 snd_hda_mixer_amp_volume_get);
1949}
1950
1951static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1952 struct snd_ctl_elem_value *ucontrol)
1953{
1954 return alc_cap_getput_caller(kcontrol, ucontrol,
1955 snd_hda_mixer_amp_volume_put);
1956}
1957
1958/* capture mixer elements */
1959#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1960
1961static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1962 struct snd_ctl_elem_value *ucontrol)
1963{
1964 return alc_cap_getput_caller(kcontrol, ucontrol,
1965 snd_hda_mixer_amp_switch_get);
1966}
1967
1968static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1969 struct snd_ctl_elem_value *ucontrol)
1970{
1971 return alc_cap_getput_caller(kcontrol, ucontrol,
1972 snd_hda_mixer_amp_switch_put);
1973}
1974
Takashi Iwaia23b6882009-03-23 15:21:36 +01001975#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001976 { \
1977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1978 .name = "Capture Switch", \
1979 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1980 .count = num, \
1981 .info = alc_cap_sw_info, \
1982 .get = alc_cap_sw_get, \
1983 .put = alc_cap_sw_put, \
1984 }, \
1985 { \
1986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1987 .name = "Capture Volume", \
1988 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1989 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1990 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1991 .count = num, \
1992 .info = alc_cap_vol_info, \
1993 .get = alc_cap_vol_get, \
1994 .put = alc_cap_vol_put, \
1995 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01001996 }
1997
1998#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001999 { \
2000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2001 /* .name = "Capture Source", */ \
2002 .name = "Input Source", \
2003 .count = num, \
2004 .info = alc_mux_enum_info, \
2005 .get = alc_mux_enum_get, \
2006 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002007 }
2008
2009#define DEFINE_CAPMIX(num) \
2010static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2011 _DEFINE_CAPMIX(num), \
2012 _DEFINE_CAPSRC(num), \
2013 { } /* end */ \
2014}
2015
2016#define DEFINE_CAPMIX_NOSRC(num) \
2017static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2018 _DEFINE_CAPMIX(num), \
2019 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002020}
2021
2022/* up to three ADCs */
2023DEFINE_CAPMIX(1);
2024DEFINE_CAPMIX(2);
2025DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002026DEFINE_CAPMIX_NOSRC(1);
2027DEFINE_CAPMIX_NOSRC(2);
2028DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002029
2030/*
2031 * ALC880 5-stack model
2032 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002033 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2034 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002035 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2036 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2037 */
2038
2039/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002040static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002041 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002042 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043 { } /* end */
2044};
2045
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002046/* channel source setting (6/8 channel selection for 5-stack) */
2047/* 6ch mode */
2048static struct hda_verb alc880_fivestack_ch6_init[] = {
2049 /* set line-in to input, mute it */
2050 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2051 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002052 { } /* end */
2053};
2054
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055/* 8ch mode */
2056static struct hda_verb alc880_fivestack_ch8_init[] = {
2057 /* set line-in to output, unmute it */
2058 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2059 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2060 { } /* end */
2061};
2062
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002063static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002064 { 6, alc880_fivestack_ch6_init },
2065 { 8, alc880_fivestack_ch8_init },
2066};
2067
2068
2069/*
2070 * ALC880 6-stack model
2071 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002072 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2073 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002074 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2075 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2076 */
2077
2078static hda_nid_t alc880_6st_dac_nids[4] = {
2079 /* front, rear, clfe, rear_surr */
2080 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002081};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002082
2083static struct hda_input_mux alc880_6stack_capture_source = {
2084 .num_items = 4,
2085 .items = {
2086 { "Mic", 0x0 },
2087 { "Front Mic", 0x1 },
2088 { "Line", 0x2 },
2089 { "CD", 0x4 },
2090 },
2091};
2092
2093/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002094static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 { 8, NULL },
2096};
2097
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002098static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002099 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002100 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002101 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002102 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002103 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2104 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002105 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2106 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002107 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002108 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002109 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2115 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2116 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 {
2118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2119 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002120 .info = alc_ch_mode_info,
2121 .get = alc_ch_mode_get,
2122 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002123 },
2124 { } /* end */
2125};
2126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002127
2128/*
2129 * ALC880 W810 model
2130 *
2131 * W810 has rear IO for:
2132 * Front (DAC 02)
2133 * Surround (DAC 03)
2134 * Center/LFE (DAC 04)
2135 * Digital out (06)
2136 *
2137 * The system also has a pair of internal speakers, and a headphone jack.
2138 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002139 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002140 * There is a variable resistor to control the speaker or headphone
2141 * volume. This is a hardware-only device without a software API.
2142 *
2143 * Plugging headphones in will disable the internal speakers. This is
2144 * implemented in hardware, not via the driver using jack sense. In
2145 * a similar fashion, plugging into the rear socket marked "front" will
2146 * disable both the speakers and headphones.
2147 *
2148 * For input, there's a microphone jack, and an "audio in" jack.
2149 * These may not do anything useful with this driver yet, because I
2150 * haven't setup any initialization verbs for these yet...
2151 */
2152
2153static hda_nid_t alc880_w810_dac_nids[3] = {
2154 /* front, rear/surround, clfe */
2155 0x02, 0x03, 0x04
2156};
2157
2158/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002159static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002160 { 6, NULL }
2161};
2162
2163/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002164static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002165 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002166 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002167 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002168 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2170 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002171 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2172 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002173 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2174 { } /* end */
2175};
2176
2177
2178/*
2179 * Z710V model
2180 *
2181 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002182 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2183 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002184 */
2185
2186static hda_nid_t alc880_z71v_dac_nids[1] = {
2187 0x02
2188};
2189#define ALC880_Z71V_HP_DAC 0x03
2190
2191/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002192static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002193 { 2, NULL }
2194};
2195
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002196static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002197 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002198 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002199 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002200 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002201 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2202 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2203 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2204 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2205 { } /* end */
2206};
2207
2208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209/*
2210 * ALC880 F1734 model
2211 *
2212 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2213 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2214 */
2215
2216static hda_nid_t alc880_f1734_dac_nids[1] = {
2217 0x03
2218};
2219#define ALC880_F1734_HP_DAC 0x02
2220
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002221static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002222 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002223 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002224 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2225 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002226 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2227 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002230 { } /* end */
2231};
2232
Takashi Iwai937b4162008-02-11 14:52:36 +01002233static struct hda_input_mux alc880_f1734_capture_source = {
2234 .num_items = 2,
2235 .items = {
2236 { "Mic", 0x1 },
2237 { "CD", 0x4 },
2238 },
2239};
2240
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002242/*
2243 * ALC880 ASUS model
2244 *
2245 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2246 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2247 * Mic = 0x18, Line = 0x1a
2248 */
2249
2250#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2251#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2252
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002253static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002254 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002255 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002256 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002257 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002258 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2259 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002260 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2261 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002262 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2263 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2264 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2265 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2266 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2267 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 {
2269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2270 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002271 .info = alc_ch_mode_info,
2272 .get = alc_ch_mode_get,
2273 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002274 },
2275 { } /* end */
2276};
2277
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002278/*
2279 * ALC880 ASUS W1V model
2280 *
2281 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2282 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2283 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2284 */
2285
2286/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002287static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002288 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2289 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002290 { } /* end */
2291};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002292
Kailang Yangdf694da2005-12-05 19:42:22 +01002293/* TCL S700 */
2294static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2295 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2296 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2297 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2298 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2299 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2301 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2302 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2303 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002304 { } /* end */
2305};
2306
Kailang Yangccc656c2006-10-17 12:32:26 +02002307/* Uniwill */
2308static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002309 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2310 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2311 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2312 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002313 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2314 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2315 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2316 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2317 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2318 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2319 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2320 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2321 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2322 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2323 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2324 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002325 {
2326 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2327 .name = "Channel Mode",
2328 .info = alc_ch_mode_info,
2329 .get = alc_ch_mode_get,
2330 .put = alc_ch_mode_put,
2331 },
2332 { } /* end */
2333};
2334
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002335static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2336 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2337 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2338 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2339 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2340 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2341 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2342 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2343 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2344 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2345 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2346 { } /* end */
2347};
2348
Kailang Yangccc656c2006-10-17 12:32:26 +02002349static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002350 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2351 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2356 { } /* end */
2357};
2358
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002360 * virtual master controls
2361 */
2362
2363/*
2364 * slave controls for virtual master
2365 */
2366static const char *alc_slave_vols[] = {
2367 "Front Playback Volume",
2368 "Surround Playback Volume",
2369 "Center Playback Volume",
2370 "LFE Playback Volume",
2371 "Side Playback Volume",
2372 "Headphone Playback Volume",
2373 "Speaker Playback Volume",
2374 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002375 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002376 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002377 NULL,
2378};
2379
2380static const char *alc_slave_sws[] = {
2381 "Front Playback Switch",
2382 "Surround Playback Switch",
2383 "Center Playback Switch",
2384 "LFE Playback Switch",
2385 "Side Playback Switch",
2386 "Headphone Playback Switch",
2387 "Speaker Playback Switch",
2388 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002389 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002390 NULL,
2391};
2392
2393/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002394 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002396
2397static void alc_free_kctls(struct hda_codec *codec);
2398
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002399/* additional beep mixers; the actual parameters are overwritten at build */
2400static struct snd_kcontrol_new alc_beep_mixer[] = {
2401 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2402 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2403 { } /* end */
2404};
2405
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406static int alc_build_controls(struct hda_codec *codec)
2407{
2408 struct alc_spec *spec = codec->spec;
2409 int err;
2410 int i;
2411
2412 for (i = 0; i < spec->num_mixers; i++) {
2413 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2414 if (err < 0)
2415 return err;
2416 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002417 if (spec->cap_mixer) {
2418 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2419 if (err < 0)
2420 return err;
2421 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002423 err = snd_hda_create_spdif_out_ctls(codec,
2424 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 if (err < 0)
2426 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002427 if (!spec->no_analog) {
2428 err = snd_hda_create_spdif_share_sw(codec,
2429 &spec->multiout);
2430 if (err < 0)
2431 return err;
2432 spec->multiout.share_spdif = 1;
2433 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 }
2435 if (spec->dig_in_nid) {
2436 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2437 if (err < 0)
2438 return err;
2439 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002440
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002441 /* create beep controls if needed */
2442 if (spec->beep_amp) {
2443 struct snd_kcontrol_new *knew;
2444 for (knew = alc_beep_mixer; knew->name; knew++) {
2445 struct snd_kcontrol *kctl;
2446 kctl = snd_ctl_new1(knew, codec);
2447 if (!kctl)
2448 return -ENOMEM;
2449 kctl->private_value = spec->beep_amp;
2450 err = snd_hda_ctl_add(codec, kctl);
2451 if (err < 0)
2452 return err;
2453 }
2454 }
2455
Takashi Iwai2134ea42008-01-10 16:53:55 +01002456 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002457 if (!spec->no_analog &&
2458 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002459 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002460 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002461 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002462 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002463 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002464 if (err < 0)
2465 return err;
2466 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002467 if (!spec->no_analog &&
2468 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002469 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2470 NULL, alc_slave_sws);
2471 if (err < 0)
2472 return err;
2473 }
2474
Takashi Iwai603c4012008-07-30 15:01:44 +02002475 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 return 0;
2477}
2478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002479
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480/*
2481 * initialize the codec volumes, etc
2482 */
2483
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002484/*
2485 * generic initialization of ADC, input mixers and output mixers
2486 */
2487static struct hda_verb alc880_volume_init_verbs[] = {
2488 /*
2489 * Unmute ADC0-2 and set the default input to mic-in
2490 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002491 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002493 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002495 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002498 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2499 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002500 * Note: PASD motherboards uses the Line In 2 as the input for front
2501 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002503 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002504 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2505 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512 /*
2513 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 /* set vol=0 to output mixers */
2516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2520 /* set up input amps for analog loopback */
2521 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002524 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2525 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002526 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2527 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002528 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530
2531 { }
2532};
2533
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002534/*
2535 * 3-stack pin configuration:
2536 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2537 */
2538static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2539 /*
2540 * preset connection lists of input pins
2541 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2542 */
2543 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2544 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2545 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2546
2547 /*
2548 * Set pin mode and muting
2549 */
2550 /* set front pin widgets 0x14 for output */
2551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2552 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2553 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2554 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2555 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2556 /* Mic2 (as headphone out) for HP output */
2557 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2558 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2559 /* Line In pin widget for input */
2560 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2561 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2562 /* Line2 (as front mic) pin widget for input and vref at 80% */
2563 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2564 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2565 /* CD pin widget for input */
2566 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2567
2568 { }
2569};
2570
2571/*
2572 * 5-stack pin configuration:
2573 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2574 * line-in/side = 0x1a, f-mic = 0x1b
2575 */
2576static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2577 /*
2578 * preset connection lists of input pins
2579 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2580 */
2581 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2582 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2583
2584 /*
2585 * Set pin mode and muting
2586 */
2587 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2590 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2591 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002592 /* unmute pins for output (no gain on this amp) */
2593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2594 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2595 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2596 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2597
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002599 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002600 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2601 /* Mic2 (as headphone out) for HP output */
2602 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002603 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002604 /* Line In pin widget for input */
2605 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2606 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2607 /* Line2 (as front mic) pin widget for input and vref at 80% */
2608 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2609 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2610 /* CD pin widget for input */
2611 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612
2613 { }
2614};
2615
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002616/*
2617 * W810 pin configuration:
2618 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2619 */
2620static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621 /* hphone/speaker input selector: front DAC */
2622 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2623
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2625 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2628 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2630
2631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 { }
2635};
2636
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002637/*
2638 * Z71V pin configuration:
2639 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2640 */
2641static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002646
Takashi Iwai16ded522005-06-10 19:58:24 +02002647 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002650 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002651
2652 { }
2653};
2654
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655/*
2656 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002657 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2658 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002659 */
2660static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2661 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2662
Takashi Iwai16ded522005-06-10 19:58:24 +02002663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002665 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002666 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002669 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2671
Takashi Iwai16ded522005-06-10 19:58:24 +02002672 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002674 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002675 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002676 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002678 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002680 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002681
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002682 { }
2683};
Takashi Iwai16ded522005-06-10 19:58:24 +02002684
Kailang Yangccc656c2006-10-17 12:32:26 +02002685/*
2686 * Uniwill pin configuration:
2687 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2688 * line = 0x1a
2689 */
2690static struct hda_verb alc880_uniwill_init_verbs[] = {
2691 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2692
2693 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2694 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2695 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2696 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2697 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2698 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2699 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2701 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2702 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2703 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2704 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2705 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2706 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2707
2708 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2709 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2710 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2711 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2714 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2715 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2716 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2717
2718 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2719 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2720
2721 { }
2722};
2723
2724/*
2725* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002726* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002727 */
2728static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2729 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2730
2731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2733 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2734 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2736 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2737 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2738 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2739 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2740 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2741 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2743
2744 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2745 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2746 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2747 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2748 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2749 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2750
2751 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2752 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2753
2754 { }
2755};
2756
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002757static struct hda_verb alc880_beep_init_verbs[] = {
2758 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2759 { }
2760};
2761
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002762/* auto-toggle front mic */
2763static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2764{
2765 unsigned int present;
2766 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002767
2768 present = snd_hda_codec_read(codec, 0x18, 0,
2769 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002770 bits = present ? HDA_AMP_MUTE : 0;
2771 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002772}
2773
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002774static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002775{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002776 struct alc_spec *spec = codec->spec;
2777
2778 spec->autocfg.hp_pins[0] = 0x14;
2779 spec->autocfg.speaker_pins[0] = 0x15;
2780 spec->autocfg.speaker_pins[0] = 0x16;
2781 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002782 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002783}
2784
2785static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2786 unsigned int res)
2787{
2788 /* Looks like the unsol event is incompatible with the standard
2789 * definition. 4bit tag is placed at 28 bit!
2790 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002791 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002792 case ALC880_MIC_EVENT:
2793 alc880_uniwill_mic_automute(codec);
2794 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002795 default:
2796 alc_automute_amp_unsol_event(codec, res);
2797 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002798 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002799}
2800
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002801static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002803 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002804
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002805 spec->autocfg.hp_pins[0] = 0x14;
2806 spec->autocfg.speaker_pins[0] = 0x15;
2807 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002808}
2809
2810static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2811{
2812 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002813
Kailang Yangccc656c2006-10-17 12:32:26 +02002814 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002815 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2816 present &= HDA_AMP_VOLMASK;
2817 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2818 HDA_AMP_VOLMASK, present);
2819 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2820 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002821}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002822
Kailang Yangccc656c2006-10-17 12:32:26 +02002823static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2824 unsigned int res)
2825{
2826 /* Looks like the unsol event is incompatible with the standard
2827 * definition. 4bit tag is placed at 28 bit!
2828 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002829 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002830 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002831 else
2832 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002833}
2834
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002835/*
2836 * F1734 pin configuration:
2837 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2838 */
2839static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002840 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002841 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2842 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2843 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2844 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2845
2846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2849 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2850
2851 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002853 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002854 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2855 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2859 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002860
Takashi Iwai937b4162008-02-11 14:52:36 +01002861 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2862 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2863
Takashi Iwai16ded522005-06-10 19:58:24 +02002864 { }
2865};
2866
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002867/*
2868 * ASUS pin configuration:
2869 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2870 */
2871static struct hda_verb alc880_pin_asus_init_verbs[] = {
2872 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2873 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2874 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2875 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2876
2877 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2878 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2880 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2885
2886 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2887 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2888 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2891 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2892 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2893 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2894 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002895
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002896 { }
2897};
2898
2899/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002900#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2901#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002902#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002903
Kailang Yangdf694da2005-12-05 19:42:22 +01002904/* Clevo m520g init */
2905static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2906 /* headphone output */
2907 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2908 /* line-out */
2909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2911 /* Line-in */
2912 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2913 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2914 /* CD */
2915 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2916 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2917 /* Mic1 (rear panel) */
2918 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2919 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 /* Mic2 (front panel) */
2921 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2922 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2923 /* headphone */
2924 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 /* change to EAPD mode */
2927 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2928 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2929
2930 { }
2931};
2932
2933static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002934 /* change to EAPD mode */
2935 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2936 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2937
Kailang Yangdf694da2005-12-05 19:42:22 +01002938 /* Headphone output */
2939 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2940 /* Front output*/
2941 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2943
2944 /* Line In pin widget for input */
2945 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2946 /* CD pin widget for input */
2947 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2948 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2950
2951 /* change to EAPD mode */
2952 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2953 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2954
2955 { }
2956};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002957
2958/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002959 * LG m1 express dual
2960 *
2961 * Pin assignment:
2962 * Rear Line-In/Out (blue): 0x14
2963 * Build-in Mic-In: 0x15
2964 * Speaker-out: 0x17
2965 * HP-Out (green): 0x1b
2966 * Mic-In/Out (red): 0x19
2967 * SPDIF-Out: 0x1e
2968 */
2969
2970/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2971static hda_nid_t alc880_lg_dac_nids[3] = {
2972 0x05, 0x02, 0x03
2973};
2974
2975/* seems analog CD is not working */
2976static struct hda_input_mux alc880_lg_capture_source = {
2977 .num_items = 3,
2978 .items = {
2979 { "Mic", 0x1 },
2980 { "Line", 0x5 },
2981 { "Internal Mic", 0x6 },
2982 },
2983};
2984
2985/* 2,4,6 channel modes */
2986static struct hda_verb alc880_lg_ch2_init[] = {
2987 /* set line-in and mic-in to input */
2988 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2989 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2990 { }
2991};
2992
2993static struct hda_verb alc880_lg_ch4_init[] = {
2994 /* set line-in to out and mic-in to input */
2995 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2996 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2997 { }
2998};
2999
3000static struct hda_verb alc880_lg_ch6_init[] = {
3001 /* set line-in and mic-in to output */
3002 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3003 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3004 { }
3005};
3006
3007static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3008 { 2, alc880_lg_ch2_init },
3009 { 4, alc880_lg_ch4_init },
3010 { 6, alc880_lg_ch6_init },
3011};
3012
3013static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003014 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3015 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003016 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3017 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3018 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3019 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3020 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3021 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3024 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3025 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3026 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3027 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3028 {
3029 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3030 .name = "Channel Mode",
3031 .info = alc_ch_mode_info,
3032 .get = alc_ch_mode_get,
3033 .put = alc_ch_mode_put,
3034 },
3035 { } /* end */
3036};
3037
3038static struct hda_verb alc880_lg_init_verbs[] = {
3039 /* set capture source to mic-in */
3040 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3043 /* mute all amp mixer inputs */
3044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003047 /* line-in to input */
3048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3050 /* built-in mic */
3051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3052 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3053 /* speaker-out */
3054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 /* mic-in to input */
3057 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3058 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3059 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 /* HP-out */
3061 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3062 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3063 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003066 { }
3067};
3068
3069/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003070static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003071{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003072 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003073
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003074 spec->autocfg.hp_pins[0] = 0x1b;
3075 spec->autocfg.speaker_pins[0] = 0x17;
3076 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003077}
3078
3079/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003080 * LG LW20
3081 *
3082 * Pin assignment:
3083 * Speaker-out: 0x14
3084 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003085 * Built-in Mic-In: 0x19
3086 * Line-In: 0x1b
3087 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003088 * SPDIF-Out: 0x1e
3089 */
3090
Takashi Iwaid6815182006-03-23 16:06:23 +01003091static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003092 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003093 .items = {
3094 { "Mic", 0x0 },
3095 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003096 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003097 },
3098};
3099
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003100#define alc880_lg_lw_modes alc880_threestack_modes
3101
Takashi Iwaid6815182006-03-23 16:06:23 +01003102static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003103 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3104 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3105 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3106 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3107 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3108 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3109 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3110 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003113 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3115 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3116 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003117 {
3118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3119 .name = "Channel Mode",
3120 .info = alc_ch_mode_info,
3121 .get = alc_ch_mode_get,
3122 .put = alc_ch_mode_put,
3123 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003124 { } /* end */
3125};
3126
3127static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003128 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3129 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3130 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3131
Takashi Iwaid6815182006-03-23 16:06:23 +01003132 /* set capture source to mic-in */
3133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3134 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003136 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003137 /* speaker-out */
3138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3139 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3140 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003141 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3142 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3143 /* mic-in to input */
3144 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* built-in mic */
3147 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3149 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003150 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003151 { }
3152};
3153
3154/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003155static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003156{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003157 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003158
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003159 spec->autocfg.hp_pins[0] = 0x1b;
3160 spec->autocfg.speaker_pins[0] = 0x14;
3161 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003162}
3163
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003164static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3165 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3166 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3169 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3170 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3171 { } /* end */
3172};
3173
3174static struct hda_input_mux alc880_medion_rim_capture_source = {
3175 .num_items = 2,
3176 .items = {
3177 { "Mic", 0x0 },
3178 { "Internal Mic", 0x1 },
3179 },
3180};
3181
3182static struct hda_verb alc880_medion_rim_init_verbs[] = {
3183 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3184
3185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187
3188 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3189 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3190 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3191 /* Mic2 (as headphone out) for HP output */
3192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3194 /* Internal Speaker */
3195 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3196 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3197
3198 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3199 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3200
3201 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3202 { }
3203};
3204
3205/* toggle speaker-output according to the hp-jack state */
3206static void alc880_medion_rim_automute(struct hda_codec *codec)
3207{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003208 struct alc_spec *spec = codec->spec;
3209 alc_automute_amp(codec);
3210 /* toggle EAPD */
3211 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003212 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3213 else
3214 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3215}
3216
3217static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3218 unsigned int res)
3219{
3220 /* Looks like the unsol event is incompatible with the standard
3221 * definition. 4bit tag is placed at 28 bit!
3222 */
3223 if ((res >> 28) == ALC880_HP_EVENT)
3224 alc880_medion_rim_automute(codec);
3225}
3226
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003227static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3228{
3229 struct alc_spec *spec = codec->spec;
3230
3231 spec->autocfg.hp_pins[0] = 0x14;
3232 spec->autocfg.speaker_pins[0] = 0x1b;
3233 alc880_medion_rim_automute(codec);
3234}
3235
Takashi Iwaicb53c622007-08-10 17:21:45 +02003236#ifdef CONFIG_SND_HDA_POWER_SAVE
3237static struct hda_amp_list alc880_loopbacks[] = {
3238 { 0x0b, HDA_INPUT, 0 },
3239 { 0x0b, HDA_INPUT, 1 },
3240 { 0x0b, HDA_INPUT, 2 },
3241 { 0x0b, HDA_INPUT, 3 },
3242 { 0x0b, HDA_INPUT, 4 },
3243 { } /* end */
3244};
3245
3246static struct hda_amp_list alc880_lg_loopbacks[] = {
3247 { 0x0b, HDA_INPUT, 1 },
3248 { 0x0b, HDA_INPUT, 6 },
3249 { 0x0b, HDA_INPUT, 7 },
3250 { } /* end */
3251};
3252#endif
3253
Takashi Iwaid6815182006-03-23 16:06:23 +01003254/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003255 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003257
Linus Torvalds1da177e2005-04-16 15:20:36 -07003258static int alc_init(struct hda_codec *codec)
3259{
3260 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 unsigned int i;
3262
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003263 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003264 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003265
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 for (i = 0; i < spec->num_init_verbs; i++)
3267 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003268
3269 if (spec->init_hook)
3270 spec->init_hook(codec);
3271
Linus Torvalds1da177e2005-04-16 15:20:36 -07003272 return 0;
3273}
3274
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003275static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3276{
3277 struct alc_spec *spec = codec->spec;
3278
3279 if (spec->unsol_event)
3280 spec->unsol_event(codec, res);
3281}
3282
Takashi Iwaicb53c622007-08-10 17:21:45 +02003283#ifdef CONFIG_SND_HDA_POWER_SAVE
3284static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3285{
3286 struct alc_spec *spec = codec->spec;
3287 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3288}
3289#endif
3290
Linus Torvalds1da177e2005-04-16 15:20:36 -07003291/*
3292 * Analog playback callbacks
3293 */
3294static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3295 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003296 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003297{
3298 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003299 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3300 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003301}
3302
3303static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3304 struct hda_codec *codec,
3305 unsigned int stream_tag,
3306 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003307 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003308{
3309 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003310 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3311 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003312}
3313
3314static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3315 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003316 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003317{
3318 struct alc_spec *spec = codec->spec;
3319 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3320}
3321
3322/*
3323 * Digital out
3324 */
3325static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3326 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003327 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003328{
3329 struct alc_spec *spec = codec->spec;
3330 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3331}
3332
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003333static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3334 struct hda_codec *codec,
3335 unsigned int stream_tag,
3336 unsigned int format,
3337 struct snd_pcm_substream *substream)
3338{
3339 struct alc_spec *spec = codec->spec;
3340 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3341 stream_tag, format, substream);
3342}
3343
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003344static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3345 struct hda_codec *codec,
3346 struct snd_pcm_substream *substream)
3347{
3348 struct alc_spec *spec = codec->spec;
3349 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3350}
3351
Linus Torvalds1da177e2005-04-16 15:20:36 -07003352static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3353 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003354 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003355{
3356 struct alc_spec *spec = codec->spec;
3357 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3358}
3359
3360/*
3361 * Analog capture
3362 */
Takashi Iwai63300792008-01-24 15:31:36 +01003363static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003364 struct hda_codec *codec,
3365 unsigned int stream_tag,
3366 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003367 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003368{
3369 struct alc_spec *spec = codec->spec;
3370
Takashi Iwai63300792008-01-24 15:31:36 +01003371 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372 stream_tag, 0, format);
3373 return 0;
3374}
3375
Takashi Iwai63300792008-01-24 15:31:36 +01003376static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003378 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003379{
3380 struct alc_spec *spec = codec->spec;
3381
Takashi Iwai888afa12008-03-18 09:57:50 +01003382 snd_hda_codec_cleanup_stream(codec,
3383 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003384 return 0;
3385}
3386
3387
3388/*
3389 */
3390static struct hda_pcm_stream alc880_pcm_analog_playback = {
3391 .substreams = 1,
3392 .channels_min = 2,
3393 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003394 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003395 .ops = {
3396 .open = alc880_playback_pcm_open,
3397 .prepare = alc880_playback_pcm_prepare,
3398 .cleanup = alc880_playback_pcm_cleanup
3399 },
3400};
3401
3402static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003403 .substreams = 1,
3404 .channels_min = 2,
3405 .channels_max = 2,
3406 /* NID is set in alc_build_pcms */
3407};
3408
3409static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3410 .substreams = 1,
3411 .channels_min = 2,
3412 .channels_max = 2,
3413 /* NID is set in alc_build_pcms */
3414};
3415
3416static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3417 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003418 .channels_min = 2,
3419 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003420 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003421 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003422 .prepare = alc880_alt_capture_pcm_prepare,
3423 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003424 },
3425};
3426
3427static struct hda_pcm_stream alc880_pcm_digital_playback = {
3428 .substreams = 1,
3429 .channels_min = 2,
3430 .channels_max = 2,
3431 /* NID is set in alc_build_pcms */
3432 .ops = {
3433 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003434 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003435 .prepare = alc880_dig_playback_pcm_prepare,
3436 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437 },
3438};
3439
3440static struct hda_pcm_stream alc880_pcm_digital_capture = {
3441 .substreams = 1,
3442 .channels_min = 2,
3443 .channels_max = 2,
3444 /* NID is set in alc_build_pcms */
3445};
3446
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003447/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003448static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003449 .substreams = 0,
3450 .channels_min = 0,
3451 .channels_max = 0,
3452};
3453
Linus Torvalds1da177e2005-04-16 15:20:36 -07003454static int alc_build_pcms(struct hda_codec *codec)
3455{
3456 struct alc_spec *spec = codec->spec;
3457 struct hda_pcm *info = spec->pcm_rec;
3458 int i;
3459
3460 codec->num_pcms = 1;
3461 codec->pcm_info = info;
3462
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003463 if (spec->no_analog)
3464 goto skip_analog;
3465
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003466 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3467 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003468 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003469
Takashi Iwai4a471b72005-12-07 13:56:29 +01003470 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003471 if (snd_BUG_ON(!spec->multiout.dac_nids))
3472 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003473 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3474 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3475 }
3476 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003477 if (snd_BUG_ON(!spec->adc_nids))
3478 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003479 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3480 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3481 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003482
Takashi Iwai4a471b72005-12-07 13:56:29 +01003483 if (spec->channel_mode) {
3484 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3485 for (i = 0; i < spec->num_channel_mode; i++) {
3486 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3487 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3488 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003489 }
3490 }
3491
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003492 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003493 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003494 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003495 snprintf(spec->stream_name_digital,
3496 sizeof(spec->stream_name_digital),
3497 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003498 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003499 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003500 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003502 if (spec->dig_out_type)
3503 info->pcm_type = spec->dig_out_type;
3504 else
3505 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003506 if (spec->multiout.dig_out_nid &&
3507 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3509 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3510 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003511 if (spec->dig_in_nid &&
3512 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3514 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3515 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003516 /* FIXME: do we need this for all Realtek codec models? */
3517 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518 }
3519
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003520 if (spec->no_analog)
3521 return 0;
3522
Takashi Iwaie08a0072006-09-07 17:52:14 +02003523 /* If the use of more than one ADC is requested for the current
3524 * model, configure a second analog capture-only PCM.
3525 */
3526 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003527 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3528 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003529 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003530 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003531 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003532 if (spec->alt_dac_nid) {
3533 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3534 *spec->stream_analog_alt_playback;
3535 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3536 spec->alt_dac_nid;
3537 } else {
3538 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3539 alc_pcm_null_stream;
3540 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3541 }
3542 if (spec->num_adc_nids > 1) {
3543 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3544 *spec->stream_analog_alt_capture;
3545 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3546 spec->adc_nids[1];
3547 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3548 spec->num_adc_nids - 1;
3549 } else {
3550 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3551 alc_pcm_null_stream;
3552 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003553 }
3554 }
3555
Linus Torvalds1da177e2005-04-16 15:20:36 -07003556 return 0;
3557}
3558
Takashi Iwai603c4012008-07-30 15:01:44 +02003559static void alc_free_kctls(struct hda_codec *codec)
3560{
3561 struct alc_spec *spec = codec->spec;
3562
3563 if (spec->kctls.list) {
3564 struct snd_kcontrol_new *kctl = spec->kctls.list;
3565 int i;
3566 for (i = 0; i < spec->kctls.used; i++)
3567 kfree(kctl[i].name);
3568 }
3569 snd_array_free(&spec->kctls);
3570}
3571
Linus Torvalds1da177e2005-04-16 15:20:36 -07003572static void alc_free(struct hda_codec *codec)
3573{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003576 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003577 return;
3578
Takashi Iwai603c4012008-07-30 15:01:44 +02003579 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003580 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003581 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003582}
3583
Takashi Iwaie044c392008-10-27 16:56:24 +01003584#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003585static int alc_resume(struct hda_codec *codec)
3586{
Takashi Iwaie044c392008-10-27 16:56:24 +01003587 codec->patch_ops.init(codec);
3588 snd_hda_codec_resume_amp(codec);
3589 snd_hda_codec_resume_cache(codec);
3590 return 0;
3591}
Takashi Iwaie044c392008-10-27 16:56:24 +01003592#endif
3593
Linus Torvalds1da177e2005-04-16 15:20:36 -07003594/*
3595 */
3596static struct hda_codec_ops alc_patch_ops = {
3597 .build_controls = alc_build_controls,
3598 .build_pcms = alc_build_pcms,
3599 .init = alc_init,
3600 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003601 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003602#ifdef SND_HDA_NEEDS_RESUME
3603 .resume = alc_resume,
3604#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003605#ifdef CONFIG_SND_HDA_POWER_SAVE
3606 .check_power_status = alc_check_power_status,
3607#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003608};
3609
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003610
3611/*
3612 * Test configuration for debugging
3613 *
3614 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3615 * enum controls.
3616 */
3617#ifdef CONFIG_SND_DEBUG
3618static hda_nid_t alc880_test_dac_nids[4] = {
3619 0x02, 0x03, 0x04, 0x05
3620};
3621
3622static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003623 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003624 .items = {
3625 { "In-1", 0x0 },
3626 { "In-2", 0x1 },
3627 { "In-3", 0x2 },
3628 { "In-4", 0x3 },
3629 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003630 { "Front", 0x5 },
3631 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003632 },
3633};
3634
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003635static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003636 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003637 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003638 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003639 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003640};
3641
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003642static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3643 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003644{
3645 static char *texts[] = {
3646 "N/A", "Line Out", "HP Out",
3647 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3648 };
3649 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3650 uinfo->count = 1;
3651 uinfo->value.enumerated.items = 8;
3652 if (uinfo->value.enumerated.item >= 8)
3653 uinfo->value.enumerated.item = 7;
3654 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3655 return 0;
3656}
3657
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003658static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3659 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003660{
3661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3662 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3663 unsigned int pin_ctl, item = 0;
3664
3665 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3666 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3667 if (pin_ctl & AC_PINCTL_OUT_EN) {
3668 if (pin_ctl & AC_PINCTL_HP_EN)
3669 item = 2;
3670 else
3671 item = 1;
3672 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3673 switch (pin_ctl & AC_PINCTL_VREFEN) {
3674 case AC_PINCTL_VREF_HIZ: item = 3; break;
3675 case AC_PINCTL_VREF_50: item = 4; break;
3676 case AC_PINCTL_VREF_GRD: item = 5; break;
3677 case AC_PINCTL_VREF_80: item = 6; break;
3678 case AC_PINCTL_VREF_100: item = 7; break;
3679 }
3680 }
3681 ucontrol->value.enumerated.item[0] = item;
3682 return 0;
3683}
3684
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003685static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3686 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003687{
3688 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3689 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3690 static unsigned int ctls[] = {
3691 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3692 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3693 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3694 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3695 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3696 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3697 };
3698 unsigned int old_ctl, new_ctl;
3699
3700 old_ctl = snd_hda_codec_read(codec, nid, 0,
3701 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3702 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3703 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003704 int val;
3705 snd_hda_codec_write_cache(codec, nid, 0,
3706 AC_VERB_SET_PIN_WIDGET_CONTROL,
3707 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003708 val = ucontrol->value.enumerated.item[0] >= 3 ?
3709 HDA_AMP_MUTE : 0;
3710 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3711 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003712 return 1;
3713 }
3714 return 0;
3715}
3716
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003717static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3718 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003719{
3720 static char *texts[] = {
3721 "Front", "Surround", "CLFE", "Side"
3722 };
3723 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3724 uinfo->count = 1;
3725 uinfo->value.enumerated.items = 4;
3726 if (uinfo->value.enumerated.item >= 4)
3727 uinfo->value.enumerated.item = 3;
3728 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3729 return 0;
3730}
3731
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003732static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3733 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003734{
3735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3736 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3737 unsigned int sel;
3738
3739 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3740 ucontrol->value.enumerated.item[0] = sel & 3;
3741 return 0;
3742}
3743
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003744static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3745 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003746{
3747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3748 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3749 unsigned int sel;
3750
3751 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3752 if (ucontrol->value.enumerated.item[0] != sel) {
3753 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003754 snd_hda_codec_write_cache(codec, nid, 0,
3755 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003756 return 1;
3757 }
3758 return 0;
3759}
3760
3761#define PIN_CTL_TEST(xname,nid) { \
3762 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3763 .name = xname, \
3764 .info = alc_test_pin_ctl_info, \
3765 .get = alc_test_pin_ctl_get, \
3766 .put = alc_test_pin_ctl_put, \
3767 .private_value = nid \
3768 }
3769
3770#define PIN_SRC_TEST(xname,nid) { \
3771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3772 .name = xname, \
3773 .info = alc_test_pin_src_info, \
3774 .get = alc_test_pin_src_get, \
3775 .put = alc_test_pin_src_put, \
3776 .private_value = nid \
3777 }
3778
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003779static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003780 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3781 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3782 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3783 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003784 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3785 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3786 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3787 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003788 PIN_CTL_TEST("Front Pin Mode", 0x14),
3789 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3790 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3791 PIN_CTL_TEST("Side Pin Mode", 0x17),
3792 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3793 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3794 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3795 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3796 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3797 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3798 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3799 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3800 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3801 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3802 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3803 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3804 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3805 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3806 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3807 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003810 {
3811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3812 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003813 .info = alc_ch_mode_info,
3814 .get = alc_ch_mode_get,
3815 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003816 },
3817 { } /* end */
3818};
3819
3820static struct hda_verb alc880_test_init_verbs[] = {
3821 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003822 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3823 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3824 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3825 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3826 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3827 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3828 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3829 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003830 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3833 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3834 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003835 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3838 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3839 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003840 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003841 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3842 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3843 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3844 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003845 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003846 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3847 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003851 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003852 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3853 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3854 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3855 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003856 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003857 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003858 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003859 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003860 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003861 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003862 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003863 /* Analog input/passthru */
3864 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3865 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3866 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3867 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3868 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003869 { }
3870};
3871#endif
3872
Linus Torvalds1da177e2005-04-16 15:20:36 -07003873/*
3874 */
3875
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003876static const char *alc880_models[ALC880_MODEL_LAST] = {
3877 [ALC880_3ST] = "3stack",
3878 [ALC880_TCL_S700] = "tcl",
3879 [ALC880_3ST_DIG] = "3stack-digout",
3880 [ALC880_CLEVO] = "clevo",
3881 [ALC880_5ST] = "5stack",
3882 [ALC880_5ST_DIG] = "5stack-digout",
3883 [ALC880_W810] = "w810",
3884 [ALC880_Z71V] = "z71v",
3885 [ALC880_6ST] = "6stack",
3886 [ALC880_6ST_DIG] = "6stack-digout",
3887 [ALC880_ASUS] = "asus",
3888 [ALC880_ASUS_W1V] = "asus-w1v",
3889 [ALC880_ASUS_DIG] = "asus-dig",
3890 [ALC880_ASUS_DIG2] = "asus-dig2",
3891 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003892 [ALC880_UNIWILL_P53] = "uniwill-p53",
3893 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003894 [ALC880_F1734] = "F1734",
3895 [ALC880_LG] = "lg",
3896 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003897 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003898#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003899 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003900#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003901 [ALC880_AUTO] = "auto",
3902};
3903
3904static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003905 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003906 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3907 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3908 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3909 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3910 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3911 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3912 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3913 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003914 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3915 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003916 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3917 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3918 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3919 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3920 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3921 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3922 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3923 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3924 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3925 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003926 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003927 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3928 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3929 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003930 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003931 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003932 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3933 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003934 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3935 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003936 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3937 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3938 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3939 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003940 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3941 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003942 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003943 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003944 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003945 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3947 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003948 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003949 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003950 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003951 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003953 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003954 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003955 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003956 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003957 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3958 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003959 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003960 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3961 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3962 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3963 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003964 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3965 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003966 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003967 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003968 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3969 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003970 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3971 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3972 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003973 /* default Intel */
3974 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003975 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3976 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003977 {}
3978};
3979
Takashi Iwai16ded522005-06-10 19:58:24 +02003980/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003981 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003982 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003983static struct alc_config_preset alc880_presets[] = {
3984 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003985 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003986 .init_verbs = { alc880_volume_init_verbs,
3987 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003988 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003989 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003990 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3991 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003992 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003993 .input_mux = &alc880_capture_source,
3994 },
3995 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003996 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003997 .init_verbs = { alc880_volume_init_verbs,
3998 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003999 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 .dac_nids = alc880_dac_nids,
4001 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004002 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4003 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004004 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004005 .input_mux = &alc880_capture_source,
4006 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004007 [ALC880_TCL_S700] = {
4008 .mixers = { alc880_tcl_s700_mixer },
4009 .init_verbs = { alc880_volume_init_verbs,
4010 alc880_pin_tcl_S700_init_verbs,
4011 alc880_gpio2_init_verbs },
4012 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4013 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004014 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4015 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004016 .hp_nid = 0x03,
4017 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4018 .channel_mode = alc880_2_jack_modes,
4019 .input_mux = &alc880_capture_source,
4020 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004022 .mixers = { alc880_three_stack_mixer,
4023 alc880_five_stack_mixer},
4024 .init_verbs = { alc880_volume_init_verbs,
4025 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004026 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4027 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004028 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4029 .channel_mode = alc880_fivestack_modes,
4030 .input_mux = &alc880_capture_source,
4031 },
4032 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004033 .mixers = { alc880_three_stack_mixer,
4034 alc880_five_stack_mixer },
4035 .init_verbs = { alc880_volume_init_verbs,
4036 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004037 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4038 .dac_nids = alc880_dac_nids,
4039 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004040 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4041 .channel_mode = alc880_fivestack_modes,
4042 .input_mux = &alc880_capture_source,
4043 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004044 [ALC880_6ST] = {
4045 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004046 .init_verbs = { alc880_volume_init_verbs,
4047 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004048 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4049 .dac_nids = alc880_6st_dac_nids,
4050 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4051 .channel_mode = alc880_sixstack_modes,
4052 .input_mux = &alc880_6stack_capture_source,
4053 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004054 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004055 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004056 .init_verbs = { alc880_volume_init_verbs,
4057 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004058 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4059 .dac_nids = alc880_6st_dac_nids,
4060 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004061 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4062 .channel_mode = alc880_sixstack_modes,
4063 .input_mux = &alc880_6stack_capture_source,
4064 },
4065 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004066 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004067 .init_verbs = { alc880_volume_init_verbs,
4068 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004069 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004070 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4071 .dac_nids = alc880_w810_dac_nids,
4072 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004073 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4074 .channel_mode = alc880_w810_modes,
4075 .input_mux = &alc880_capture_source,
4076 },
4077 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079 .init_verbs = { alc880_volume_init_verbs,
4080 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004081 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4082 .dac_nids = alc880_z71v_dac_nids,
4083 .dig_out_nid = ALC880_DIGOUT_NID,
4084 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004085 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4086 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004087 .input_mux = &alc880_capture_source,
4088 },
4089 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004090 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004091 .init_verbs = { alc880_volume_init_verbs,
4092 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004093 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4094 .dac_nids = alc880_f1734_dac_nids,
4095 .hp_nid = 0x02,
4096 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4097 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004098 .input_mux = &alc880_f1734_capture_source,
4099 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004100 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02004101 },
4102 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004104 .init_verbs = { alc880_volume_init_verbs,
4105 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004106 alc880_gpio1_init_verbs },
4107 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4108 .dac_nids = alc880_asus_dac_nids,
4109 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4110 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004111 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004112 .input_mux = &alc880_capture_source,
4113 },
4114 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004116 .init_verbs = { alc880_volume_init_verbs,
4117 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004118 alc880_gpio1_init_verbs },
4119 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4120 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004121 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004122 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4123 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004124 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004125 .input_mux = &alc880_capture_source,
4126 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004127 [ALC880_ASUS_DIG2] = {
4128 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004129 .init_verbs = { alc880_volume_init_verbs,
4130 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004131 alc880_gpio2_init_verbs }, /* use GPIO2 */
4132 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4133 .dac_nids = alc880_asus_dac_nids,
4134 .dig_out_nid = ALC880_DIGOUT_NID,
4135 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4136 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004137 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004138 .input_mux = &alc880_capture_source,
4139 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004140 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004141 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004142 .init_verbs = { alc880_volume_init_verbs,
4143 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004144 alc880_gpio1_init_verbs },
4145 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4146 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004147 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004148 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4149 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004150 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004151 .input_mux = &alc880_capture_source,
4152 },
4153 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004154 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004155 .init_verbs = { alc880_volume_init_verbs,
4156 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4158 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004159 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4161 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004162 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 .input_mux = &alc880_capture_source,
4164 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004165 [ALC880_UNIWILL] = {
4166 .mixers = { alc880_uniwill_mixer },
4167 .init_verbs = { alc880_volume_init_verbs,
4168 alc880_uniwill_init_verbs },
4169 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4170 .dac_nids = alc880_asus_dac_nids,
4171 .dig_out_nid = ALC880_DIGOUT_NID,
4172 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4173 .channel_mode = alc880_threestack_modes,
4174 .need_dac_fix = 1,
4175 .input_mux = &alc880_capture_source,
4176 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004177 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004178 },
4179 [ALC880_UNIWILL_P53] = {
4180 .mixers = { alc880_uniwill_p53_mixer },
4181 .init_verbs = { alc880_volume_init_verbs,
4182 alc880_uniwill_p53_init_verbs },
4183 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4184 .dac_nids = alc880_asus_dac_nids,
4185 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004186 .channel_mode = alc880_threestack_modes,
4187 .input_mux = &alc880_capture_source,
4188 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004189 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004190 },
4191 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004192 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004193 .init_verbs = { alc880_volume_init_verbs,
4194 alc880_uniwill_p53_init_verbs,
4195 alc880_beep_init_verbs },
4196 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4197 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004198 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004199 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4200 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004201 .input_mux = &alc880_capture_source,
4202 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004203 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004204 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004205 [ALC880_CLEVO] = {
4206 .mixers = { alc880_three_stack_mixer },
4207 .init_verbs = { alc880_volume_init_verbs,
4208 alc880_pin_clevo_init_verbs },
4209 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4210 .dac_nids = alc880_dac_nids,
4211 .hp_nid = 0x03,
4212 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4213 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004214 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004215 .input_mux = &alc880_capture_source,
4216 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004217 [ALC880_LG] = {
4218 .mixers = { alc880_lg_mixer },
4219 .init_verbs = { alc880_volume_init_verbs,
4220 alc880_lg_init_verbs },
4221 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4222 .dac_nids = alc880_lg_dac_nids,
4223 .dig_out_nid = ALC880_DIGOUT_NID,
4224 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4225 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004226 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004227 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004228 .unsol_event = alc_automute_amp_unsol_event,
4229 .init_hook = alc880_lg_init_hook,
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,
4245 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004246 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004247 [ALC880_MEDION_RIM] = {
4248 .mixers = { alc880_medion_rim_mixer },
4249 .init_verbs = { alc880_volume_init_verbs,
4250 alc880_medion_rim_init_verbs,
4251 alc_gpio2_init_verbs },
4252 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4253 .dac_nids = alc880_dac_nids,
4254 .dig_out_nid = ALC880_DIGOUT_NID,
4255 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4256 .channel_mode = alc880_2_jack_modes,
4257 .input_mux = &alc880_medion_rim_capture_source,
4258 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004259 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004260 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004261#ifdef CONFIG_SND_DEBUG
4262 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004263 .mixers = { alc880_test_mixer },
4264 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004265 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4266 .dac_nids = alc880_test_dac_nids,
4267 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004268 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4269 .channel_mode = alc880_test_modes,
4270 .input_mux = &alc880_test_capture_source,
4271 },
4272#endif
4273};
4274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004275/*
4276 * Automatic parse of I/O pins from the BIOS configuration
4277 */
4278
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279enum {
4280 ALC_CTL_WIDGET_VOL,
4281 ALC_CTL_WIDGET_MUTE,
4282 ALC_CTL_BIND_MUTE,
4283};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004284static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004285 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4286 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004287 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004288};
4289
4290/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004291static int add_control(struct alc_spec *spec, int type, const char *name,
4292 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004294 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295
Takashi Iwai603c4012008-07-30 15:01:44 +02004296 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4297 knew = snd_array_new(&spec->kctls);
4298 if (!knew)
4299 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004300 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004301 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004302 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303 return -ENOMEM;
4304 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305 return 0;
4306}
4307
4308#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4309#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4310#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4311#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4312#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4313#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4314#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 {
4401 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004402 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4403 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4404 HDA_OUTPUT));
4405 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004406 return err;
4407 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004408 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4409 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4410 HDA_INPUT));
4411 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004412 return err;
4413 }
4414 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004415 return 0;
4416}
4417
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004418/* add playback controls for speaker and HP outputs */
4419static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4420 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004421{
4422 hda_nid_t nid;
4423 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004424 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004426 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004427 return 0;
4428
4429 if (alc880_is_fixed_pin(pin)) {
4430 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004431 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004432 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004433 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004434 else
4435 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004436 /* control HP volume/switch on the output mixer amp */
4437 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004438 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004439 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4440 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4441 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004442 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004443 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004444 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4445 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4446 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004447 return err;
4448 } else if (alc880_is_multi_pin(pin)) {
4449 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004450 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004451 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004452 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4453 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4454 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004455 return err;
4456 }
4457 return 0;
4458}
4459
4460/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004461static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4462 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004463 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004464{
4465 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004466 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467
4468 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4470 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4471 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004472 return err;
4473 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004474 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4475 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4476 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477 return err;
4478 return 0;
4479}
4480
4481/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004482static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4483 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004485 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004486 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487
4488 for (i = 0; i < AUTO_PIN_LAST; i++) {
4489 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004490 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004491 err = new_analog_input(spec, cfg->input_pins[i],
4492 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004493 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494 if (err < 0)
4495 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004496 imux->items[imux->num_items].label =
4497 auto_pin_cfg_labels[i];
4498 imux->items[imux->num_items].index =
4499 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004500 imux->num_items++;
4501 }
4502 }
4503 return 0;
4504}
4505
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004506static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4507 unsigned int pin_type)
4508{
4509 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4510 pin_type);
4511 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004512 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4513 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004514}
4515
Kailang Yangdf694da2005-12-05 19:42:22 +01004516static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4517 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518 int dac_idx)
4519{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004520 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004521 /* need the manual connection? */
4522 if (alc880_is_multi_pin(nid)) {
4523 struct alc_spec *spec = codec->spec;
4524 int idx = alc880_multi_pin_idx(nid);
4525 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4526 AC_VERB_SET_CONNECT_SEL,
4527 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4528 }
4529}
4530
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004531static int get_pin_type(int line_out_type)
4532{
4533 if (line_out_type == AUTO_PIN_HP_OUT)
4534 return PIN_HP;
4535 else
4536 return PIN_OUT;
4537}
4538
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539static void alc880_auto_init_multi_out(struct hda_codec *codec)
4540{
4541 struct alc_spec *spec = codec->spec;
4542 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004543
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004544 for (i = 0; i < spec->autocfg.line_outs; i++) {
4545 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004546 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4547 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004548 }
4549}
4550
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004551static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004552{
4553 struct alc_spec *spec = codec->spec;
4554 hda_nid_t pin;
4555
Takashi Iwai82bc9552006-03-21 11:24:42 +01004556 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004557 if (pin) /* connect to front */
4558 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004559 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004560 if (pin) /* connect to front */
4561 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4562}
4563
4564static void alc880_auto_init_analog_input(struct hda_codec *codec)
4565{
4566 struct alc_spec *spec = codec->spec;
4567 int i;
4568
4569 for (i = 0; i < AUTO_PIN_LAST; i++) {
4570 hda_nid_t nid = spec->autocfg.input_pins[i];
4571 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004572 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004573 if (nid != ALC880_PIN_CD_NID &&
4574 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004575 snd_hda_codec_write(codec, nid, 0,
4576 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004577 AMP_OUT_MUTE);
4578 }
4579 }
4580}
4581
4582/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004583/* return 1 if successful, 0 if the proper config is not found,
4584 * or a negative error code
4585 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004586static int alc880_parse_auto_config(struct hda_codec *codec)
4587{
4588 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004589 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004590 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004591
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004592 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4593 alc880_ignore);
4594 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004595 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004596 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004597 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004598
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004599 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4600 if (err < 0)
4601 return err;
4602 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4603 if (err < 0)
4604 return err;
4605 err = alc880_auto_create_extra_out(spec,
4606 spec->autocfg.speaker_pins[0],
4607 "Speaker");
4608 if (err < 0)
4609 return err;
4610 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4611 "Headphone");
4612 if (err < 0)
4613 return err;
4614 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4615 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004616 return err;
4617
4618 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4619
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004620 /* check multiple SPDIF-out (for recent codecs) */
4621 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4622 hda_nid_t dig_nid;
4623 err = snd_hda_get_connections(codec,
4624 spec->autocfg.dig_out_pins[i],
4625 &dig_nid, 1);
4626 if (err < 0)
4627 continue;
4628 if (!i)
4629 spec->multiout.dig_out_nid = dig_nid;
4630 else {
4631 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4632 spec->slave_dig_outs[i - 1] = dig_nid;
4633 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4634 break;
4635 }
4636 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637 if (spec->autocfg.dig_in_pin)
4638 spec->dig_in_nid = ALC880_DIGIN_NID;
4639
Takashi Iwai603c4012008-07-30 15:01:44 +02004640 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004641 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642
Takashi Iwaid88897e2008-10-31 15:01:37 +01004643 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004645 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004646 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004647
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004648 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 return 1;
4651}
4652
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004653/* additional initialization for auto-configuration model */
4654static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004655{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004656 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004658 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004659 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004660 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004661 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004662}
4663
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004664/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4665 * one of two digital mic pins, e.g. on ALC272
4666 */
4667static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004668{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004669 struct alc_spec *spec = codec->spec;
4670 int i;
4671
4672 for (i = 0; i < spec->num_adc_nids; i++) {
4673 hda_nid_t cap = spec->capsrc_nids ?
4674 spec->capsrc_nids[i] : spec->adc_nids[i];
4675 int iidx, eidx;
4676
4677 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4678 if (iidx < 0)
4679 continue;
4680 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4681 if (eidx < 0)
4682 continue;
4683 spec->int_mic.mux_idx = iidx;
4684 spec->ext_mic.mux_idx = eidx;
4685 if (spec->capsrc_nids)
4686 spec->capsrc_nids += i;
4687 spec->adc_nids += i;
4688 spec->num_adc_nids = 1;
4689 return;
4690 }
4691 snd_printd(KERN_INFO "hda_codec: %s: "
4692 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4693 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4694 spec->auto_mic = 0; /* disable auto-mic to be sure */
4695}
4696
4697static void set_capture_mixer(struct hda_codec *codec)
4698{
4699 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004700 static struct snd_kcontrol_new *caps[2][3] = {
4701 { alc_capture_mixer_nosrc1,
4702 alc_capture_mixer_nosrc2,
4703 alc_capture_mixer_nosrc3 },
4704 { alc_capture_mixer1,
4705 alc_capture_mixer2,
4706 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004707 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004708 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4709 int mux;
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004710 if (spec->auto_mic) {
4711 mux = 0;
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004712 fixup_automic_adc(codec);
Takashi Iwai2a22d3f2009-08-10 18:54:38 +02004713 } else if (spec->input_mux && spec->input_mux->num_items > 1)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004714 mux = 1;
4715 else
4716 mux = 0;
4717 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4718 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004719}
4720
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004721#define set_beep_amp(spec, nid, idx, dir) \
4722 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4723
4724/*
4725 * OK, here we have finally the patch for ALC880
4726 */
4727
Linus Torvalds1da177e2005-04-16 15:20:36 -07004728static int patch_alc880(struct hda_codec *codec)
4729{
4730 struct alc_spec *spec;
4731 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004732 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004733
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004734 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004735 if (spec == NULL)
4736 return -ENOMEM;
4737
4738 codec->spec = spec;
4739
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004740 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4741 alc880_models,
4742 alc880_cfg_tbl);
4743 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004744 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4745 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004746 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004747 }
4748
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004749 if (board_config == ALC880_AUTO) {
4750 /* automatic parse from the BIOS config */
4751 err = alc880_parse_auto_config(codec);
4752 if (err < 0) {
4753 alc_free(codec);
4754 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004755 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004756 printk(KERN_INFO
4757 "hda_codec: Cannot set up configuration "
4758 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004759 board_config = ALC880_3ST;
4760 }
4761 }
4762
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004763 err = snd_hda_attach_beep_device(codec, 0x1);
4764 if (err < 0) {
4765 alc_free(codec);
4766 return err;
4767 }
4768
Kailang Yangdf694da2005-12-05 19:42:22 +01004769 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02004770 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771
Linus Torvalds1da177e2005-04-16 15:20:36 -07004772 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4773 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004774 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004775
Linus Torvalds1da177e2005-04-16 15:20:36 -07004776 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4777 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4778
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004779 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004781 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004782 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004783 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004784 if (wcap != AC_WID_AUD_IN) {
4785 spec->adc_nids = alc880_adc_nids_alt;
4786 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004787 } else {
4788 spec->adc_nids = alc880_adc_nids;
4789 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 }
4791 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004792 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004793 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004794
Takashi Iwai2134ea42008-01-10 16:53:55 +01004795 spec->vmaster_nid = 0x0c;
4796
Linus Torvalds1da177e2005-04-16 15:20:36 -07004797 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004798 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004799 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004800#ifdef CONFIG_SND_HDA_POWER_SAVE
4801 if (!spec->loopback.amplist)
4802 spec->loopback.amplist = alc880_loopbacks;
4803#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004804 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004805
4806 return 0;
4807}
4808
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809
Linus Torvalds1da177e2005-04-16 15:20:36 -07004810/*
4811 * ALC260 support
4812 */
4813
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004814static hda_nid_t alc260_dac_nids[1] = {
4815 /* front */
4816 0x02,
4817};
4818
4819static hda_nid_t alc260_adc_nids[1] = {
4820 /* ADC0 */
4821 0x04,
4822};
4823
Kailang Yangdf694da2005-12-05 19:42:22 +01004824static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004825 /* ADC1 */
4826 0x05,
4827};
4828
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004829/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4830 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4831 */
4832static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004833 /* ADC0, ADC1 */
4834 0x04, 0x05
4835};
4836
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004837#define ALC260_DIGOUT_NID 0x03
4838#define ALC260_DIGIN_NID 0x06
4839
4840static struct hda_input_mux alc260_capture_source = {
4841 .num_items = 4,
4842 .items = {
4843 { "Mic", 0x0 },
4844 { "Front Mic", 0x1 },
4845 { "Line", 0x2 },
4846 { "CD", 0x4 },
4847 },
4848};
4849
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004850/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004851 * headphone jack and the internal CD lines since these are the only pins at
4852 * which audio can appear. For flexibility, also allow the option of
4853 * recording the mixer output on the second ADC (ADC0 doesn't have a
4854 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004855 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004856static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4857 {
4858 .num_items = 3,
4859 .items = {
4860 { "Mic/Line", 0x0 },
4861 { "CD", 0x4 },
4862 { "Headphone", 0x2 },
4863 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004864 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004865 {
4866 .num_items = 4,
4867 .items = {
4868 { "Mic/Line", 0x0 },
4869 { "CD", 0x4 },
4870 { "Headphone", 0x2 },
4871 { "Mixer", 0x5 },
4872 },
4873 },
4874
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004875};
4876
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004877/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4878 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004879 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004880static struct hda_input_mux alc260_acer_capture_sources[2] = {
4881 {
4882 .num_items = 4,
4883 .items = {
4884 { "Mic", 0x0 },
4885 { "Line", 0x2 },
4886 { "CD", 0x4 },
4887 { "Headphone", 0x5 },
4888 },
4889 },
4890 {
4891 .num_items = 5,
4892 .items = {
4893 { "Mic", 0x0 },
4894 { "Line", 0x2 },
4895 { "CD", 0x4 },
4896 { "Headphone", 0x6 },
4897 { "Mixer", 0x5 },
4898 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004899 },
4900};
Michael Schwingencc959482009-02-22 18:58:45 +01004901
4902/* Maxdata Favorit 100XS */
4903static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4904 {
4905 .num_items = 2,
4906 .items = {
4907 { "Line/Mic", 0x0 },
4908 { "CD", 0x4 },
4909 },
4910 },
4911 {
4912 .num_items = 3,
4913 .items = {
4914 { "Line/Mic", 0x0 },
4915 { "CD", 0x4 },
4916 { "Mixer", 0x5 },
4917 },
4918 },
4919};
4920
Linus Torvalds1da177e2005-04-16 15:20:36 -07004921/*
4922 * This is just place-holder, so there's something for alc_build_pcms to look
4923 * at when it calculates the maximum number of channels. ALC260 has no mixer
4924 * element which allows changing the channel mode, so the verb list is
4925 * never used.
4926 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004927static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004928 { 2, NULL },
4929};
4930
Kailang Yangdf694da2005-12-05 19:42:22 +01004931
4932/* Mixer combinations
4933 *
4934 * basic: base_output + input + pc_beep + capture
4935 * HP: base_output + input + capture_alt
4936 * HP_3013: hp_3013 + input + capture
4937 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004938 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004939 */
4940
4941static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004942 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004943 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004944 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4945 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4946 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4947 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4948 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004949};
Kailang Yangdf694da2005-12-05 19:42:22 +01004950
4951static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004952 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4953 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4954 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4955 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4957 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4958 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004960 { } /* end */
4961};
4962
Takashi Iwaibec15c32008-01-28 18:16:30 +01004963/* update HP, line and mono out pins according to the master switch */
4964static void alc260_hp_master_update(struct hda_codec *codec,
4965 hda_nid_t hp, hda_nid_t line,
4966 hda_nid_t mono)
4967{
4968 struct alc_spec *spec = codec->spec;
4969 unsigned int val = spec->master_sw ? PIN_HP : 0;
4970 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004971 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004972 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004973 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004974 val);
4975 /* mono (speaker) depending on the HP jack sense */
4976 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004977 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004978 val);
4979}
4980
4981static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4982 struct snd_ctl_elem_value *ucontrol)
4983{
4984 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4985 struct alc_spec *spec = codec->spec;
4986 *ucontrol->value.integer.value = spec->master_sw;
4987 return 0;
4988}
4989
4990static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4991 struct snd_ctl_elem_value *ucontrol)
4992{
4993 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4994 struct alc_spec *spec = codec->spec;
4995 int val = !!*ucontrol->value.integer.value;
4996 hda_nid_t hp, line, mono;
4997
4998 if (val == spec->master_sw)
4999 return 0;
5000 spec->master_sw = val;
5001 hp = (kcontrol->private_value >> 16) & 0xff;
5002 line = (kcontrol->private_value >> 8) & 0xff;
5003 mono = kcontrol->private_value & 0xff;
5004 alc260_hp_master_update(codec, hp, line, mono);
5005 return 1;
5006}
5007
5008static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5009 {
5010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5011 .name = "Master Playback Switch",
5012 .info = snd_ctl_boolean_mono_info,
5013 .get = alc260_hp_master_sw_get,
5014 .put = alc260_hp_master_sw_put,
5015 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5016 },
5017 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5018 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5019 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5020 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5021 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5022 HDA_OUTPUT),
5023 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5024 { } /* end */
5025};
5026
5027static struct hda_verb alc260_hp_unsol_verbs[] = {
5028 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5029 {},
5030};
5031
5032static void alc260_hp_automute(struct hda_codec *codec)
5033{
5034 struct alc_spec *spec = codec->spec;
5035 unsigned int present;
5036
5037 present = snd_hda_codec_read(codec, 0x10, 0,
5038 AC_VERB_GET_PIN_SENSE, 0);
5039 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5040 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5041}
5042
5043static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5044{
5045 if ((res >> 26) == ALC880_HP_EVENT)
5046 alc260_hp_automute(codec);
5047}
5048
Kailang Yangdf694da2005-12-05 19:42:22 +01005049static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005050 {
5051 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5052 .name = "Master Playback Switch",
5053 .info = snd_ctl_boolean_mono_info,
5054 .get = alc260_hp_master_sw_get,
5055 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005056 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005057 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005058 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5059 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5060 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5061 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5062 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5063 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005064 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5065 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005066 { } /* end */
5067};
5068
Kailang Yang3f878302008-08-26 13:02:23 +02005069static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5070 .ops = &snd_hda_bind_vol,
5071 .values = {
5072 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5073 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5074 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5075 0
5076 },
5077};
5078
5079static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5080 .ops = &snd_hda_bind_sw,
5081 .values = {
5082 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5083 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5084 0
5085 },
5086};
5087
5088static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5089 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5090 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5091 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5093 { } /* end */
5094};
5095
Takashi Iwaibec15c32008-01-28 18:16:30 +01005096static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5097 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5098 {},
5099};
5100
5101static void alc260_hp_3013_automute(struct hda_codec *codec)
5102{
5103 struct alc_spec *spec = codec->spec;
5104 unsigned int present;
5105
5106 present = snd_hda_codec_read(codec, 0x15, 0,
5107 AC_VERB_GET_PIN_SENSE, 0);
5108 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005109 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005110}
5111
5112static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5113 unsigned int res)
5114{
5115 if ((res >> 26) == ALC880_HP_EVENT)
5116 alc260_hp_3013_automute(codec);
5117}
5118
Kailang Yang3f878302008-08-26 13:02:23 +02005119static void alc260_hp_3012_automute(struct hda_codec *codec)
5120{
5121 unsigned int present, bits;
5122
5123 present = snd_hda_codec_read(codec, 0x10, 0,
5124 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5125
5126 bits = present ? 0 : PIN_OUT;
5127 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5128 bits);
5129 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5130 bits);
5131 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5132 bits);
5133}
5134
5135static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5136 unsigned int res)
5137{
5138 if ((res >> 26) == ALC880_HP_EVENT)
5139 alc260_hp_3012_automute(codec);
5140}
5141
5142/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005143 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5144 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005145static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005146 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005147 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005148 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005149 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5150 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5151 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5152 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005153 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005154 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5155 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005156 { } /* end */
5157};
5158
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005159/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5160 * versions of the ALC260 don't act on requests to enable mic bias from NID
5161 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5162 * datasheet doesn't mention this restriction. At this stage it's not clear
5163 * whether this behaviour is intentional or is a hardware bug in chip
5164 * revisions available in early 2006. Therefore for now allow the
5165 * "Headphone Jack Mode" control to span all choices, but if it turns out
5166 * that the lack of mic bias for this NID is intentional we could change the
5167 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5168 *
5169 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5170 * don't appear to make the mic bias available from the "line" jack, even
5171 * though the NID used for this jack (0x14) can supply it. The theory is
5172 * that perhaps Acer have included blocking capacitors between the ALC260
5173 * and the output jack. If this turns out to be the case for all such
5174 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5175 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005176 *
5177 * The C20x Tablet series have a mono internal speaker which is controlled
5178 * via the chip's Mono sum widget and pin complex, so include the necessary
5179 * controls for such models. On models without a "mono speaker" the control
5180 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005181 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005182static struct snd_kcontrol_new alc260_acer_mixer[] = {
5183 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5184 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005185 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005186 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005187 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005188 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005189 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005190 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5191 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5193 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5194 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5195 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5196 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5197 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005198 { } /* end */
5199};
5200
Michael Schwingencc959482009-02-22 18:58:45 +01005201/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5202 */
5203static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5204 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5205 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5206 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5207 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5208 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5209 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5210 { } /* end */
5211};
5212
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005213/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5214 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5215 */
5216static struct snd_kcontrol_new alc260_will_mixer[] = {
5217 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5218 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5220 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5221 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5222 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5223 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5224 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5225 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5226 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005227 { } /* end */
5228};
5229
5230/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5231 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5232 */
5233static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5234 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5235 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5236 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5237 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5238 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5239 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5240 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5241 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5242 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5243 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5244 { } /* end */
5245};
5246
Kailang Yangdf694da2005-12-05 19:42:22 +01005247/*
5248 * initialization verbs
5249 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005250static struct hda_verb alc260_init_verbs[] = {
5251 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005253 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005254 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005255 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005256 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005257 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005258 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005259 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005261 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005262 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005263 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005264 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005265 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005266 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005267 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005268 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5269 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005270 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005271 /* set connection select to line in (default select for this ADC) */
5272 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005273 /* mute capture amp left and right */
5274 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5275 /* set connection select to line in (default select for this ADC) */
5276 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005277 /* set vol=0 Line-Out mixer amp left and right */
5278 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5279 /* unmute pin widget amp left and right (no gain on this amp) */
5280 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5281 /* set vol=0 HP mixer amp left and right */
5282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5283 /* unmute pin widget amp left and right (no gain on this amp) */
5284 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5285 /* set vol=0 Mono mixer amp left and right */
5286 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5287 /* unmute pin widget amp left and right (no gain on this amp) */
5288 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5289 /* unmute LINE-2 out pin */
5290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005291 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5292 * Line In 2 = 0x03
5293 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005294 /* mute analog inputs */
5295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5296 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5298 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5299 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005300 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005301 /* mute Front out path */
5302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5303 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5304 /* mute Headphone out path */
5305 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5307 /* mute Mono out path */
5308 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5309 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005310 { }
5311};
5312
Takashi Iwai474167d2006-05-17 17:17:43 +02005313#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005314static struct hda_verb alc260_hp_init_verbs[] = {
5315 /* Headphone and output */
5316 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5317 /* mono output */
5318 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5319 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5320 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5321 /* Mic2 (front panel) pin widget for input and vref at 80% */
5322 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5323 /* Line In pin widget for input */
5324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5325 /* Line-2 pin widget for output */
5326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5327 /* CD pin widget for input */
5328 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5329 /* unmute amp left and right */
5330 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5331 /* set connection select to line in (default select for this ADC) */
5332 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5333 /* unmute Line-Out mixer amp left and right (volume = 0) */
5334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5335 /* mute pin widget amp left and right (no gain on this amp) */
5336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5337 /* unmute HP mixer amp left and right (volume = 0) */
5338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5339 /* mute pin widget amp left and right (no gain on this amp) */
5340 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005341 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5342 * Line In 2 = 0x03
5343 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005344 /* mute analog inputs */
5345 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5346 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005350 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5351 /* Unmute Front out path */
5352 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5353 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5354 /* Unmute Headphone out path */
5355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5356 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5357 /* Unmute Mono out path */
5358 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5360 { }
5361};
Takashi Iwai474167d2006-05-17 17:17:43 +02005362#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005363
5364static struct hda_verb alc260_hp_3013_init_verbs[] = {
5365 /* Line out and output */
5366 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5367 /* mono output */
5368 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5369 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5370 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5371 /* Mic2 (front panel) pin widget for input and vref at 80% */
5372 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5373 /* Line In pin widget for input */
5374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5375 /* Headphone pin widget for output */
5376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5377 /* CD pin widget for input */
5378 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5379 /* unmute amp left and right */
5380 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5381 /* set connection select to line in (default select for this ADC) */
5382 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5383 /* unmute Line-Out mixer amp left and right (volume = 0) */
5384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5385 /* mute pin widget amp left and right (no gain on this amp) */
5386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5387 /* unmute HP mixer amp left and right (volume = 0) */
5388 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5389 /* mute pin widget amp left and right (no gain on this amp) */
5390 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005391 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5392 * Line In 2 = 0x03
5393 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005394 /* mute analog inputs */
5395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005400 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5401 /* Unmute Front out path */
5402 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5404 /* Unmute Headphone out path */
5405 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5407 /* Unmute Mono out path */
5408 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5409 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5410 { }
5411};
5412
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005413/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005414 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5415 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005416 */
5417static struct hda_verb alc260_fujitsu_init_verbs[] = {
5418 /* Disable all GPIOs */
5419 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5420 /* Internal speaker is connected to headphone pin */
5421 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5422 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005424 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5425 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5426 /* Ensure all other unused pins are disabled and muted. */
5427 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5428 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005429 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005430 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005431 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005432 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5433 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005435
Jonathan Woithef7ace402006-02-28 11:46:14 +01005436 /* Disable digital (SPDIF) pins */
5437 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5438 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005439
Kailang Yangea1fb292008-08-26 12:58:38 +02005440 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005441 * when acting as an output.
5442 */
5443 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5444
5445 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005446 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5447 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5448 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5449 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5450 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5452 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5453 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5454 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005455
Jonathan Woithef7ace402006-02-28 11:46:14 +01005456 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5457 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5458 /* Unmute Line1 pin widget output buffer since it starts as an output.
5459 * If the pin mode is changed by the user the pin mode control will
5460 * take care of enabling the pin's input/output buffers as needed.
5461 * Therefore there's no need to enable the input buffer at this
5462 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005463 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005465 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005466 * mixer ctrl)
5467 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005468 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005469
Jonathan Woithef7ace402006-02-28 11:46:14 +01005470 /* Mute capture amp left and right */
5471 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005472 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005473 * in (on mic1 pin)
5474 */
5475 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005476
Jonathan Woithef7ace402006-02-28 11:46:14 +01005477 /* Do the same for the second ADC: mute capture input amp and
5478 * set ADC connection to line in (on mic1 pin)
5479 */
5480 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5481 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005482
Jonathan Woithef7ace402006-02-28 11:46:14 +01005483 /* Mute all inputs to mixer widget (even unconnected ones) */
5484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5485 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5486 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5488 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5489 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005492
5493 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005494};
5495
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005496/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5497 * similar laptops (adapted from Fujitsu init verbs).
5498 */
5499static struct hda_verb alc260_acer_init_verbs[] = {
5500 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5501 * the headphone jack. Turn this on and rely on the standard mute
5502 * methods whenever the user wants to turn these outputs off.
5503 */
5504 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5505 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5506 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5507 /* Internal speaker/Headphone jack is connected to Line-out pin */
5508 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5509 /* Internal microphone/Mic jack is connected to Mic1 pin */
5510 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5511 /* Line In jack is connected to Line1 pin */
5512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005513 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5514 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005515 /* Ensure all other unused pins are disabled and muted. */
5516 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5517 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005518 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5519 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5521 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5522 /* Disable digital (SPDIF) pins */
5523 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5524 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5525
Kailang Yangea1fb292008-08-26 12:58:38 +02005526 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005527 * bus when acting as outputs.
5528 */
5529 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5530 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5531
5532 /* Start with output sum widgets muted and their output gains at min */
5533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5534 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5535 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5536 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5537 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5538 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5539 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5540 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5541 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5542
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005543 /* Unmute Line-out pin widget amp left and right
5544 * (no equiv mixer ctrl)
5545 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005546 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005547 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5548 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005549 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5550 * inputs. If the pin mode is changed by the user the pin mode control
5551 * will take care of enabling the pin's input/output buffers as needed.
5552 * Therefore there's no need to enable the input buffer at this
5553 * stage.
5554 */
5555 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5556 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5557
5558 /* Mute capture amp left and right */
5559 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5560 /* Set ADC connection select to match default mixer setting - mic
5561 * (on mic1 pin)
5562 */
5563 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5564
5565 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005566 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005567 */
5568 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005569 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005570
5571 /* Mute all inputs to mixer widget (even unconnected ones) */
5572 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5580
5581 { }
5582};
5583
Michael Schwingencc959482009-02-22 18:58:45 +01005584/* Initialisation sequence for Maxdata Favorit 100XS
5585 * (adapted from Acer init verbs).
5586 */
5587static struct hda_verb alc260_favorit100_init_verbs[] = {
5588 /* GPIO 0 enables the output jack.
5589 * Turn this on and rely on the standard mute
5590 * methods whenever the user wants to turn these outputs off.
5591 */
5592 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5593 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5594 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5595 /* Line/Mic input jack is connected to Mic1 pin */
5596 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5597 /* Ensure all other unused pins are disabled and muted. */
5598 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5599 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5600 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5601 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5602 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5603 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5608 /* Disable digital (SPDIF) pins */
5609 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5610 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5611
5612 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5613 * bus when acting as outputs.
5614 */
5615 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5616 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5617
5618 /* Start with output sum widgets muted and their output gains at min */
5619 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5620 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5621 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5622 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5623 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5624 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5625 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5626 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5627 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5628
5629 /* Unmute Line-out pin widget amp left and right
5630 * (no equiv mixer ctrl)
5631 */
5632 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5633 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5634 * inputs. If the pin mode is changed by the user the pin mode control
5635 * will take care of enabling the pin's input/output buffers as needed.
5636 * Therefore there's no need to enable the input buffer at this
5637 * stage.
5638 */
5639 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5640
5641 /* Mute capture amp left and right */
5642 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5643 /* Set ADC connection select to match default mixer setting - mic
5644 * (on mic1 pin)
5645 */
5646 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5647
5648 /* Do similar with the second ADC: mute capture input amp and
5649 * set ADC connection to mic to match ALSA's default state.
5650 */
5651 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5652 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5653
5654 /* Mute all inputs to mixer widget (even unconnected ones) */
5655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5661 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5662 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5663
5664 { }
5665};
5666
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005667static struct hda_verb alc260_will_verbs[] = {
5668 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5669 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5670 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5671 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5672 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5673 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5674 {}
5675};
5676
5677static struct hda_verb alc260_replacer_672v_verbs[] = {
5678 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5679 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5680 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5681
5682 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5683 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5684 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5685
5686 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5687 {}
5688};
5689
5690/* toggle speaker-output according to the hp-jack state */
5691static void alc260_replacer_672v_automute(struct hda_codec *codec)
5692{
5693 unsigned int present;
5694
5695 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5696 present = snd_hda_codec_read(codec, 0x0f, 0,
5697 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5698 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005699 snd_hda_codec_write_cache(codec, 0x01, 0,
5700 AC_VERB_SET_GPIO_DATA, 1);
5701 snd_hda_codec_write_cache(codec, 0x0f, 0,
5702 AC_VERB_SET_PIN_WIDGET_CONTROL,
5703 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005704 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005705 snd_hda_codec_write_cache(codec, 0x01, 0,
5706 AC_VERB_SET_GPIO_DATA, 0);
5707 snd_hda_codec_write_cache(codec, 0x0f, 0,
5708 AC_VERB_SET_PIN_WIDGET_CONTROL,
5709 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005710 }
5711}
5712
5713static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5714 unsigned int res)
5715{
5716 if ((res >> 26) == ALC880_HP_EVENT)
5717 alc260_replacer_672v_automute(codec);
5718}
5719
Kailang Yang3f878302008-08-26 13:02:23 +02005720static struct hda_verb alc260_hp_dc7600_verbs[] = {
5721 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5723 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5724 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5725 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5726 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5727 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5728 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5729 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5730 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5731 {}
5732};
5733
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005734/* Test configuration for debugging, modelled after the ALC880 test
5735 * configuration.
5736 */
5737#ifdef CONFIG_SND_DEBUG
5738static hda_nid_t alc260_test_dac_nids[1] = {
5739 0x02,
5740};
5741static hda_nid_t alc260_test_adc_nids[2] = {
5742 0x04, 0x05,
5743};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005744/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005745 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005746 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005747 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005748static struct hda_input_mux alc260_test_capture_sources[2] = {
5749 {
5750 .num_items = 7,
5751 .items = {
5752 { "MIC1 pin", 0x0 },
5753 { "MIC2 pin", 0x1 },
5754 { "LINE1 pin", 0x2 },
5755 { "LINE2 pin", 0x3 },
5756 { "CD pin", 0x4 },
5757 { "LINE-OUT pin", 0x5 },
5758 { "HP-OUT pin", 0x6 },
5759 },
5760 },
5761 {
5762 .num_items = 8,
5763 .items = {
5764 { "MIC1 pin", 0x0 },
5765 { "MIC2 pin", 0x1 },
5766 { "LINE1 pin", 0x2 },
5767 { "LINE2 pin", 0x3 },
5768 { "CD pin", 0x4 },
5769 { "Mixer", 0x5 },
5770 { "LINE-OUT pin", 0x6 },
5771 { "HP-OUT pin", 0x7 },
5772 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005773 },
5774};
5775static struct snd_kcontrol_new alc260_test_mixer[] = {
5776 /* Output driver widgets */
5777 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5778 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5779 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5780 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5781 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5782 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5783
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005784 /* Modes for retasking pin widgets
5785 * Note: the ALC260 doesn't seem to act on requests to enable mic
5786 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5787 * mention this restriction. At this stage it's not clear whether
5788 * this behaviour is intentional or is a hardware bug in chip
5789 * revisions available at least up until early 2006. Therefore for
5790 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5791 * choices, but if it turns out that the lack of mic bias for these
5792 * NIDs is intentional we could change their modes from
5793 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5794 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005795 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5796 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5797 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5798 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5799 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5800 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5801
5802 /* Loopback mixer controls */
5803 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5804 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5805 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5806 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5807 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5808 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5809 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5810 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5811 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5812 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005813 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5814 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5815 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5816 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005817
5818 /* Controls for GPIO pins, assuming they are configured as outputs */
5819 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5820 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5821 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5822 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5823
Jonathan Woithe92621f12006-02-28 11:47:47 +01005824 /* Switches to allow the digital IO pins to be enabled. The datasheet
5825 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005826 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005827 */
5828 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5829 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5830
Jonathan Woithef8225f62008-01-08 12:16:54 +01005831 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5832 * this output to turn on an external amplifier.
5833 */
5834 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5835 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5836
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005837 { } /* end */
5838};
5839static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005840 /* Enable all GPIOs as outputs with an initial value of 0 */
5841 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5842 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5843 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5844
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005845 /* Enable retasking pins as output, initially without power amp */
5846 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5847 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5848 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5849 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5850 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5851 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5852
Jonathan Woithe92621f12006-02-28 11:47:47 +01005853 /* Disable digital (SPDIF) pins initially, but users can enable
5854 * them via a mixer switch. In the case of SPDIF-out, this initverb
5855 * payload also sets the generation to 0, output to be in "consumer"
5856 * PCM format, copyright asserted, no pre-emphasis and no validity
5857 * control.
5858 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005859 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5860 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5861
Kailang Yangea1fb292008-08-26 12:58:38 +02005862 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005863 * OUT1 sum bus when acting as an output.
5864 */
5865 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5866 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5867 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5868 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5869
5870 /* Start with output sum widgets muted and their output gains at min */
5871 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5872 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5873 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5874 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5875 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5876 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5877 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5878 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5879 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5880
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005881 /* Unmute retasking pin widget output buffers since the default
5882 * state appears to be output. As the pin mode is changed by the
5883 * user the pin mode control will take care of enabling the pin's
5884 * input/output buffers as needed.
5885 */
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005886 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5889 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5890 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5891 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5892 /* Also unmute the mono-out pin widget */
5893 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5894
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005895 /* Mute capture amp left and right */
5896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005897 /* Set ADC connection select to match default mixer setting (mic1
5898 * pin)
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005899 */
5900 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5901
5902 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005903 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01005904 */
5905 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5906 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5907
5908 /* Mute all inputs to mixer widget (even unconnected ones) */
5909 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5911 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5913 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5914 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5917
5918 { }
5919};
5920#endif
5921
Takashi Iwai63300792008-01-24 15:31:36 +01005922#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5923#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005924
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005925#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5926#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5927
Kailang Yangdf694da2005-12-05 19:42:22 +01005928/*
5929 * for BIOS auto-configuration
5930 */
5931
5932static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005933 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005934{
5935 hda_nid_t nid_vol;
5936 unsigned long vol_val, sw_val;
5937 char name[32];
5938 int err;
5939
5940 if (nid >= 0x0f && nid < 0x11) {
5941 nid_vol = nid - 0x7;
5942 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5943 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5944 } else if (nid == 0x11) {
5945 nid_vol = nid - 0x7;
5946 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5947 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5948 } else if (nid >= 0x12 && nid <= 0x15) {
5949 nid_vol = 0x08;
5950 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5951 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5952 } else
5953 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005954
Takashi Iwai863b4512008-10-21 17:01:47 +02005955 if (!(*vol_bits & (1 << nid_vol))) {
5956 /* first control for the volume widget */
5957 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5958 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5959 if (err < 0)
5960 return err;
5961 *vol_bits |= (1 << nid_vol);
5962 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005963 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005964 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5965 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 return err;
5967 return 1;
5968}
5969
5970/* add playback controls from the parsed DAC table */
5971static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5972 const struct auto_pin_cfg *cfg)
5973{
5974 hda_nid_t nid;
5975 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005976 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005977
5978 spec->multiout.num_dacs = 1;
5979 spec->multiout.dac_nids = spec->private_dac_nids;
5980 spec->multiout.dac_nids[0] = 0x02;
5981
5982 nid = cfg->line_out_pins[0];
5983 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005984 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005985 if (err < 0)
5986 return err;
5987 }
5988
Takashi Iwai82bc9552006-03-21 11:24:42 +01005989 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005990 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005991 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005992 if (err < 0)
5993 return err;
5994 }
5995
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005996 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005997 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005998 err = alc260_add_playback_controls(spec, nid, "Headphone",
5999 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006000 if (err < 0)
6001 return err;
6002 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006003 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006004}
6005
6006/* create playback/capture controls for input pins */
6007static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
6008 const struct auto_pin_cfg *cfg)
6009{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006010 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006011 int i, err, idx;
6012
6013 for (i = 0; i < AUTO_PIN_LAST; i++) {
6014 if (cfg->input_pins[i] >= 0x12) {
6015 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006016 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006017 auto_pin_cfg_labels[i], idx,
6018 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006019 if (err < 0)
6020 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006021 imux->items[imux->num_items].label =
6022 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006023 imux->items[imux->num_items].index = idx;
6024 imux->num_items++;
6025 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006026 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01006027 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006028 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006029 auto_pin_cfg_labels[i], idx,
6030 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006031 if (err < 0)
6032 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006033 imux->items[imux->num_items].label =
6034 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006035 imux->items[imux->num_items].index = idx;
6036 imux->num_items++;
6037 }
6038 }
6039 return 0;
6040}
6041
6042static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6043 hda_nid_t nid, int pin_type,
6044 int sel_idx)
6045{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006046 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006047 /* need the manual connection? */
6048 if (nid >= 0x12) {
6049 int idx = nid - 0x12;
6050 snd_hda_codec_write(codec, idx + 0x0b, 0,
6051 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006052 }
6053}
6054
6055static void alc260_auto_init_multi_out(struct hda_codec *codec)
6056{
6057 struct alc_spec *spec = codec->spec;
6058 hda_nid_t nid;
6059
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006060 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006061 if (nid) {
6062 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6063 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6064 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006065
Takashi Iwai82bc9552006-03-21 11:24:42 +01006066 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006067 if (nid)
6068 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6069
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006070 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006071 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006072 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006073}
Kailang Yangdf694da2005-12-05 19:42:22 +01006074
6075#define ALC260_PIN_CD_NID 0x16
6076static void alc260_auto_init_analog_input(struct hda_codec *codec)
6077{
6078 struct alc_spec *spec = codec->spec;
6079 int i;
6080
6081 for (i = 0; i < AUTO_PIN_LAST; i++) {
6082 hda_nid_t nid = spec->autocfg.input_pins[i];
6083 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006084 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006085 if (nid != ALC260_PIN_CD_NID &&
6086 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006087 snd_hda_codec_write(codec, nid, 0,
6088 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006089 AMP_OUT_MUTE);
6090 }
6091 }
6092}
6093
6094/*
6095 * generic initialization of ADC, input mixers and output mixers
6096 */
6097static struct hda_verb alc260_volume_init_verbs[] = {
6098 /*
6099 * Unmute ADC0-1 and set the default input to mic-in
6100 */
6101 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6102 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6103 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6104 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006105
Kailang Yangdf694da2005-12-05 19:42:22 +01006106 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6107 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006108 * Note: PASD motherboards uses the Line In 2 as the input for
6109 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006110 */
6111 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006112 /* mute analog inputs */
6113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006118
6119 /*
6120 * Set up output mixers (0x08 - 0x0a)
6121 */
6122 /* set vol=0 to output mixers */
6123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6125 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6126 /* set up input amps for analog loopback */
6127 /* Amp Indices: DAC = 0, mixer = 1 */
6128 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6129 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6130 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6132 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6133 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006134
Kailang Yangdf694da2005-12-05 19:42:22 +01006135 { }
6136};
6137
6138static int alc260_parse_auto_config(struct hda_codec *codec)
6139{
6140 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006141 int err;
6142 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6143
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006144 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6145 alc260_ignore);
6146 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006147 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006148 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6149 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006150 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006151 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006152 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006153 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
6154 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006155 return err;
6156
6157 spec->multiout.max_channels = 2;
6158
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006159 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006160 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006161 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006162 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006163
Takashi Iwaid88897e2008-10-31 15:01:37 +01006164 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006165
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006166 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006167 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006168
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006169 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6170
Kailang Yangdf694da2005-12-05 19:42:22 +01006171 return 1;
6172}
6173
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006174/* additional initialization for auto-configuration model */
6175static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006176{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006177 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006178 alc260_auto_init_multi_out(codec);
6179 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006180 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006181 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006182}
6183
Takashi Iwaicb53c622007-08-10 17:21:45 +02006184#ifdef CONFIG_SND_HDA_POWER_SAVE
6185static struct hda_amp_list alc260_loopbacks[] = {
6186 { 0x07, HDA_INPUT, 0 },
6187 { 0x07, HDA_INPUT, 1 },
6188 { 0x07, HDA_INPUT, 2 },
6189 { 0x07, HDA_INPUT, 3 },
6190 { 0x07, HDA_INPUT, 4 },
6191 { } /* end */
6192};
6193#endif
6194
Kailang Yangdf694da2005-12-05 19:42:22 +01006195/*
6196 * ALC260 configurations
6197 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006198static const char *alc260_models[ALC260_MODEL_LAST] = {
6199 [ALC260_BASIC] = "basic",
6200 [ALC260_HP] = "hp",
6201 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006202 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006203 [ALC260_FUJITSU_S702X] = "fujitsu",
6204 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006205 [ALC260_WILL] = "will",
6206 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006207 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006208#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006209 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006210#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006211 [ALC260_AUTO] = "auto",
6212};
6213
6214static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006215 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006216 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006217 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006218 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006219 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006220 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006221 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006222 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006223 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6224 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6225 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6226 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6227 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6228 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6229 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6230 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6231 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006232 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006233 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006234 {}
6235};
6236
Kailang Yangdf694da2005-12-05 19:42:22 +01006237static struct alc_config_preset alc260_presets[] = {
6238 [ALC260_BASIC] = {
6239 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006240 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006241 .init_verbs = { alc260_init_verbs },
6242 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6243 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006244 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006245 .adc_nids = alc260_adc_nids,
6246 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6247 .channel_mode = alc260_modes,
6248 .input_mux = &alc260_capture_source,
6249 },
6250 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006251 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006252 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006253 .init_verbs = { alc260_init_verbs,
6254 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006255 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6256 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006257 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6258 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006259 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6260 .channel_mode = alc260_modes,
6261 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006262 .unsol_event = alc260_hp_unsol_event,
6263 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006264 },
Kailang Yang3f878302008-08-26 13:02:23 +02006265 [ALC260_HP_DC7600] = {
6266 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006267 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006268 .init_verbs = { alc260_init_verbs,
6269 alc260_hp_dc7600_verbs },
6270 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6271 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006272 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6273 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006274 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6275 .channel_mode = alc260_modes,
6276 .input_mux = &alc260_capture_source,
6277 .unsol_event = alc260_hp_3012_unsol_event,
6278 .init_hook = alc260_hp_3012_automute,
6279 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006280 [ALC260_HP_3013] = {
6281 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006282 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006283 .init_verbs = { alc260_hp_3013_init_verbs,
6284 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006285 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6286 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006287 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6288 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006289 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6290 .channel_mode = alc260_modes,
6291 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006292 .unsol_event = alc260_hp_3013_unsol_event,
6293 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006294 },
6295 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006296 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006297 .init_verbs = { alc260_fujitsu_init_verbs },
6298 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6299 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006300 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6301 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006302 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6303 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006304 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6305 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006306 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006307 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006308 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006309 .init_verbs = { alc260_acer_init_verbs },
6310 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6311 .dac_nids = alc260_dac_nids,
6312 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6313 .adc_nids = alc260_dual_adc_nids,
6314 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6315 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006316 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6317 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006318 },
Michael Schwingencc959482009-02-22 18:58:45 +01006319 [ALC260_FAVORIT100] = {
6320 .mixers = { alc260_favorit100_mixer },
6321 .init_verbs = { alc260_favorit100_init_verbs },
6322 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6323 .dac_nids = alc260_dac_nids,
6324 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6325 .adc_nids = alc260_dual_adc_nids,
6326 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6327 .channel_mode = alc260_modes,
6328 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6329 .input_mux = alc260_favorit100_capture_sources,
6330 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006331 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006332 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006333 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6334 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6335 .dac_nids = alc260_dac_nids,
6336 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6337 .adc_nids = alc260_adc_nids,
6338 .dig_out_nid = ALC260_DIGOUT_NID,
6339 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6340 .channel_mode = alc260_modes,
6341 .input_mux = &alc260_capture_source,
6342 },
6343 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006344 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006345 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6346 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6347 .dac_nids = alc260_dac_nids,
6348 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6349 .adc_nids = alc260_adc_nids,
6350 .dig_out_nid = ALC260_DIGOUT_NID,
6351 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6352 .channel_mode = alc260_modes,
6353 .input_mux = &alc260_capture_source,
6354 .unsol_event = alc260_replacer_672v_unsol_event,
6355 .init_hook = alc260_replacer_672v_automute,
6356 },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006357#ifdef CONFIG_SND_DEBUG
6358 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006359 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006360 .init_verbs = { alc260_test_init_verbs },
6361 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6362 .dac_nids = alc260_test_dac_nids,
6363 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6364 .adc_nids = alc260_test_adc_nids,
6365 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6366 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006367 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6368 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01006369 },
6370#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006371};
6372
Linus Torvalds1da177e2005-04-16 15:20:36 -07006373static int patch_alc260(struct hda_codec *codec)
6374{
6375 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006376 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006377
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006378 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006379 if (spec == NULL)
6380 return -ENOMEM;
6381
6382 codec->spec = spec;
6383
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006384 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6385 alc260_models,
6386 alc260_cfg_tbl);
6387 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006388 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006389 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006390 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006391 }
6392
Kailang Yangdf694da2005-12-05 19:42:22 +01006393 if (board_config == ALC260_AUTO) {
6394 /* automatic parse from the BIOS config */
6395 err = alc260_parse_auto_config(codec);
6396 if (err < 0) {
6397 alc_free(codec);
6398 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006399 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006400 printk(KERN_INFO
6401 "hda_codec: Cannot set up configuration "
6402 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006403 board_config = ALC260_BASIC;
6404 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006405 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006406
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006407 err = snd_hda_attach_beep_device(codec, 0x1);
6408 if (err < 0) {
6409 alc_free(codec);
6410 return err;
6411 }
6412
Kailang Yangdf694da2005-12-05 19:42:22 +01006413 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006414 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006415
Linus Torvalds1da177e2005-04-16 15:20:36 -07006416 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6417 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6418
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006419 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6420 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6421
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006422 if (!spec->adc_nids && spec->input_mux) {
6423 /* check whether NID 0x04 is valid */
6424 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006425 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006426 /* get type */
6427 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6428 spec->adc_nids = alc260_adc_nids_alt;
6429 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6430 } else {
6431 spec->adc_nids = alc260_adc_nids;
6432 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6433 }
6434 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006435 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006436 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006437
Takashi Iwai2134ea42008-01-10 16:53:55 +01006438 spec->vmaster_nid = 0x08;
6439
Linus Torvalds1da177e2005-04-16 15:20:36 -07006440 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006441 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006442 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006443#ifdef CONFIG_SND_HDA_POWER_SAVE
6444 if (!spec->loopback.amplist)
6445 spec->loopback.amplist = alc260_loopbacks;
6446#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006447 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006448
6449 return 0;
6450}
6451
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006452
Linus Torvalds1da177e2005-04-16 15:20:36 -07006453/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006454 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455 *
6456 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6457 * configuration. Each pin widget can choose any input DACs and a mixer.
6458 * Each ADC is connected from a mixer of all inputs. This makes possible
6459 * 6-channel independent captures.
6460 *
6461 * In addition, an independent DAC for the multi-playback (not used in this
6462 * driver yet).
6463 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006464#define ALC882_DIGOUT_NID 0x06
6465#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006466#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6467#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6468#define ALC1200_DIGOUT_NID 0x10
6469
Linus Torvalds1da177e2005-04-16 15:20:36 -07006470
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006471static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006472 { 8, NULL }
6473};
6474
Takashi Iwai4953550a2009-06-30 15:28:30 +02006475/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006476static hda_nid_t alc882_dac_nids[4] = {
6477 /* front, rear, clfe, rear_surr */
6478 0x02, 0x03, 0x04, 0x05
6479};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006480#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006481
Takashi Iwai4953550a2009-06-30 15:28:30 +02006482/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006483#define alc882_adc_nids alc880_adc_nids
6484#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006485#define alc883_adc_nids alc882_adc_nids_alt
6486static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6487static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6488#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006489
Takashi Iwaie1406342008-02-11 18:32:32 +01006490static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6491static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006492#define alc883_capsrc_nids alc882_capsrc_nids_alt
6493static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6494#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006495
Linus Torvalds1da177e2005-04-16 15:20:36 -07006496/* input MUX */
6497/* FIXME: should be a matrix-type input source selection */
6498
6499static struct hda_input_mux alc882_capture_source = {
6500 .num_items = 4,
6501 .items = {
6502 { "Mic", 0x0 },
6503 { "Front Mic", 0x1 },
6504 { "Line", 0x2 },
6505 { "CD", 0x4 },
6506 },
6507};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006508
Takashi Iwai4953550a2009-06-30 15:28:30 +02006509#define alc883_capture_source alc882_capture_source
6510
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006511static struct hda_input_mux alc889_capture_source = {
6512 .num_items = 3,
6513 .items = {
6514 { "Front Mic", 0x0 },
6515 { "Mic", 0x3 },
6516 { "Line", 0x2 },
6517 },
6518};
6519
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006520static struct hda_input_mux mb5_capture_source = {
6521 .num_items = 3,
6522 .items = {
6523 { "Mic", 0x1 },
6524 { "Line", 0x2 },
6525 { "CD", 0x4 },
6526 },
6527};
6528
Takashi Iwai4953550a2009-06-30 15:28:30 +02006529static struct hda_input_mux alc883_3stack_6ch_intel = {
6530 .num_items = 4,
6531 .items = {
6532 { "Mic", 0x1 },
6533 { "Front Mic", 0x0 },
6534 { "Line", 0x2 },
6535 { "CD", 0x4 },
6536 },
6537};
6538
6539static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6540 .num_items = 2,
6541 .items = {
6542 { "Mic", 0x1 },
6543 { "Line", 0x2 },
6544 },
6545};
6546
6547static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6548 .num_items = 4,
6549 .items = {
6550 { "Mic", 0x0 },
6551 { "iMic", 0x1 },
6552 { "Line", 0x2 },
6553 { "CD", 0x4 },
6554 },
6555};
6556
6557static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6558 .num_items = 2,
6559 .items = {
6560 { "Mic", 0x0 },
6561 { "Int Mic", 0x1 },
6562 },
6563};
6564
6565static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6566 .num_items = 3,
6567 .items = {
6568 { "Mic", 0x0 },
6569 { "Front Mic", 0x1 },
6570 { "Line", 0x4 },
6571 },
6572};
6573
6574static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6575 .num_items = 2,
6576 .items = {
6577 { "Mic", 0x0 },
6578 { "Line", 0x2 },
6579 },
6580};
6581
6582static struct hda_input_mux alc889A_mb31_capture_source = {
6583 .num_items = 2,
6584 .items = {
6585 { "Mic", 0x0 },
6586 /* Front Mic (0x01) unused */
6587 { "Line", 0x2 },
6588 /* Line 2 (0x03) unused */
6589 /* CD (0x04) unsused? */
6590 },
6591};
6592
6593/*
6594 * 2ch mode
6595 */
6596static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6597 { 2, NULL }
6598};
6599
Kailang Yangdf694da2005-12-05 19:42:22 +01006600/*
Kailang Yang272a5272007-05-14 11:00:38 +02006601 * 2ch mode
6602 */
6603static struct hda_verb alc882_3ST_ch2_init[] = {
6604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6606 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6607 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6608 { } /* end */
6609};
6610
6611/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006612 * 4ch mode
6613 */
6614static struct hda_verb alc882_3ST_ch4_init[] = {
6615 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6617 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6618 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6619 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6620 { } /* end */
6621};
6622
6623/*
Kailang Yang272a5272007-05-14 11:00:38 +02006624 * 6ch mode
6625 */
6626static struct hda_verb alc882_3ST_ch6_init[] = {
6627 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6628 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6629 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6630 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6631 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6632 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6633 { } /* end */
6634};
6635
Takashi Iwai4953550a2009-06-30 15:28:30 +02006636static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006637 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006638 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006639 { 6, alc882_3ST_ch6_init },
6640};
6641
Takashi Iwai4953550a2009-06-30 15:28:30 +02006642#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6643
Kailang Yang272a5272007-05-14 11:00:38 +02006644/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006645 * 6ch mode
6646 */
6647static struct hda_verb alc882_sixstack_ch6_init[] = {
6648 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6649 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6650 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6651 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6652 { } /* end */
6653};
6654
6655/*
6656 * 8ch mode
6657 */
6658static struct hda_verb alc882_sixstack_ch8_init[] = {
6659 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6660 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6661 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6662 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6663 { } /* end */
6664};
6665
6666static struct hda_channel_mode alc882_sixstack_modes[2] = {
6667 { 6, alc882_sixstack_ch6_init },
6668 { 8, alc882_sixstack_ch8_init },
6669};
6670
Takashi Iwai87350ad2007-08-16 18:19:38 +02006671/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006672 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006673 */
6674
6675/*
6676 * 2ch mode
6677 */
6678static struct hda_verb alc885_mbp_ch2_init[] = {
6679 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6680 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6681 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6682 { } /* end */
6683};
6684
6685/*
6686 * 6ch mode
6687 */
6688static struct hda_verb alc885_mbp_ch6_init[] = {
6689 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6690 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6691 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6692 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6693 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6694 { } /* end */
6695};
6696
6697static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6698 { 2, alc885_mbp_ch2_init },
6699 { 6, alc885_mbp_ch6_init },
6700};
6701
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006702/*
6703 * 2ch
6704 * Speakers/Woofer/HP = Front
6705 * LineIn = Input
6706 */
6707static struct hda_verb alc885_mb5_ch2_init[] = {
6708 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6709 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6710 { } /* end */
6711};
6712
6713/*
6714 * 6ch mode
6715 * Speakers/HP = Front
6716 * Woofer = LFE
6717 * LineIn = Surround
6718 */
6719static struct hda_verb alc885_mb5_ch6_init[] = {
6720 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6722 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6723 { } /* end */
6724};
6725
6726static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6727 { 2, alc885_mb5_ch2_init },
6728 { 6, alc885_mb5_ch6_init },
6729};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006730
Takashi Iwai4953550a2009-06-30 15:28:30 +02006731
6732/*
6733 * 2ch mode
6734 */
6735static struct hda_verb alc883_4ST_ch2_init[] = {
6736 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6737 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6740 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6741 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6742 { } /* end */
6743};
6744
6745/*
6746 * 4ch mode
6747 */
6748static struct hda_verb alc883_4ST_ch4_init[] = {
6749 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6750 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6751 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6752 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6753 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6754 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6755 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6756 { } /* end */
6757};
6758
6759/*
6760 * 6ch mode
6761 */
6762static struct hda_verb alc883_4ST_ch6_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_OUT },
6766 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6767 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6768 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6769 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6770 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6771 { } /* end */
6772};
6773
6774/*
6775 * 8ch mode
6776 */
6777static struct hda_verb alc883_4ST_ch8_init[] = {
6778 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6779 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6780 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6781 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6782 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6783 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6784 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6785 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6786 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6787 { } /* end */
6788};
6789
6790static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6791 { 2, alc883_4ST_ch2_init },
6792 { 4, alc883_4ST_ch4_init },
6793 { 6, alc883_4ST_ch6_init },
6794 { 8, alc883_4ST_ch8_init },
6795};
6796
6797
6798/*
6799 * 2ch mode
6800 */
6801static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6802 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6803 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6804 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6805 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6806 { } /* end */
6807};
6808
6809/*
6810 * 4ch mode
6811 */
6812static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6813 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6814 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6815 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6816 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6817 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6818 { } /* end */
6819};
6820
6821/*
6822 * 6ch mode
6823 */
6824static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6825 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6826 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6827 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6828 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6829 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6830 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6831 { } /* end */
6832};
6833
6834static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6835 { 2, alc883_3ST_ch2_intel_init },
6836 { 4, alc883_3ST_ch4_intel_init },
6837 { 6, alc883_3ST_ch6_intel_init },
6838};
6839
6840/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006841 * 2ch mode
6842 */
6843static struct hda_verb alc889_ch2_intel_init[] = {
6844 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6845 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6846 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6847 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6850 { } /* end */
6851};
6852
6853/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006854 * 6ch mode
6855 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006856static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006857 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6858 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6859 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6860 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6861 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006862 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6863 { } /* end */
6864};
6865
6866/*
6867 * 8ch mode
6868 */
6869static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006870 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6871 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6872 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6873 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6874 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006875 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6876 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006877 { } /* end */
6878};
6879
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006880static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6881 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006882 { 6, alc889_ch6_intel_init },
6883 { 8, alc889_ch8_intel_init },
6884};
6885
6886/*
6887 * 6ch mode
6888 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006889static struct hda_verb alc883_sixstack_ch6_init[] = {
6890 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6891 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6892 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6893 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6894 { } /* end */
6895};
6896
6897/*
6898 * 8ch mode
6899 */
6900static struct hda_verb alc883_sixstack_ch8_init[] = {
6901 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6902 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6903 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6904 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6905 { } /* end */
6906};
6907
6908static struct hda_channel_mode alc883_sixstack_modes[2] = {
6909 { 6, alc883_sixstack_ch6_init },
6910 { 8, alc883_sixstack_ch8_init },
6911};
6912
6913
Linus Torvalds1da177e2005-04-16 15:20:36 -07006914/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6915 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6916 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006917static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006919 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006920 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006921 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006922 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6923 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006924 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6925 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006926 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006927 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6929 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6930 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6936 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006937 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006938 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006939 { } /* end */
6940};
6941
Takashi Iwai87350ad2007-08-16 18:19:38 +02006942static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006943 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6944 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6945 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6946 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6948 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6950 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006951 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006952 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6953 { } /* end */
6954};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006955
6956static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6958 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6959 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6960 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6961 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6962 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6963 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6964 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006965 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6966 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6967 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6968 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6969 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6970 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6971 { } /* end */
6972};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006973
Kailang Yangbdd148a2007-05-08 15:19:08 +02006974static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6975 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6976 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6979 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, 0x0, HDA_INPUT),
6982 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006984 { } /* end */
6985};
6986
Kailang Yang272a5272007-05-14 11:00:38 +02006987static struct snd_kcontrol_new alc882_targa_mixer[] = {
6988 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6989 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
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_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006998 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6999 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007000 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007001 { } /* end */
7002};
7003
7004/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7005 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7006 */
7007static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7008 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7009 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7011 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7012 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7013 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7014 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7015 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7016 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7017 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7019 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007020 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007021 { } /* end */
7022};
7023
Takashi Iwai914759b2007-09-06 14:52:04 +02007024static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7025 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7026 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7028 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7029 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7030 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7031 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7033 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7034 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007035 { } /* end */
7036};
7037
Kailang Yangdf694da2005-12-05 19:42:22 +01007038static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7039 {
7040 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7041 .name = "Channel Mode",
7042 .info = alc_ch_mode_info,
7043 .get = alc_ch_mode_get,
7044 .put = alc_ch_mode_put,
7045 },
7046 { } /* end */
7047};
7048
Takashi Iwai4953550a2009-06-30 15:28:30 +02007049static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007050 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7052 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7053 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007054 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007055 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007058 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7060 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7061 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007062 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007063 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7064 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7065 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007066
Takashi Iwaicb638122009-07-03 10:56:10 +02007067 /* mute analog input loopbacks */
7068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7073
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007074 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007075 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007076 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007077 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007078 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007080 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007082 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007083 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007084 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007085 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007086 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007089 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007090 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007091 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007092 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7093 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007094 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007095 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7096 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007098 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7099 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7101 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7102 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007103 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007104 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007105
7106 /* FIXME: use matrix-type input source selection */
7107 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007108 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007113 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007118 /* ADC2: mute amp left and right */
7119 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007120 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007121 /* ADC3: mute amp left and right */
7122 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007123 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007124
7125 { }
7126};
7127
Takashi Iwai4953550a2009-06-30 15:28:30 +02007128static struct hda_verb alc882_adc1_init_verbs[] = {
7129 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7131 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7132 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7133 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7134 /* ADC1: mute amp left and right */
7135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7136 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7137 { }
7138};
7139
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007140static struct hda_verb alc882_eapd_verbs[] = {
7141 /* change to EAPD mode */
7142 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007143 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007144 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007145};
7146
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007147static struct hda_verb alc889_eapd_verbs[] = {
7148 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7149 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7150 { }
7151};
7152
Wu Fengguang6732bd02009-07-30 09:19:14 +02007153static struct hda_verb alc_hp15_unsol_verbs[] = {
7154 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7156 {}
7157};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007158
7159static struct hda_verb alc885_init_verbs[] = {
7160 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7164 /* Rear mixer */
7165 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7168 /* CLFE mixer */
7169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7172 /* Side mixer */
7173 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7174 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7176
7177 /* mute analog input loopbacks */
7178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7179 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7180 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7181
7182 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7185 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7186 /* Front Pin: output 0 (0x0c) */
7187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7189 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7190 /* Rear Pin: output 1 (0x0d) */
7191 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7193 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7194 /* CLFE Pin: output 2 (0x0e) */
7195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7197 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7198 /* Side Pin: output 3 (0x0f) */
7199 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7200 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7201 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7202 /* Mic (rear) pin: input vref at 80% */
7203 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7204 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7205 /* Front Mic pin: input vref at 80% */
7206 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7207 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7208 /* Line In pin: input */
7209 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7211
7212 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7213 /* Input mixer1 */
7214 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7215 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7216 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7217 /* Input mixer2 */
7218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7220 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7221 /* Input mixer3 */
7222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7225 /* ADC2: mute amp left and right */
7226 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7227 /* ADC3: mute amp left and right */
7228 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7229
7230 { }
7231};
7232
7233static struct hda_verb alc885_init_input_verbs[] = {
7234 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7235 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7236 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7237 { }
7238};
7239
7240
7241/* Unmute Selector 24h and set the default input to front mic */
7242static struct hda_verb alc889_init_input_verbs[] = {
7243 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7245 { }
7246};
7247
7248
Takashi Iwai4953550a2009-06-30 15:28:30 +02007249#define alc883_init_verbs alc882_base_init_verbs
7250
Tobin Davis9102cd12006-12-15 10:02:12 +01007251/* Mac Pro test */
7252static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7254 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7256 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7257 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007258 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007259 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7260 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007261 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007262 { } /* end */
7263};
7264
7265static struct hda_verb alc882_macpro_init_verbs[] = {
7266 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7268 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7269 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7270 /* Front Pin: output 0 (0x0c) */
7271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7272 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7273 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7274 /* Front Mic pin: input vref at 80% */
7275 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7277 /* Speaker: output */
7278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7280 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7281 /* Headphone output (output 0 - 0x0c) */
7282 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7283 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7284 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7285
7286 /* FIXME: use matrix-type input source selection */
7287 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7288 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7290 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7291 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7292 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7293 /* Input mixer2 */
7294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7295 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7296 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7297 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7298 /* Input mixer3 */
7299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7302 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7303 /* ADC1: mute amp left and right */
7304 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7305 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7306 /* ADC2: mute amp left and right */
7307 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7308 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7309 /* ADC3: mute amp left and right */
7310 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7311 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7312
7313 { }
7314};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007315
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007316/* Macbook 5,1 */
7317static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007318 /* DACs */
7319 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7320 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7321 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7322 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007323 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007324 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007327 /* Surround mixer */
7328 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7329 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7330 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7331 /* LFE mixer */
7332 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7335 /* HP mixer */
7336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7337 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7338 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7339 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007340 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7341 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007342 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7343 /* LFE Pin (0x0e) */
7344 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7345 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7346 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7347 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007350 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007351 /* Front Mic pin: input vref at 80% */
7352 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7353 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7354 /* Line In pin */
7355 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7356 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7357
7358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7359 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7361 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7362 { }
7363};
7364
Takashi Iwai87350ad2007-08-16 18:19:38 +02007365/* Macbook Pro rev3 */
7366static struct hda_verb alc885_mbp3_init_verbs[] = {
7367 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7371 /* Rear mixer */
7372 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7375 /* Front Pin: output 0 (0x0c) */
7376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7377 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7378 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7379 /* HP Pin: output 0 (0x0d) */
7380 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7381 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7382 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7384 /* Mic (rear) pin: input vref at 80% */
7385 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7386 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7387 /* Front Mic pin: input vref at 80% */
7388 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7389 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7390 /* Line In pin: use output 1 when in LineOut mode */
7391 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7392 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7394
7395 /* FIXME: use matrix-type input source selection */
7396 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7397 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7398 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7399 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7400 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7401 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7402 /* Input mixer2 */
7403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7404 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7405 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7406 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7407 /* Input mixer3 */
7408 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7409 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7410 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7411 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7412 /* ADC1: mute amp left and right */
7413 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7414 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7415 /* ADC2: mute amp left and right */
7416 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7417 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7418 /* ADC3: mute amp left and right */
7419 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7420 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7421
7422 { }
7423};
7424
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007425/* iMac 24 mixer. */
7426static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7427 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7428 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7429 { } /* end */
7430};
7431
7432/* iMac 24 init verbs. */
7433static struct hda_verb alc885_imac24_init_verbs[] = {
7434 /* Internal speakers: output 0 (0x0c) */
7435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7437 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7438 /* Internal speakers: output 0 (0x0c) */
7439 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7441 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7442 /* Headphone: output 0 (0x0c) */
7443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7445 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7446 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7447 /* Front Mic: input vref at 80% */
7448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7450 { }
7451};
7452
7453/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007454static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007455{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007456 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007457
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007458 spec->autocfg.hp_pins[0] = 0x14;
7459 spec->autocfg.speaker_pins[0] = 0x18;
7460 spec->autocfg.speaker_pins[1] = 0x1a;
7461 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007462}
7463
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007464static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007466 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007467
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007468 spec->autocfg.hp_pins[0] = 0x15;
7469 spec->autocfg.speaker_pins[0] = 0x14;
7470 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02007471}
7472
7473
Kailang Yang272a5272007-05-14 11:00:38 +02007474static struct hda_verb alc882_targa_verbs[] = {
7475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7477
7478 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007480
Kailang Yang272a5272007-05-14 11:00:38 +02007481 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7482 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7483 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7484
7485 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007486 { } /* end */
7487};
7488
7489/* toggle speaker-output according to the hp-jack state */
7490static void alc882_targa_automute(struct hda_codec *codec)
7491{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007492 struct alc_spec *spec = codec->spec;
7493 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007494 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007495 spec->jack_present ? 1 : 3);
7496}
7497
7498static void alc882_targa_init_hook(struct hda_codec *codec)
7499{
7500 struct alc_spec *spec = codec->spec;
7501
7502 spec->autocfg.hp_pins[0] = 0x14;
7503 spec->autocfg.speaker_pins[0] = 0x1b;
7504 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007505}
7506
7507static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7508{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007509 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007510 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007511}
7512
7513static struct hda_verb alc882_asus_a7j_verbs[] = {
7514 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7515 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7516
7517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7518 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7519 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007520
Kailang Yang272a5272007-05-14 11:00:38 +02007521 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7522 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7523 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7524
7525 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7526 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7527 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7528 { } /* end */
7529};
7530
Takashi Iwai914759b2007-09-06 14:52:04 +02007531static struct hda_verb alc882_asus_a7m_verbs[] = {
7532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7534
7535 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7536 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007538
Takashi Iwai914759b2007-09-06 14:52:04 +02007539 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7540 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7541 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7542
7543 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7544 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7545 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7546 { } /* end */
7547};
7548
Tobin Davis9102cd12006-12-15 10:02:12 +01007549static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7550{
7551 unsigned int gpiostate, gpiomask, gpiodir;
7552
7553 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7554 AC_VERB_GET_GPIO_DATA, 0);
7555
7556 if (!muted)
7557 gpiostate |= (1 << pin);
7558 else
7559 gpiostate &= ~(1 << pin);
7560
7561 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7562 AC_VERB_GET_GPIO_MASK, 0);
7563 gpiomask |= (1 << pin);
7564
7565 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7566 AC_VERB_GET_GPIO_DIRECTION, 0);
7567 gpiodir |= (1 << pin);
7568
7569
7570 snd_hda_codec_write(codec, codec->afg, 0,
7571 AC_VERB_SET_GPIO_MASK, gpiomask);
7572 snd_hda_codec_write(codec, codec->afg, 0,
7573 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7574
7575 msleep(1);
7576
7577 snd_hda_codec_write(codec, codec->afg, 0,
7578 AC_VERB_SET_GPIO_DATA, gpiostate);
7579}
7580
Takashi Iwai7debbe52007-08-16 15:01:03 +02007581/* set up GPIO at initialization */
7582static void alc885_macpro_init_hook(struct hda_codec *codec)
7583{
7584 alc882_gpio_mute(codec, 0, 0);
7585 alc882_gpio_mute(codec, 1, 0);
7586}
7587
7588/* set up GPIO and update auto-muting at initialization */
7589static void alc885_imac24_init_hook(struct hda_codec *codec)
7590{
7591 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007592 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007593}
7594
Kailang Yangdf694da2005-12-05 19:42:22 +01007595/*
7596 * generic initialization of ADC, input mixers and output mixers
7597 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007598static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007599 /*
7600 * Unmute ADC0-2 and set the default input to mic-in
7601 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007602 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7603 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7604 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7606
Takashi Iwaicb53c622007-08-10 17:21:45 +02007607 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007608 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007609 * Note: PASD motherboards uses the Line In 2 as the input for
7610 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007611 */
7612 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007613 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7614 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7615 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7616 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7617 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007618
7619 /*
7620 * Set up output mixers (0x0c - 0x0f)
7621 */
7622 /* set vol=0 to output mixers */
7623 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7626 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7627 /* set up input amps for analog loopback */
7628 /* Amp Indices: DAC = 0, mixer = 1 */
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7633 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7634 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7635 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7636 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7637 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7638 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7639
7640 /* FIXME: use matrix-type input source selection */
7641 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007642 /* Input mixer2 */
7643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7645 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7646 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7647 /* Input mixer3 */
7648 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7649 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7652
7653 { }
7654};
7655
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007656/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7657static struct hda_verb alc889A_mb31_ch2_init[] = {
7658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7659 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7660 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7661 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7662 { } /* end */
7663};
7664
7665/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7666static struct hda_verb alc889A_mb31_ch4_init[] = {
7667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7668 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7670 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7671 { } /* end */
7672};
7673
7674/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7675static struct hda_verb alc889A_mb31_ch5_init[] = {
7676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7678 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7679 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7680 { } /* end */
7681};
7682
7683/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7684static struct hda_verb alc889A_mb31_ch6_init[] = {
7685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7687 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7688 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7689 { } /* end */
7690};
7691
7692static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7693 { 2, alc889A_mb31_ch2_init },
7694 { 4, alc889A_mb31_ch4_init },
7695 { 5, alc889A_mb31_ch5_init },
7696 { 6, alc889A_mb31_ch6_init },
7697};
7698
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007699static struct hda_verb alc883_medion_eapd_verbs[] = {
7700 /* eanable EAPD on medion laptop */
7701 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7702 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7703 { }
7704};
7705
Takashi Iwai4953550a2009-06-30 15:28:30 +02007706#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007707
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007708static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7709 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7710 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7711 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7712 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7713 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7714 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7716 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7717 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7718 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7719 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7720 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7721 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007722 { } /* end */
7723};
7724
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007725static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007726 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7727 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7729 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7731 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7734 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7735 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007736 { } /* end */
7737};
7738
Jiang zhefb97dc62008-03-06 11:07:11 +01007739static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7740 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7741 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7742 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7743 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7746 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7749 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007750 { } /* end */
7751};
7752
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007753static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7754 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7755 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7757 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7758 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7760 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007762 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7764 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007765 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007766 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007767 { } /* end */
7768};
7769
7770static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7771 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7772 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7773 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7774 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7775 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7776 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7777 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7778 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7780 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7781 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7787 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007788 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007789 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007790 { } /* end */
7791};
7792
Jiang zhe17bba1b2008-06-04 12:11:07 +02007793static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7794 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7795 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7796 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7797 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7798 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7799 HDA_OUTPUT),
7800 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7801 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7802 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7807 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7808 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7811 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7812 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7813 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007814 { } /* end */
7815};
7816
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007817static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7818 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7819 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7820 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7821 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7822 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7823 HDA_OUTPUT),
7824 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7825 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7826 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7828 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7830 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7831 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7833 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7834 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7835 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7836 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7838 { } /* end */
7839};
7840
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007841static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007842 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007843 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007844 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007845 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007846 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7847 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007848 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7849 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7854 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007856 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007861 { } /* end */
7862};
7863
Sasha Alexandrc2592492009-06-16 14:52:54 -04007864static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007865 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7867 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7869 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7871 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7873 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007881 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007882};
Kailang Yangccc656c2006-10-17 12:32:26 +02007883
Sasha Alexandrc2592492009-06-16 14:52:54 -04007884static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007885 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7886 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7887 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7888 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7889 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7890 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007893 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7894 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7895 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007896 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007897};
Kailang Yangccc656c2006-10-17 12:32:26 +02007898
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007899static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7900 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7901 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007902 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7903 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7905 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7906 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7907 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007908 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007909};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007910
Kailang Yang272a5272007-05-14 11:00:38 +02007911static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7912 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7913 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7915 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7916 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7919 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7920 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007921 { } /* end */
7922};
7923
7924static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7925 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7927 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7928 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7929 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007934 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007935};
Kailang Yang272a5272007-05-14 11:00:38 +02007936
Tobin Davis2880a862007-08-07 11:50:26 +02007937static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007938 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7939 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007940 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007941 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7942 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007943 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7945 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007946 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007947};
Tobin Davis2880a862007-08-07 11:50:26 +02007948
Tony Vroond2fd4b02009-06-21 00:40:10 +01007949static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7950 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7951 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7952 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7953 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007956 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7957 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7961 { } /* end */
7962};
7963
Kailang Yange2757d52008-08-26 13:17:46 +02007964static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7966 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7967 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7968 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7969 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7970 0x0d, 1, 0x0, HDA_OUTPUT),
7971 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7972 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7973 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7974 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7975 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007976 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7977 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7979 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7981 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7983 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7985 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007986 { } /* end */
7987};
7988
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007989static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7990 /* Output mixers */
7991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7993 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7994 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7995 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7996 HDA_OUTPUT),
7997 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7998 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7999 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8000 /* Output switches */
8001 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8002 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8003 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8004 /* Boost mixers */
8005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8006 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8007 /* Input mixers */
8008 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8011 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8012 { } /* end */
8013};
8014
Guido Günther3e1647c2009-06-05 00:47:26 +02008015static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8016 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8017 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8019 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8020 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8022 { } /* end */
8023};
8024
Kailang Yange2757d52008-08-26 13:17:46 +02008025static struct hda_bind_ctls alc883_bind_cap_vol = {
8026 .ops = &snd_hda_bind_vol,
8027 .values = {
8028 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8029 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8030 0
8031 },
8032};
8033
8034static struct hda_bind_ctls alc883_bind_cap_switch = {
8035 .ops = &snd_hda_bind_sw,
8036 .values = {
8037 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8038 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8039 0
8040 },
8041};
8042
8043static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8044 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8045 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8047 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8048 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8049 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8051 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008052 { } /* end */
8053};
8054
8055static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008056 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8057 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8058 {
8059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8060 /* .name = "Capture Source", */
8061 .name = "Input Source",
8062 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008063 .info = alc_mux_enum_info,
8064 .get = alc_mux_enum_get,
8065 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008066 },
8067 { } /* end */
8068};
8069
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008070static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8071 {
8072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8073 .name = "Channel Mode",
8074 .info = alc_ch_mode_info,
8075 .get = alc_ch_mode_get,
8076 .put = alc_ch_mode_put,
8077 },
8078 { } /* end */
8079};
8080
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008081/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008082static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008083{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008084 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008085
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008086 spec->autocfg.hp_pins[0] = 0x15;
8087 spec->autocfg.speaker_pins[0] = 0x14;
8088 spec->autocfg.speaker_pins[1] = 0x17;
8089 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008090}
8091
8092/* auto-toggle front mic */
8093/*
8094static void alc883_mitac_mic_automute(struct hda_codec *codec)
8095{
8096 unsigned int present;
8097 unsigned char bits;
8098
8099 present = snd_hda_codec_read(codec, 0x18, 0,
8100 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8101 bits = present ? HDA_AMP_MUTE : 0;
8102 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8103}
8104*/
8105
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008106static struct hda_verb alc883_mitac_verbs[] = {
8107 /* HP */
8108 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8110 /* Subwoofer */
8111 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8112 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8113
8114 /* enable unsolicited event */
8115 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8116 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8117
8118 { } /* end */
8119};
8120
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008121static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008122 /* HP */
8123 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8124 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8125 /* Int speaker */
8126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8128
8129 /* enable unsolicited event */
8130 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008131 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008132
8133 { } /* end */
8134};
8135
Jiang zhefb97dc62008-03-06 11:07:11 +01008136static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8137 /* HP */
8138 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8139 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8140 /* Subwoofer */
8141 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8143
8144 /* enable unsolicited event */
8145 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8146
8147 { } /* end */
8148};
8149
Sasha Alexandrc2592492009-06-16 14:52:54 -04008150static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8152 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8153
8154 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008156
David Heidelberger64a8be72009-06-08 16:15:18 +02008157/* Connect Line-Out side jack (SPDIF) to Side */
8158 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8159 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8161/* Connect Mic jack to CLFE */
8162 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8163 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8164 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8165/* Connect Line-in jack to Surround */
8166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8168 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8169/* Connect HP out jack to Front */
8170 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8171 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8172 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008173
8174 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008175
8176 { } /* end */
8177};
8178
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008179static struct hda_verb alc883_lenovo_101e_verbs[] = {
8180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8181 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8182 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8183 { } /* end */
8184};
8185
Kailang Yang272a5272007-05-14 11:00:38 +02008186static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8188 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8189 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8191 { } /* end */
8192};
8193
8194static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8195 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8196 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8198 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8199 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8200 { } /* end */
8201};
8202
Kailang Yang189609a2007-08-20 11:31:23 +02008203static struct hda_verb alc883_haier_w66_verbs[] = {
8204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8205 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8206
8207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8208
8209 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8210 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8211 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8212 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8213 { } /* end */
8214};
8215
Kailang Yange2757d52008-08-26 13:17:46 +02008216static struct hda_verb alc888_lenovo_sky_verbs[] = {
8217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8221 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8222 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8223 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8224 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8225 { } /* end */
8226};
8227
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008228static struct hda_verb alc888_6st_dell_verbs[] = {
8229 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8230 { }
8231};
8232
Guido Günther3e1647c2009-06-05 00:47:26 +02008233static struct hda_verb alc883_vaiott_verbs[] = {
8234 /* HP */
8235 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8237
8238 /* enable unsolicited event */
8239 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8240
8241 { } /* end */
8242};
8243
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008244static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008245{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008246 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008247
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008248 spec->autocfg.hp_pins[0] = 0x1b;
8249 spec->autocfg.speaker_pins[0] = 0x14;
8250 spec->autocfg.speaker_pins[1] = 0x16;
8251 spec->autocfg.speaker_pins[2] = 0x18;
8252 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008253}
8254
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008255static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008256 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008257 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8258 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008259 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008260 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008261};
8262
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008263/*
8264 * 2ch mode
8265 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008266static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008267 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8268 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8269 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8270 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008271 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008272};
8273
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008274/*
8275 * 4ch mode
8276 */
8277static struct hda_verb alc888_3st_hp_4ch_init[] = {
8278 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8279 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8280 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8281 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8282 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8283 { } /* end */
8284};
8285
8286/*
8287 * 6ch mode
8288 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008289static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008290 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8291 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008292 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008293 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8294 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008295 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8296 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008297};
8298
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008299static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008300 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008301 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008302 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008303};
8304
Kailang Yang272a5272007-05-14 11:00:38 +02008305/* toggle front-jack and RCA according to the hp-jack state */
8306static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8307{
8308 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008309
Kailang Yang272a5272007-05-14 11:00:38 +02008310 present = snd_hda_codec_read(codec, 0x1b, 0,
8311 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008312 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8313 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8314 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8315 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008316}
8317
8318/* toggle RCA according to the front-jack state */
8319static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8320{
8321 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008322
Kailang Yang272a5272007-05-14 11:00:38 +02008323 present = snd_hda_codec_read(codec, 0x14, 0,
8324 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008325 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8326 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008327}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008328
Kailang Yang272a5272007-05-14 11:00:38 +02008329static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8330 unsigned int res)
8331{
8332 if ((res >> 26) == ALC880_HP_EVENT)
8333 alc888_lenovo_ms7195_front_automute(codec);
8334 if ((res >> 26) == ALC880_FRONT_EVENT)
8335 alc888_lenovo_ms7195_rca_automute(codec);
8336}
8337
8338static struct hda_verb alc883_medion_md2_verbs[] = {
8339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8341
8342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8343
8344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8345 { } /* end */
8346};
8347
8348/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008349static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008350{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008351 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008352
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008353 spec->autocfg.hp_pins[0] = 0x14;
8354 spec->autocfg.speaker_pins[0] = 0x15;
8355 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008356}
8357
Kailang Yangccc656c2006-10-17 12:32:26 +02008358/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008359#define alc883_targa_init_hook alc882_targa_init_hook
8360#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008361
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008362static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8363{
8364 unsigned int present;
8365
8366 present = snd_hda_codec_read(codec, 0x18, 0,
8367 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8368 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8369 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8370}
8371
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008372static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008373{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008374 struct alc_spec *spec = codec->spec;
8375
8376 spec->autocfg.hp_pins[0] = 0x15;
8377 spec->autocfg.speaker_pins[0] = 0x14;
8378 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008379 alc883_clevo_m720_mic_automute(codec);
8380}
8381
8382static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008383 unsigned int res)
8384{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008385 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008386 case ALC880_MIC_EVENT:
8387 alc883_clevo_m720_mic_automute(codec);
8388 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008389 default:
8390 alc_automute_amp_unsol_event(codec, res);
8391 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008392 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008393}
8394
Jiang zhefb97dc62008-03-06 11:07:11 +01008395/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008396static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008398 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008400 spec->autocfg.hp_pins[0] = 0x14;
8401 spec->autocfg.speaker_pins[0] = 0x15;
8402 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008403}
8404
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008405static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008406{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008407 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008408
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008409 spec->autocfg.hp_pins[0] = 0x1b;
8410 spec->autocfg.speaker_pins[0] = 0x14;
8411 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008412}
8413
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008414static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8415{
8416 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008417 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008418
David Heidelberger64a8be72009-06-08 16:15:18 +02008419 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8420 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008421 bits = present ? HDA_AMP_MUTE : 0;
8422 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8423 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008424}
8425
8426static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8427{
8428 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008429 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008430
8431 present = snd_hda_codec_read(codec, 0x1b, 0,
8432 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008433 bits = present ? HDA_AMP_MUTE : 0;
8434 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8435 HDA_AMP_MUTE, bits);
8436 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8437 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008438}
8439
8440static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8441 unsigned int res)
8442{
8443 if ((res >> 26) == ALC880_HP_EVENT)
8444 alc883_lenovo_101e_all_automute(codec);
8445 if ((res >> 26) == ALC880_FRONT_EVENT)
8446 alc883_lenovo_101e_ispeaker_automute(codec);
8447}
8448
Takashi Iwai676a9b52007-08-16 15:23:35 +02008449/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008450static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008451{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008452 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008453
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008454 spec->autocfg.hp_pins[0] = 0x14;
8455 spec->autocfg.speaker_pins[0] = 0x15;
8456 spec->autocfg.speaker_pins[1] = 0x16;
8457 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008458}
8459
Kailang Yangd1a991a2007-08-15 16:21:59 +02008460static struct hda_verb alc883_acer_eapd_verbs[] = {
8461 /* HP Pin: output 0 (0x0c) */
8462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8464 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8465 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8467 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008468 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008469 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8470 /* eanable EAPD on medion laptop */
8471 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8472 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008473 /* enable unsolicited event */
8474 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008475 { }
8476};
8477
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008478static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008479{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008480 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008481
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008482 spec->autocfg.hp_pins[0] = 0x1b;
8483 spec->autocfg.speaker_pins[0] = 0x14;
8484 spec->autocfg.speaker_pins[1] = 0x15;
8485 spec->autocfg.speaker_pins[2] = 0x16;
8486 spec->autocfg.speaker_pins[3] = 0x17;
8487 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008488}
8489
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008490static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008491{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008492 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008493
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008494 spec->autocfg.hp_pins[0] = 0x1b;
8495 spec->autocfg.speaker_pins[0] = 0x14;
8496 spec->autocfg.speaker_pins[1] = 0x15;
8497 spec->autocfg.speaker_pins[2] = 0x16;
8498 spec->autocfg.speaker_pins[3] = 0x17;
8499 spec->autocfg.speaker_pins[4] = 0x1a;
8500 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008501}
8502
Guido Günther3e1647c2009-06-05 00:47:26 +02008503static void alc883_vaiott_init_hook(struct hda_codec *codec)
8504{
8505 struct alc_spec *spec = codec->spec;
8506
8507 spec->autocfg.hp_pins[0] = 0x15;
8508 spec->autocfg.speaker_pins[0] = 0x14;
8509 spec->autocfg.speaker_pins[1] = 0x17;
8510 alc_automute_amp(codec);
8511}
8512
Kailang Yange2757d52008-08-26 13:17:46 +02008513static struct hda_verb alc888_asus_m90v_verbs[] = {
8514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8515 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8516 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8517 /* enable unsolicited event */
8518 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8519 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8520 { } /* end */
8521};
8522
8523static void alc883_nb_mic_automute(struct hda_codec *codec)
8524{
8525 unsigned int present;
8526
8527 present = snd_hda_codec_read(codec, 0x18, 0,
8528 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8529 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8530 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8531 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8532 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8533}
8534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008536{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008537 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008538
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008539 spec->autocfg.hp_pins[0] = 0x1b;
8540 spec->autocfg.speaker_pins[0] = 0x14;
8541 spec->autocfg.speaker_pins[1] = 0x15;
8542 spec->autocfg.speaker_pins[2] = 0x16;
8543 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008544}
8545
8546static void alc883_mode2_unsol_event(struct hda_codec *codec,
8547 unsigned int res)
8548{
8549 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008550 case ALC880_MIC_EVENT:
8551 alc883_nb_mic_automute(codec);
8552 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008553 default:
8554 alc_sku_unsol_event(codec, res);
8555 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008556 }
8557}
8558
8559static void alc883_mode2_inithook(struct hda_codec *codec)
8560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008561 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008562 alc883_nb_mic_automute(codec);
8563}
8564
8565static struct hda_verb alc888_asus_eee1601_verbs[] = {
8566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8567 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8569 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8570 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8571 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8572 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8573 /* enable unsolicited event */
8574 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8575 { } /* end */
8576};
8577
Kailang Yange2757d52008-08-26 13:17:46 +02008578static void alc883_eee1601_inithook(struct hda_codec *codec)
8579{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008580 struct alc_spec *spec = codec->spec;
8581
8582 spec->autocfg.hp_pins[0] = 0x14;
8583 spec->autocfg.speaker_pins[0] = 0x1b;
8584 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008585}
8586
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008587static struct hda_verb alc889A_mb31_verbs[] = {
8588 /* Init rear pin (used as headphone output) */
8589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8590 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8591 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8592 /* Init line pin (used as output in 4ch and 6ch mode) */
8593 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8594 /* Init line 2 pin (used as headphone out by default) */
8595 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8596 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8597 { } /* end */
8598};
8599
8600/* Mute speakers according to the headphone jack state */
8601static void alc889A_mb31_automute(struct hda_codec *codec)
8602{
8603 unsigned int present;
8604
8605 /* Mute only in 2ch or 4ch mode */
8606 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8607 == 0x00) {
8608 present = snd_hda_codec_read(codec, 0x15, 0,
8609 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8610 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8611 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8612 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8613 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8614 }
8615}
8616
8617static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8618{
8619 if ((res >> 26) == ALC880_HP_EVENT)
8620 alc889A_mb31_automute(codec);
8621}
8622
Takashi Iwai4953550a2009-06-30 15:28:30 +02008623
Takashi Iwaicb53c622007-08-10 17:21:45 +02008624#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008625#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008626#endif
8627
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008628/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008629#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8630#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8631#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8632#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8633
8634static hda_nid_t alc883_slave_dig_outs[] = {
8635 ALC1200_DIGOUT_NID, 0,
8636};
8637
8638static hda_nid_t alc1200_slave_dig_outs[] = {
8639 ALC883_DIGOUT_NID, 0,
8640};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008641
8642/*
8643 * configuration and preset
8644 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008645static const char *alc882_models[ALC882_MODEL_LAST] = {
8646 [ALC882_3ST_DIG] = "3stack-dig",
8647 [ALC882_6ST_DIG] = "6stack-dig",
8648 [ALC882_ARIMA] = "arima",
8649 [ALC882_W2JC] = "w2jc",
8650 [ALC882_TARGA] = "targa",
8651 [ALC882_ASUS_A7J] = "asus-a7j",
8652 [ALC882_ASUS_A7M] = "asus-a7m",
8653 [ALC885_MACPRO] = "macpro",
8654 [ALC885_MB5] = "mb5",
8655 [ALC885_MBP3] = "mbp3",
8656 [ALC885_IMAC24] = "imac24",
8657 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008658 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8659 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008660 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008661 [ALC883_TARGA_DIG] = "targa-dig",
8662 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008663 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008664 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008665 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008666 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008667 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008668 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008669 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008670 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008671 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008672 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008673 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8674 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008675 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008676 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008677 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008678 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008679 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008680 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008681 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008682 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008683 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008684 [ALC889A_INTEL] = "intel-alc889a",
8685 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008686 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008687 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008688 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008689 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008690};
8691
Takashi Iwai4953550a2009-06-30 15:28:30 +02008692static struct snd_pci_quirk alc882_cfg_tbl[] = {
8693 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8694
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008695 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008696 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008697 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008698 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8699 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008700 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008701 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8702 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008703 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8704 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008705 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8706 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008707 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8708 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008709 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8710 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008711 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008712 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008713 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008714 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008715 /* default Acer -- disabled as it causes more problems.
8716 * model=auto should work fine now
8717 */
8718 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008719
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008720 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008721
Tobin Davisfebe3372007-06-12 11:27:46 +02008722 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008723 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8724 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008725 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008726 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008727 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008728
8729 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8730 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8731 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008732 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008733 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8734 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8735 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008736 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008737 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008738 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008739 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008740
8741 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008742 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008743 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008744 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008745 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8746 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008747 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008748 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008749 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8750
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008751 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8752 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8753 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008754 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008755 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008756 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008757 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008758 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008759 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8760 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8761 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8762 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8763 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8764 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008765 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008766 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8767 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8768 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008769 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008770 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8771 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008772 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008773 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008774 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008775 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008776 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008777 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008778 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008779 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008780
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008781 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008782 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8783 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008784 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008785 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008786 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008787 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008788 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008789 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008790 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008791 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008792 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008793 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008794 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8795 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008796 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008797 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008798 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008799 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008800 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008801
Jiang zhe17bba1b2008-06-04 12:11:07 +02008802 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8803 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008804 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008805 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8806 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8807 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008808 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008809
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008810 {}
8811};
8812
Takashi Iwai4953550a2009-06-30 15:28:30 +02008813/* codec SSID table for Intel Mac */
8814static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8815 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8816 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8817 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8818 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8819 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8820 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8821 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8822 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8823 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8824 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8825 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8826 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8827 * no perfect solution yet
8828 */
8829 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8830 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008831};
8832
Takashi Iwai4953550a2009-06-30 15:28:30 +02008833static struct alc_config_preset alc882_presets[] = {
8834 [ALC882_3ST_DIG] = {
8835 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008836 .init_verbs = { alc882_base_init_verbs,
8837 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008838 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8839 .dac_nids = alc882_dac_nids,
8840 .dig_out_nid = ALC882_DIGOUT_NID,
8841 .dig_in_nid = ALC882_DIGIN_NID,
8842 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8843 .channel_mode = alc882_ch_modes,
8844 .need_dac_fix = 1,
8845 .input_mux = &alc882_capture_source,
8846 },
8847 [ALC882_6ST_DIG] = {
8848 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008849 .init_verbs = { alc882_base_init_verbs,
8850 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008851 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8852 .dac_nids = alc882_dac_nids,
8853 .dig_out_nid = ALC882_DIGOUT_NID,
8854 .dig_in_nid = ALC882_DIGIN_NID,
8855 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8856 .channel_mode = alc882_sixstack_modes,
8857 .input_mux = &alc882_capture_source,
8858 },
8859 [ALC882_ARIMA] = {
8860 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008861 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8862 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008863 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8864 .dac_nids = alc882_dac_nids,
8865 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8866 .channel_mode = alc882_sixstack_modes,
8867 .input_mux = &alc882_capture_source,
8868 },
8869 [ALC882_W2JC] = {
8870 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008871 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8872 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008873 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8874 .dac_nids = alc882_dac_nids,
8875 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8876 .channel_mode = alc880_threestack_modes,
8877 .need_dac_fix = 1,
8878 .input_mux = &alc882_capture_source,
8879 .dig_out_nid = ALC882_DIGOUT_NID,
8880 },
8881 [ALC885_MBP3] = {
8882 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8883 .init_verbs = { alc885_mbp3_init_verbs,
8884 alc880_gpio1_init_verbs },
8885 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8886 .dac_nids = alc882_dac_nids,
8887 .channel_mode = alc885_mbp_6ch_modes,
8888 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8889 .input_mux = &alc882_capture_source,
8890 .dig_out_nid = ALC882_DIGOUT_NID,
8891 .dig_in_nid = ALC882_DIGIN_NID,
8892 .unsol_event = alc_automute_amp_unsol_event,
8893 .init_hook = alc885_mbp3_init_hook,
8894 },
8895 [ALC885_MB5] = {
8896 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8897 .init_verbs = { alc885_mb5_init_verbs,
8898 alc880_gpio1_init_verbs },
8899 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8900 .dac_nids = alc882_dac_nids,
8901 .channel_mode = alc885_mb5_6ch_modes,
8902 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8903 .input_mux = &mb5_capture_source,
8904 .dig_out_nid = ALC882_DIGOUT_NID,
8905 .dig_in_nid = ALC882_DIGIN_NID,
8906 },
8907 [ALC885_MACPRO] = {
8908 .mixers = { alc882_macpro_mixer },
8909 .init_verbs = { alc882_macpro_init_verbs },
8910 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8911 .dac_nids = alc882_dac_nids,
8912 .dig_out_nid = ALC882_DIGOUT_NID,
8913 .dig_in_nid = ALC882_DIGIN_NID,
8914 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8915 .channel_mode = alc882_ch_modes,
8916 .input_mux = &alc882_capture_source,
8917 .init_hook = alc885_macpro_init_hook,
8918 },
8919 [ALC885_IMAC24] = {
8920 .mixers = { alc885_imac24_mixer },
8921 .init_verbs = { alc885_imac24_init_verbs },
8922 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8923 .dac_nids = alc882_dac_nids,
8924 .dig_out_nid = ALC882_DIGOUT_NID,
8925 .dig_in_nid = ALC882_DIGIN_NID,
8926 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8927 .channel_mode = alc882_ch_modes,
8928 .input_mux = &alc882_capture_source,
8929 .unsol_event = alc_automute_amp_unsol_event,
8930 .init_hook = alc885_imac24_init_hook,
8931 },
8932 [ALC882_TARGA] = {
8933 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008934 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008935 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008936 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8937 .dac_nids = alc882_dac_nids,
8938 .dig_out_nid = ALC882_DIGOUT_NID,
8939 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8940 .adc_nids = alc882_adc_nids,
8941 .capsrc_nids = alc882_capsrc_nids,
8942 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8943 .channel_mode = alc882_3ST_6ch_modes,
8944 .need_dac_fix = 1,
8945 .input_mux = &alc882_capture_source,
8946 .unsol_event = alc882_targa_unsol_event,
8947 .init_hook = alc882_targa_init_hook,
8948 },
8949 [ALC882_ASUS_A7J] = {
8950 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008951 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8952 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008953 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8954 .dac_nids = alc882_dac_nids,
8955 .dig_out_nid = ALC882_DIGOUT_NID,
8956 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8957 .adc_nids = alc882_adc_nids,
8958 .capsrc_nids = alc882_capsrc_nids,
8959 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8960 .channel_mode = alc882_3ST_6ch_modes,
8961 .need_dac_fix = 1,
8962 .input_mux = &alc882_capture_source,
8963 },
8964 [ALC882_ASUS_A7M] = {
8965 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008966 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8967 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008968 alc882_asus_a7m_verbs },
8969 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8970 .dac_nids = alc882_dac_nids,
8971 .dig_out_nid = ALC882_DIGOUT_NID,
8972 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8973 .channel_mode = alc880_threestack_modes,
8974 .need_dac_fix = 1,
8975 .input_mux = &alc882_capture_source,
8976 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008977 [ALC883_3ST_2ch_DIG] = {
8978 .mixers = { alc883_3ST_2ch_mixer },
8979 .init_verbs = { alc883_init_verbs },
8980 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8981 .dac_nids = alc883_dac_nids,
8982 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008983 .dig_in_nid = ALC883_DIGIN_NID,
8984 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8985 .channel_mode = alc883_3ST_2ch_modes,
8986 .input_mux = &alc883_capture_source,
8987 },
8988 [ALC883_3ST_6ch_DIG] = {
8989 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8990 .init_verbs = { alc883_init_verbs },
8991 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8992 .dac_nids = alc883_dac_nids,
8993 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008994 .dig_in_nid = ALC883_DIGIN_NID,
8995 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8996 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008997 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008998 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008999 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009000 [ALC883_3ST_6ch] = {
9001 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9002 .init_verbs = { alc883_init_verbs },
9003 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9004 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009005 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9006 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009007 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009008 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009009 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009010 [ALC883_3ST_6ch_INTEL] = {
9011 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9012 .init_verbs = { alc883_init_verbs },
9013 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9014 .dac_nids = alc883_dac_nids,
9015 .dig_out_nid = ALC883_DIGOUT_NID,
9016 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009017 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009018 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9019 .channel_mode = alc883_3ST_6ch_intel_modes,
9020 .need_dac_fix = 1,
9021 .input_mux = &alc883_3stack_6ch_intel,
9022 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009023 [ALC889A_INTEL] = {
9024 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009025 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9026 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009027 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9028 .dac_nids = alc883_dac_nids,
9029 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9030 .adc_nids = alc889_adc_nids,
9031 .dig_out_nid = ALC883_DIGOUT_NID,
9032 .dig_in_nid = ALC883_DIGIN_NID,
9033 .slave_dig_outs = alc883_slave_dig_outs,
9034 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9035 .channel_mode = alc889_8ch_intel_modes,
9036 .capsrc_nids = alc889_capsrc_nids,
9037 .input_mux = &alc889_capture_source,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009038 .init_hook = alc889_automute_init,
9039 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009040 .need_dac_fix = 1,
9041 },
9042 [ALC889_INTEL] = {
9043 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9044 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009045 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009046 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9047 .dac_nids = alc883_dac_nids,
9048 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9049 .adc_nids = alc889_adc_nids,
9050 .dig_out_nid = ALC883_DIGOUT_NID,
9051 .dig_in_nid = ALC883_DIGIN_NID,
9052 .slave_dig_outs = alc883_slave_dig_outs,
9053 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9054 .channel_mode = alc889_8ch_intel_modes,
9055 .capsrc_nids = alc889_capsrc_nids,
9056 .input_mux = &alc889_capture_source,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009057 .init_hook = alc889_intel_init_hook,
9058 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009059 .need_dac_fix = 1,
9060 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009061 [ALC883_6ST_DIG] = {
9062 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9063 .init_verbs = { alc883_init_verbs },
9064 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9065 .dac_nids = alc883_dac_nids,
9066 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009067 .dig_in_nid = ALC883_DIGIN_NID,
9068 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9069 .channel_mode = alc883_sixstack_modes,
9070 .input_mux = &alc883_capture_source,
9071 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009072 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009073 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009074 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9075 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009076 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9077 .dac_nids = alc883_dac_nids,
9078 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009079 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9080 .channel_mode = alc883_3ST_6ch_modes,
9081 .need_dac_fix = 1,
9082 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009083 .unsol_event = alc883_targa_unsol_event,
9084 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009085 },
9086 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009087 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009088 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9089 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009090 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9091 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009092 .adc_nids = alc883_adc_nids_alt,
9093 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009094 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009095 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9096 .channel_mode = alc883_3ST_2ch_modes,
9097 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009098 .unsol_event = alc883_targa_unsol_event,
9099 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009100 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009101 [ALC883_TARGA_8ch_DIG] = {
9102 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9103 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009104 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9106 .dac_nids = alc883_dac_nids,
9107 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9108 .adc_nids = alc883_adc_nids_rev,
9109 .capsrc_nids = alc883_capsrc_nids_rev,
9110 .dig_out_nid = ALC883_DIGOUT_NID,
9111 .dig_in_nid = ALC883_DIGIN_NID,
9112 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9113 .channel_mode = alc883_4ST_8ch_modes,
9114 .need_dac_fix = 1,
9115 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009116 .unsol_event = alc883_targa_unsol_event,
9117 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009118 },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009119 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009120 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009121 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9122 * and the headphone jack. Turn this on and rely on the
9123 * standard mute methods whenever the user wants to turn
9124 * these outputs off.
9125 */
9126 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9127 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9128 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b2006-08-22 13:31:58 +02009129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9130 .channel_mode = alc883_3ST_2ch_modes,
9131 .input_mux = &alc883_capture_source,
9132 },
Tobin Davis2880a862007-08-07 11:50:26 +02009133 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009134 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009135 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009136 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9137 .dac_nids = alc883_dac_nids,
9138 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009139 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9140 .channel_mode = alc883_3ST_2ch_modes,
9141 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009142 .unsol_event = alc_automute_amp_unsol_event,
9143 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009144 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009145 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009146 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009147 alc883_chmode_mixer },
9148 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9149 alc888_acer_aspire_4930g_verbs },
9150 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9151 .dac_nids = alc883_dac_nids,
9152 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9153 .adc_nids = alc883_adc_nids_rev,
9154 .capsrc_nids = alc883_capsrc_nids_rev,
9155 .dig_out_nid = ALC883_DIGOUT_NID,
9156 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9157 .channel_mode = alc883_3ST_6ch_modes,
9158 .need_dac_fix = 1,
9159 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009160 ARRAY_SIZE(alc888_2_capture_sources),
9161 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009162 .unsol_event = alc_automute_amp_unsol_event,
9163 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009164 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009165 [ALC888_ACER_ASPIRE_6530G] = {
9166 .mixers = { alc888_acer_aspire_6530_mixer },
9167 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9168 alc888_acer_aspire_6530g_verbs },
9169 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9170 .dac_nids = alc883_dac_nids,
9171 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9172 .adc_nids = alc883_adc_nids_rev,
9173 .capsrc_nids = alc883_capsrc_nids_rev,
9174 .dig_out_nid = ALC883_DIGOUT_NID,
9175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9176 .channel_mode = alc883_3ST_2ch_modes,
9177 .num_mux_defs =
9178 ARRAY_SIZE(alc888_2_capture_sources),
9179 .input_mux = alc888_acer_aspire_6530_sources,
9180 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009181 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009182 },
Hector Martin3b315d72009-06-02 10:54:19 +02009183 [ALC888_ACER_ASPIRE_8930G] = {
9184 .mixers = { alc888_base_mixer,
9185 alc883_chmode_mixer },
9186 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009187 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9189 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009190 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9191 .adc_nids = alc889_adc_nids,
9192 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009193 .dig_out_nid = ALC883_DIGOUT_NID,
9194 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9195 .channel_mode = alc883_3ST_6ch_modes,
9196 .need_dac_fix = 1,
9197 .const_channel_count = 6,
9198 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009199 ARRAY_SIZE(alc889_capture_sources),
9200 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009201 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009202 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009203 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009204 [ALC883_MEDION] = {
9205 .mixers = { alc883_fivestack_mixer,
9206 alc883_chmode_mixer },
9207 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009208 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009209 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9210 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009211 .adc_nids = alc883_adc_nids_alt,
9212 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009213 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9214 .channel_mode = alc883_sixstack_modes,
9215 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009216 },
Kailang Yang272a5272007-05-14 11:00:38 +02009217 [ALC883_MEDION_MD2] = {
9218 .mixers = { alc883_medion_md2_mixer},
9219 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9220 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9221 .dac_nids = alc883_dac_nids,
9222 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009223 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9224 .channel_mode = alc883_3ST_2ch_modes,
9225 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009226 .unsol_event = alc_automute_amp_unsol_event,
9227 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009228 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009229 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009230 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009231 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9232 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9233 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009234 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9235 .channel_mode = alc883_3ST_2ch_modes,
9236 .input_mux = &alc883_capture_source,
9237 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009238 [ALC883_CLEVO_M720] = {
9239 .mixers = { alc883_clevo_m720_mixer },
9240 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009241 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9242 .dac_nids = alc883_dac_nids,
9243 .dig_out_nid = ALC883_DIGOUT_NID,
9244 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9245 .channel_mode = alc883_3ST_2ch_modes,
9246 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009247 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009248 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009249 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009250 [ALC883_LENOVO_101E_2ch] = {
9251 .mixers = { alc883_lenovo_101e_2ch_mixer},
9252 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9254 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009255 .adc_nids = alc883_adc_nids_alt,
9256 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009257 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9258 .channel_mode = alc883_3ST_2ch_modes,
9259 .input_mux = &alc883_lenovo_101e_capture_source,
9260 .unsol_event = alc883_lenovo_101e_unsol_event,
9261 .init_hook = alc883_lenovo_101e_all_automute,
9262 },
Kailang Yang272a5272007-05-14 11:00:38 +02009263 [ALC883_LENOVO_NB0763] = {
9264 .mixers = { alc883_lenovo_nb0763_mixer },
9265 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9267 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009268 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9269 .channel_mode = alc883_3ST_2ch_modes,
9270 .need_dac_fix = 1,
9271 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009272 .unsol_event = alc_automute_amp_unsol_event,
9273 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009274 },
9275 [ALC888_LENOVO_MS7195_DIG] = {
9276 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9277 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9278 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9279 .dac_nids = alc883_dac_nids,
9280 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009281 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9282 .channel_mode = alc883_3ST_6ch_modes,
9283 .need_dac_fix = 1,
9284 .input_mux = &alc883_capture_source,
9285 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9286 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009287 },
9288 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009289 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009290 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9291 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9292 .dac_nids = alc883_dac_nids,
9293 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009294 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9295 .channel_mode = alc883_3ST_2ch_modes,
9296 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009297 .unsol_event = alc_automute_amp_unsol_event,
9298 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009299 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009300 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009301 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009302 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009303 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9304 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009305 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9306 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009307 .need_dac_fix = 1,
9308 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009309 .unsol_event = alc_automute_amp_unsol_event,
9310 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009311 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009312 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009313 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009314 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9316 .dac_nids = alc883_dac_nids,
9317 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009318 .dig_in_nid = ALC883_DIGIN_NID,
9319 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9320 .channel_mode = alc883_sixstack_modes,
9321 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009322 .unsol_event = alc_automute_amp_unsol_event,
9323 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009324 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009325 [ALC883_MITAC] = {
9326 .mixers = { alc883_mitac_mixer },
9327 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9328 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9329 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009330 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9331 .channel_mode = alc883_3ST_2ch_modes,
9332 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009333 .unsol_event = alc_automute_amp_unsol_event,
9334 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009335 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009336 [ALC883_FUJITSU_PI2515] = {
9337 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9338 .init_verbs = { alc883_init_verbs,
9339 alc883_2ch_fujitsu_pi2515_verbs},
9340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9341 .dac_nids = alc883_dac_nids,
9342 .dig_out_nid = ALC883_DIGOUT_NID,
9343 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9344 .channel_mode = alc883_3ST_2ch_modes,
9345 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009346 .unsol_event = alc_automute_amp_unsol_event,
9347 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009348 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009349 [ALC888_FUJITSU_XA3530] = {
9350 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9351 .init_verbs = { alc883_init_verbs,
9352 alc888_fujitsu_xa3530_verbs },
9353 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9354 .dac_nids = alc883_dac_nids,
9355 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9356 .adc_nids = alc883_adc_nids_rev,
9357 .capsrc_nids = alc883_capsrc_nids_rev,
9358 .dig_out_nid = ALC883_DIGOUT_NID,
9359 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9360 .channel_mode = alc888_4ST_8ch_intel_modes,
9361 .num_mux_defs =
9362 ARRAY_SIZE(alc888_2_capture_sources),
9363 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009364 .unsol_event = alc_automute_amp_unsol_event,
9365 .init_hook = alc888_fujitsu_xa3530_init_hook,
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,
9378 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009379 },
9380 [ALC888_ASUS_M90V] = {
9381 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9382 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9383 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9384 .dac_nids = alc883_dac_nids,
9385 .dig_out_nid = ALC883_DIGOUT_NID,
9386 .dig_in_nid = ALC883_DIGIN_NID,
9387 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9388 .channel_mode = alc883_3ST_6ch_modes,
9389 .need_dac_fix = 1,
9390 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9391 .unsol_event = alc883_mode2_unsol_event,
9392 .init_hook = alc883_mode2_inithook,
9393 },
9394 [ALC888_ASUS_EEE1601] = {
9395 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009396 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009397 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9398 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9399 .dac_nids = alc883_dac_nids,
9400 .dig_out_nid = ALC883_DIGOUT_NID,
9401 .dig_in_nid = ALC883_DIGIN_NID,
9402 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9403 .channel_mode = alc883_3ST_2ch_modes,
9404 .need_dac_fix = 1,
9405 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009406 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009407 .init_hook = alc883_eee1601_inithook,
9408 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009409 [ALC1200_ASUS_P5Q] = {
9410 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9411 .init_verbs = { alc883_init_verbs },
9412 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9413 .dac_nids = alc883_dac_nids,
9414 .dig_out_nid = ALC1200_DIGOUT_NID,
9415 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009416 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009417 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9418 .channel_mode = alc883_sixstack_modes,
9419 .input_mux = &alc883_capture_source,
9420 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009421 [ALC889A_MB31] = {
9422 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9423 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9424 alc880_gpio1_init_verbs },
9425 .adc_nids = alc883_adc_nids,
9426 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9427 .dac_nids = alc883_dac_nids,
9428 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9429 .channel_mode = alc889A_mb31_6ch_modes,
9430 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9431 .input_mux = &alc889A_mb31_capture_source,
9432 .dig_out_nid = ALC883_DIGOUT_NID,
9433 .unsol_event = alc889A_mb31_unsol_event,
9434 .init_hook = alc889A_mb31_automute,
9435 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009436 [ALC883_SONY_VAIO_TT] = {
9437 .mixers = { alc883_vaiott_mixer },
9438 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9439 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9440 .dac_nids = alc883_dac_nids,
9441 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9442 .channel_mode = alc883_3ST_2ch_modes,
9443 .input_mux = &alc883_capture_source,
9444 .unsol_event = alc_automute_amp_unsol_event,
9445 .init_hook = alc883_vaiott_init_hook,
9446 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009447};
9448
9449
9450/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009451 * Pin config fixes
9452 */
9453enum {
9454 PINFIX_ABIT_AW9D_MAX
9455};
9456
9457static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9458 { 0x15, 0x01080104 }, /* side */
9459 { 0x16, 0x01011012 }, /* rear */
9460 { 0x17, 0x01016011 }, /* clfe */
9461 { }
9462};
9463
9464static const struct alc_pincfg *alc882_pin_fixes[] = {
9465 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9466};
9467
9468static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9469 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9470 {}
9471};
9472
9473/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009474 * BIOS auto configuration
9475 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009476static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009477 hda_nid_t nid, int pin_type,
9478 int dac_idx)
9479{
9480 /* set as output */
9481 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009482 int idx;
9483
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009484 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009485 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9486 idx = 4;
9487 else
9488 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009489 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9490
9491}
9492
Takashi Iwai4953550a2009-06-30 15:28:30 +02009493static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009494{
9495 struct alc_spec *spec = codec->spec;
9496 int i;
9497
9498 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009499 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009500 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009501 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009503 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009504 }
9505}
9506
Takashi Iwai4953550a2009-06-30 15:28:30 +02009507static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009508{
9509 struct alc_spec *spec = codec->spec;
9510 hda_nid_t pin;
9511
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009512 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009513 if (pin) /* connect to front */
9514 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009515 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009516 pin = spec->autocfg.speaker_pins[0];
9517 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009518 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009519}
9520
Takashi Iwai4953550a2009-06-30 15:28:30 +02009521static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009522{
9523 struct alc_spec *spec = codec->spec;
9524 int i;
9525
9526 for (i = 0; i < AUTO_PIN_LAST; i++) {
9527 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009528 if (!nid)
9529 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009530 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009531 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9532 snd_hda_codec_write(codec, nid, 0,
9533 AC_VERB_SET_AMP_GAIN_MUTE,
9534 AMP_OUT_MUTE);
9535 }
9536}
9537
9538static void alc882_auto_init_input_src(struct hda_codec *codec)
9539{
9540 struct alc_spec *spec = codec->spec;
9541 int c;
9542
9543 for (c = 0; c < spec->num_adc_nids; c++) {
9544 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9545 hda_nid_t nid = spec->capsrc_nids[c];
9546 unsigned int mux_idx;
9547 const struct hda_input_mux *imux;
9548 int conns, mute, idx, item;
9549
9550 conns = snd_hda_get_connections(codec, nid, conn_list,
9551 ARRAY_SIZE(conn_list));
9552 if (conns < 0)
9553 continue;
9554 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9555 imux = &spec->input_mux[mux_idx];
9556 for (idx = 0; idx < conns; idx++) {
9557 /* if the current connection is the selected one,
9558 * unmute it as default - otherwise mute it
9559 */
9560 mute = AMP_IN_MUTE(idx);
9561 for (item = 0; item < imux->num_items; item++) {
9562 if (imux->items[item].index == idx) {
9563 if (spec->cur_mux[c] == item)
9564 mute = AMP_IN_UNMUTE(idx);
9565 break;
9566 }
9567 }
9568 /* check if we have a selector or mixer
9569 * we could check for the widget type instead, but
9570 * just check for Amp-In presence (in case of mixer
9571 * without amp-in there is something wrong, this
9572 * function shouldn't be used or capsrc nid is wrong)
9573 */
9574 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009575 snd_hda_codec_write(codec, nid, 0,
9576 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009577 mute);
9578 else if (mute != AMP_IN_MUTE(idx))
9579 snd_hda_codec_write(codec, nid, 0,
9580 AC_VERB_SET_CONNECT_SEL,
9581 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009582 }
9583 }
9584}
9585
Takashi Iwai4953550a2009-06-30 15:28:30 +02009586/* add mic boosts if needed */
9587static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009588{
9589 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009590 int err;
9591 hda_nid_t nid;
9592
9593 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9594 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9595 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9596 "Mic Boost",
9597 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9598 if (err < 0)
9599 return err;
9600 }
9601 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9602 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9603 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9604 "Front Mic Boost",
9605 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9606 if (err < 0)
9607 return err;
9608 }
9609 return 0;
9610}
9611
9612/* almost identical with ALC880 parser... */
9613static int alc882_parse_auto_config(struct hda_codec *codec)
9614{
9615 struct alc_spec *spec = codec->spec;
9616 struct auto_pin_cfg *autocfg = &spec->autocfg;
9617 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009618 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009619 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009620
9621 if (err < 0)
9622 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009623 else if (!err)
9624 return 0; /* no config found */
9625
9626 err = alc_auto_add_mic_boost(codec);
9627 if (err < 0)
9628 return err;
9629
9630 /* hack - override the init verbs */
9631 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009632 /* if ADC 0x07 is available, initialize it, too */
9633 wcap = get_wcaps(codec, 0x07);
Takashi Iwaia22d5432009-07-27 12:54:26 +02009634 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009635 if (wcap == AC_WID_AUD_IN)
9636 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009637
Takashi Iwai4953550a2009-06-30 15:28:30 +02009638 /* digital-mic input pin is excluded in alc880_auto_create..()
9639 * because it's under 0x18
9640 */
9641 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9642 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9643 struct hda_input_mux *imux = &spec->private_imux[0];
9644 for (i = 1; i < 3; i++)
9645 memcpy(&spec->private_imux[i],
9646 &spec->private_imux[0],
9647 sizeof(spec->private_imux[0]));
9648 imux->items[imux->num_items].label = "Int DMic";
9649 imux->items[imux->num_items].index = 0x0b;
9650 imux->num_items++;
9651 spec->num_mux_defs = 3;
9652 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009653 }
9654
Takashi Iwai776e1842007-08-29 15:07:11 +02009655 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009656}
9657
9658/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009659static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009660{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009661 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009662 alc882_auto_init_multi_out(codec);
9663 alc882_auto_init_hp_out(codec);
9664 alc882_auto_init_analog_input(codec);
9665 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009666 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009667 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009668}
9669
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009671{
9672 struct alc_spec *spec;
9673 int err, board_config;
9674
9675 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9676 if (spec == NULL)
9677 return -ENOMEM;
9678
9679 codec->spec = spec;
9680
Takashi Iwai4953550a2009-06-30 15:28:30 +02009681 switch (codec->vendor_id) {
9682 case 0x10ec0882:
9683 case 0x10ec0885:
9684 break;
9685 default:
9686 /* ALC883 and variants */
9687 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9688 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009689 }
9690
Takashi Iwai4953550a2009-06-30 15:28:30 +02009691 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9692 alc882_models,
9693 alc882_cfg_tbl);
9694
9695 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9696 board_config = snd_hda_check_board_codec_sid_config(codec,
9697 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9698
9699 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009700 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009701 codec->chip_name);
9702 board_config = ALC882_AUTO;
9703 }
9704
9705 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9706
9707 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009708 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009709 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009710 if (err < 0) {
9711 alc_free(codec);
9712 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009713 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009714 printk(KERN_INFO
9715 "hda_codec: Cannot set up configuration "
9716 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009717 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009718 }
9719 }
9720
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009721 err = snd_hda_attach_beep_device(codec, 0x1);
9722 if (err < 0) {
9723 alc_free(codec);
9724 return err;
9725 }
9726
Takashi Iwai4953550a2009-06-30 15:28:30 +02009727 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02009728 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009729
Takashi Iwai4953550a2009-06-30 15:28:30 +02009730 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9731 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9732 /* FIXME: setup DAC5 */
9733 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9734 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9735
9736 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9737 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9738
9739 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009740 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741
9742 if (!spec->adc_nids && spec->input_mux) {
9743 int i;
9744 spec->num_adc_nids = 0;
9745 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9746 hda_nid_t cap;
9747 hda_nid_t nid = alc882_adc_nids[i];
9748 unsigned int wcap = get_wcaps(codec, nid);
9749 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009750 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009751 if (wcap != AC_WID_AUD_IN)
9752 continue;
9753 spec->private_adc_nids[spec->num_adc_nids] = nid;
9754 err = snd_hda_get_connections(codec, nid, &cap, 1);
9755 if (err < 0)
9756 continue;
9757 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9758 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009759 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009760 spec->adc_nids = spec->private_adc_nids;
9761 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009762 }
9763
Takashi Iwaib59bdf32009-08-11 09:47:30 +02009764 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009765 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009766
Takashi Iwai2134ea42008-01-10 16:53:55 +01009767 spec->vmaster_nid = 0x0c;
9768
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009769 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770 if (board_config == ALC882_AUTO)
9771 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009772#ifdef CONFIG_SND_HDA_POWER_SAVE
9773 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009774 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009775#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009776 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009777
9778 return 0;
9779}
9780
Takashi Iwai4953550a2009-06-30 15:28:30 +02009781
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009782/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009783 * ALC262 support
9784 */
9785
9786#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9787#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9788
9789#define alc262_dac_nids alc260_dac_nids
9790#define alc262_adc_nids alc882_adc_nids
9791#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009792#define alc262_capsrc_nids alc882_capsrc_nids
9793#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009794
9795#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009796#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009797
Kailang Yang4e555fe2008-08-26 13:05:55 +02009798static hda_nid_t alc262_dmic_adc_nids[1] = {
9799 /* ADC0 */
9800 0x09
9801};
9802
9803static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9804
Kailang Yangdf694da2005-12-05 19:42:22 +01009805static struct snd_kcontrol_new alc262_base_mixer[] = {
9806 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9807 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9808 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9809 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9810 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9811 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9812 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9813 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009814 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009815 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9816 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009817 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009818 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9819 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9820 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9821 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009822 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009823};
9824
Takashi Iwaice875f02008-01-28 18:17:43 +01009825/* update HP, line and mono-out pins according to the master switch */
9826static void alc262_hp_master_update(struct hda_codec *codec)
9827{
9828 struct alc_spec *spec = codec->spec;
9829 int val = spec->master_sw;
9830
9831 /* HP & line-out */
9832 snd_hda_codec_write_cache(codec, 0x1b, 0,
9833 AC_VERB_SET_PIN_WIDGET_CONTROL,
9834 val ? PIN_HP : 0);
9835 snd_hda_codec_write_cache(codec, 0x15, 0,
9836 AC_VERB_SET_PIN_WIDGET_CONTROL,
9837 val ? PIN_HP : 0);
9838 /* mono (speaker) depending on the HP jack sense */
9839 val = val && !spec->jack_present;
9840 snd_hda_codec_write_cache(codec, 0x16, 0,
9841 AC_VERB_SET_PIN_WIDGET_CONTROL,
9842 val ? PIN_OUT : 0);
9843}
9844
9845static void alc262_hp_bpc_automute(struct hda_codec *codec)
9846{
9847 struct alc_spec *spec = codec->spec;
9848 unsigned int presence;
9849 presence = snd_hda_codec_read(codec, 0x1b, 0,
9850 AC_VERB_GET_PIN_SENSE, 0);
9851 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9852 alc262_hp_master_update(codec);
9853}
9854
9855static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9856{
9857 if ((res >> 26) != ALC880_HP_EVENT)
9858 return;
9859 alc262_hp_bpc_automute(codec);
9860}
9861
9862static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9863{
9864 struct alc_spec *spec = codec->spec;
9865 unsigned int presence;
9866 presence = snd_hda_codec_read(codec, 0x15, 0,
9867 AC_VERB_GET_PIN_SENSE, 0);
9868 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9869 alc262_hp_master_update(codec);
9870}
9871
9872static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9873 unsigned int res)
9874{
9875 if ((res >> 26) != ALC880_HP_EVENT)
9876 return;
9877 alc262_hp_wildwest_automute(codec);
9878}
9879
Takashi Iwaib72519b2009-05-08 14:31:55 +02009880#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009881
9882static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9883 struct snd_ctl_elem_value *ucontrol)
9884{
9885 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9886 struct alc_spec *spec = codec->spec;
9887 int val = !!*ucontrol->value.integer.value;
9888
9889 if (val == spec->master_sw)
9890 return 0;
9891 spec->master_sw = val;
9892 alc262_hp_master_update(codec);
9893 return 1;
9894}
9895
Takashi Iwaib72519b2009-05-08 14:31:55 +02009896#define ALC262_HP_MASTER_SWITCH \
9897 { \
9898 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9899 .name = "Master Playback Switch", \
9900 .info = snd_ctl_boolean_mono_info, \
9901 .get = alc262_hp_master_sw_get, \
9902 .put = alc262_hp_master_sw_put, \
9903 }
9904
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009905static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009906 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009907 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9908 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009910 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9911 HDA_OUTPUT),
9912 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9913 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009914 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9915 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009916 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009917 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9918 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009919 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009920 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9921 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9922 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9923 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009924 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9925 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9926 { } /* end */
9927};
9928
Kailang Yangcd7509a2007-01-26 18:33:17 +01009929static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009930 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009931 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9932 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9933 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9934 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009935 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9936 HDA_OUTPUT),
9937 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9938 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009941 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9943 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9944 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9945 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009946 { } /* end */
9947};
9948
9949static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9950 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9951 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009952 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009953 { } /* end */
9954};
9955
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009956/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009957static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009958{
9959 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009961 spec->autocfg.hp_pins[0] = 0x15;
9962 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9963 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009964}
9965
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009966static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009967 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9968 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009969 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9970 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9974 { } /* end */
9975};
9976
9977static struct hda_verb alc262_hp_t5735_verbs[] = {
9978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9980
9981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9982 { }
9983};
9984
Kailang Yang8c427222008-01-10 13:03:59 +01009985static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009988 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9989 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9992 { } /* end */
9993};
9994
9995static struct hda_verb alc262_hp_rp5700_verbs[] = {
9996 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9997 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9998 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10000 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10001 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10003 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10005 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10006 {}
10007};
10008
10009static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10010 .num_items = 1,
10011 .items = {
10012 { "Line", 0x1 },
10013 },
10014};
10015
Takashi Iwai42171c12009-05-08 14:11:43 +020010016/* bind hp and internal speaker mute (with plug check) as master switch */
10017static void alc262_hippo_master_update(struct hda_codec *codec)
10018{
10019 struct alc_spec *spec = codec->spec;
10020 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10021 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10022 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10023 unsigned int mute;
10024
10025 /* HP */
10026 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10027 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10028 HDA_AMP_MUTE, mute);
10029 /* mute internal speaker per jack sense */
10030 if (spec->jack_present)
10031 mute = HDA_AMP_MUTE;
10032 if (line_nid)
10033 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10034 HDA_AMP_MUTE, mute);
10035 if (speaker_nid && speaker_nid != line_nid)
10036 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10037 HDA_AMP_MUTE, mute);
10038}
10039
10040#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10041
10042static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10043 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010044{
10045 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010046 struct alc_spec *spec = codec->spec;
10047 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010048
Takashi Iwai42171c12009-05-08 14:11:43 +020010049 if (val == spec->master_sw)
10050 return 0;
10051 spec->master_sw = val;
10052 alc262_hippo_master_update(codec);
10053 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010054}
Takashi Iwai5b319542007-07-26 11:49:22 +020010055
Takashi Iwai42171c12009-05-08 14:11:43 +020010056#define ALC262_HIPPO_MASTER_SWITCH \
10057 { \
10058 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10059 .name = "Master Playback Switch", \
10060 .info = snd_ctl_boolean_mono_info, \
10061 .get = alc262_hippo_master_sw_get, \
10062 .put = alc262_hippo_master_sw_put, \
10063 }
10064
10065static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10066 ALC262_HIPPO_MASTER_SWITCH,
10067 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10068 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10069 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10072 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10074 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10076 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10077 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10078 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10079 { } /* end */
10080};
10081
10082static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10083 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10084 ALC262_HIPPO_MASTER_SWITCH,
10085 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10086 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10087 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10088 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10089 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10090 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10091 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10092 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10093 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10094 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10095 { } /* end */
10096};
10097
10098/* mute/unmute internal speaker according to the hp jack and mute state */
10099static void alc262_hippo_automute(struct hda_codec *codec)
10100{
10101 struct alc_spec *spec = codec->spec;
10102 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10103 unsigned int present;
10104
10105 /* need to execute and sync at first */
10106 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10107 present = snd_hda_codec_read(codec, hp_nid, 0,
10108 AC_VERB_GET_PIN_SENSE, 0);
10109 spec->jack_present = (present & 0x80000000) != 0;
10110 alc262_hippo_master_update(codec);
10111}
10112
10113static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10114{
10115 if ((res >> 26) != ALC880_HP_EVENT)
10116 return;
10117 alc262_hippo_automute(codec);
10118}
10119
10120static void alc262_hippo_init_hook(struct hda_codec *codec)
10121{
10122 struct alc_spec *spec = codec->spec;
10123
10124 spec->autocfg.hp_pins[0] = 0x15;
10125 spec->autocfg.speaker_pins[0] = 0x14;
10126 alc262_hippo_automute(codec);
10127}
10128
10129static void alc262_hippo1_init_hook(struct hda_codec *codec)
10130{
10131 struct alc_spec *spec = codec->spec;
10132
10133 spec->autocfg.hp_pins[0] = 0x1b;
10134 spec->autocfg.speaker_pins[0] = 0x14;
10135 alc262_hippo_automute(codec);
10136}
10137
10138
Kailang Yang272a5272007-05-14 11:00:38 +020010139static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010140 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010141 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10144 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 { } /* end */
10147};
10148
Kailang Yang83c34212007-07-05 11:43:05 +020010149static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010150 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10151 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010152 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10155 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10156 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10157 { } /* end */
10158};
Kailang Yang272a5272007-05-14 11:00:38 +020010159
Tony Vroonba340e82009-02-02 19:01:30 +000010160static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10161 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10162 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10163 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10164 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10165 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10166 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10167 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10168 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10169 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10170 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10171 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10172 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10173 { } /* end */
10174};
10175
10176static struct hda_verb alc262_tyan_verbs[] = {
10177 /* Headphone automute */
10178 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10179 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10181
10182 /* P11 AUX_IN, white 4-pin connector */
10183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10184 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10185 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10186 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10187
10188 {}
10189};
10190
10191/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010192static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010193{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010194 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010195
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010196 spec->autocfg.hp_pins[0] = 0x1b;
10197 spec->autocfg.speaker_pins[0] = 0x15;
10198 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010199}
10200
Tony Vroonba340e82009-02-02 19:01:30 +000010201
Kailang Yangdf694da2005-12-05 19:42:22 +010010202#define alc262_capture_mixer alc882_capture_mixer
10203#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10204
10205/*
10206 * generic initialization of ADC, input mixers and output mixers
10207 */
10208static struct hda_verb alc262_init_verbs[] = {
10209 /*
10210 * Unmute ADC0-2 and set the default input to mic-in
10211 */
10212 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10214 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10215 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10216 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10217 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10218
Takashi Iwaicb53c622007-08-10 17:21:45 +020010219 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010220 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010221 * Note: PASD motherboards uses the Line In 2 as the input for
10222 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010223 */
10224 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10229 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010230
10231 /*
10232 * Set up output mixers (0x0c - 0x0e)
10233 */
10234 /* set vol=0 to output mixers */
10235 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10236 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10237 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10238 /* set up input amps for analog loopback */
10239 /* Amp Indices: DAC = 0, mixer = 1 */
10240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10243 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10245 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10246
10247 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10248 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10249 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10251 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10252 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10253
10254 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10256 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10257 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010259
Kailang Yangdf694da2005-12-05 19:42:22 +010010260 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010262
Kailang Yangdf694da2005-12-05 19:42:22 +010010263 /* FIXME: use matrix-type input source selection */
10264 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10265 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10270 /* Input mixer2 */
10271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10272 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10273 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10275 /* Input mixer3 */
10276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10277 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10278 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010279 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010280
10281 { }
10282};
10283
Kailang Yang4e555fe2008-08-26 13:05:55 +020010284static struct hda_verb alc262_eapd_verbs[] = {
10285 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10286 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10287 { }
10288};
10289
Kailang Yangccc656c2006-10-17 12:32:26 +020010290static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10291 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10292 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10293 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10294
10295 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10296 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10297 {}
10298};
10299
Kailang Yang272a5272007-05-14 11:00:38 +020010300static struct hda_verb alc262_sony_unsol_verbs[] = {
10301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10302 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10304
10305 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10306 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010307 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010308};
10309
Kailang Yang4e555fe2008-08-26 13:05:55 +020010310static struct hda_input_mux alc262_dmic_capture_source = {
10311 .num_items = 2,
10312 .items = {
10313 { "Int DMic", 0x9 },
10314 { "Mic", 0x0 },
10315 },
10316};
10317
10318static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10319 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10320 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10321 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10322 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10323 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010324 { } /* end */
10325};
10326
10327static struct hda_verb alc262_toshiba_s06_verbs[] = {
10328 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10329 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10331 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10332 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10333 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10334 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10335 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10336 {}
10337};
10338
10339static void alc262_dmic_automute(struct hda_codec *codec)
10340{
10341 unsigned int present;
10342
10343 present = snd_hda_codec_read(codec, 0x18, 0,
10344 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10345 snd_hda_codec_write(codec, 0x22, 0,
10346 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10347}
10348
Kailang Yang4e555fe2008-08-26 13:05:55 +020010349
10350/* unsolicited event for HP jack sensing */
10351static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10352 unsigned int res)
10353{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010354 if ((res >> 26) == ALC880_MIC_EVENT)
10355 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010356 else
10357 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010358}
10359
10360static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10361{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010362 struct alc_spec *spec = codec->spec;
10363
10364 spec->autocfg.hp_pins[0] = 0x15;
10365 spec->autocfg.speaker_pins[0] = 0x14;
10366 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010367 alc262_dmic_automute(codec);
10368}
10369
Takashi Iwai834be882006-03-01 14:16:17 +010010370/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010371 * nec model
10372 * 0x15 = headphone
10373 * 0x16 = internal speaker
10374 * 0x18 = external mic
10375 */
10376
10377static struct snd_kcontrol_new alc262_nec_mixer[] = {
10378 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10379 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10380
10381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10383 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10384
10385 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10387 { } /* end */
10388};
10389
10390static struct hda_verb alc262_nec_verbs[] = {
10391 /* Unmute Speaker */
10392 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10393
10394 /* Headphone */
10395 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10397
10398 /* External mic to headphone */
10399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10400 /* External mic to speaker */
10401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10402 {}
10403};
10404
10405/*
Takashi Iwai834be882006-03-01 14:16:17 +010010406 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010407 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10408 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010409 */
10410
10411#define ALC_HP_EVENT 0x37
10412
10413static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10414 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010416 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10417 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010418 {}
10419};
10420
Jiang zhe0e31daf2008-03-20 12:12:39 +010010421static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10422 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10423 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10424 {}
10425};
10426
Takashi Iwai834be882006-03-01 14:16:17 +010010427static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010428 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010429 .items = {
10430 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010431 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010432 { "CD", 0x4 },
10433 },
10434};
10435
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010436static struct hda_input_mux alc262_HP_capture_source = {
10437 .num_items = 5,
10438 .items = {
10439 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010440 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010441 { "Line", 0x2 },
10442 { "CD", 0x4 },
10443 { "AUX IN", 0x6 },
10444 },
10445};
10446
zhejiangaccbe492007-08-31 12:36:05 +020010447static struct hda_input_mux alc262_HP_D7000_capture_source = {
10448 .num_items = 4,
10449 .items = {
10450 { "Mic", 0x0 },
10451 { "Front Mic", 0x2 },
10452 { "Line", 0x1 },
10453 { "CD", 0x4 },
10454 },
10455};
10456
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010457/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010458static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10459{
10460 struct alc_spec *spec = codec->spec;
10461 unsigned int mute;
10462
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010463 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010464 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010465 /* need to execute and sync at first */
10466 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010467 /* check laptop HP jack */
10468 present = snd_hda_codec_read(codec, 0x14, 0,
10469 AC_VERB_GET_PIN_SENSE, 0);
10470 /* need to execute and sync at first */
10471 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10472 /* check docking HP jack */
10473 present |= snd_hda_codec_read(codec, 0x1b, 0,
10474 AC_VERB_GET_PIN_SENSE, 0);
10475 if (present & AC_PINSENSE_PRESENCE)
10476 spec->jack_present = 1;
10477 else
10478 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010479 spec->sense_updated = 1;
10480 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010481 /* unmute internal speaker only if both HPs are unplugged and
10482 * master switch is on
10483 */
10484 if (spec->jack_present)
10485 mute = HDA_AMP_MUTE;
10486 else
Takashi Iwai834be882006-03-01 14:16:17 +010010487 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010488 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10489 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010490}
10491
10492/* unsolicited event for HP jack sensing */
10493static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10494 unsigned int res)
10495{
10496 if ((res >> 26) != ALC_HP_EVENT)
10497 return;
10498 alc262_fujitsu_automute(codec, 1);
10499}
10500
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010501static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10502{
10503 alc262_fujitsu_automute(codec, 1);
10504}
10505
Takashi Iwai834be882006-03-01 14:16:17 +010010506/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010507static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10508 .ops = &snd_hda_bind_vol,
10509 .values = {
10510 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10511 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10512 0
10513 },
10514};
Takashi Iwai834be882006-03-01 14:16:17 +010010515
Jiang zhe0e31daf2008-03-20 12:12:39 +010010516/* mute/unmute internal speaker according to the hp jack and mute state */
10517static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10518{
10519 struct alc_spec *spec = codec->spec;
10520 unsigned int mute;
10521
10522 if (force || !spec->sense_updated) {
10523 unsigned int present_int_hp;
10524 /* need to execute and sync at first */
10525 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10526 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10527 AC_VERB_GET_PIN_SENSE, 0);
10528 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10529 spec->sense_updated = 1;
10530 }
10531 if (spec->jack_present) {
10532 /* mute internal speaker */
10533 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10534 HDA_AMP_MUTE, HDA_AMP_MUTE);
10535 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10536 HDA_AMP_MUTE, HDA_AMP_MUTE);
10537 } else {
10538 /* unmute internal speaker if necessary */
10539 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10540 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10541 HDA_AMP_MUTE, mute);
10542 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10543 HDA_AMP_MUTE, mute);
10544 }
10545}
10546
10547/* unsolicited event for HP jack sensing */
10548static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10549 unsigned int res)
10550{
10551 if ((res >> 26) != ALC_HP_EVENT)
10552 return;
10553 alc262_lenovo_3000_automute(codec, 1);
10554}
10555
Takashi Iwai8de56b72009-07-24 16:51:47 +020010556static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10557 int dir, int idx, long *valp)
10558{
10559 int i, change = 0;
10560
10561 for (i = 0; i < 2; i++, valp++)
10562 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10563 HDA_AMP_MUTE,
10564 *valp ? 0 : HDA_AMP_MUTE);
10565 return change;
10566}
10567
Takashi Iwai834be882006-03-01 14:16:17 +010010568/* bind hp and internal speaker mute (with plug check) */
10569static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10570 struct snd_ctl_elem_value *ucontrol)
10571{
10572 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10573 long *valp = ucontrol->value.integer.value;
10574 int change;
10575
Takashi Iwai8de56b72009-07-24 16:51:47 +020010576 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10577 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010578 if (change)
10579 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010580 return change;
10581}
10582
10583static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010584 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010585 {
10586 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10587 .name = "Master Playback Switch",
10588 .info = snd_hda_mixer_amp_switch_info,
10589 .get = snd_hda_mixer_amp_switch_get,
10590 .put = alc262_fujitsu_master_sw_put,
10591 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10592 },
10593 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10594 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10595 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10596 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10597 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010598 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10599 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10600 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010601 { } /* end */
10602};
10603
Jiang zhe0e31daf2008-03-20 12:12:39 +010010604/* bind hp and internal speaker mute (with plug check) */
10605static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10606 struct snd_ctl_elem_value *ucontrol)
10607{
10608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10609 long *valp = ucontrol->value.integer.value;
10610 int change;
10611
Takashi Iwai8de56b72009-07-24 16:51:47 +020010612 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010613 if (change)
10614 alc262_lenovo_3000_automute(codec, 0);
10615 return change;
10616}
10617
10618static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10619 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10620 {
10621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10622 .name = "Master Playback Switch",
10623 .info = snd_hda_mixer_amp_switch_info,
10624 .get = snd_hda_mixer_amp_switch_get,
10625 .put = alc262_lenovo_3000_master_sw_put,
10626 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10627 },
10628 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10629 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10630 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10632 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10633 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10634 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10635 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10636 { } /* end */
10637};
10638
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010639static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10640 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010641 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010642 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10643 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10644 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10645 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10646 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10647 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10648 { } /* end */
10649};
10650
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010651/* additional init verbs for Benq laptops */
10652static struct hda_verb alc262_EAPD_verbs[] = {
10653 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10654 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10655 {}
10656};
10657
Kailang Yang83c34212007-07-05 11:43:05 +020010658static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10659 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10660 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10661
10662 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10663 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10664 {}
10665};
10666
Tobin Davisf651b502007-10-26 12:40:47 +020010667/* Samsung Q1 Ultra Vista model setup */
10668static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010669 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10670 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10672 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10673 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010674 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010675 { } /* end */
10676};
10677
10678static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010679 /* output mixer */
10680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10681 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10682 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10683 /* speaker */
10684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10685 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10686 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10687 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10688 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10692 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10693 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10694 /* internal mic */
10695 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10696 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10697 /* ADC, choose mic */
10698 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10699 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10700 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10701 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10702 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10703 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10704 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10705 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10706 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10707 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010708 {}
10709};
10710
Tobin Davisf651b502007-10-26 12:40:47 +020010711/* mute/unmute internal speaker according to the hp jack and mute state */
10712static void alc262_ultra_automute(struct hda_codec *codec)
10713{
10714 struct alc_spec *spec = codec->spec;
10715 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010716
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010717 mute = 0;
10718 /* auto-mute only when HP is used as HP */
10719 if (!spec->cur_mux[0]) {
10720 unsigned int present;
10721 /* need to execute and sync at first */
10722 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10723 present = snd_hda_codec_read(codec, 0x15, 0,
10724 AC_VERB_GET_PIN_SENSE, 0);
10725 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10726 if (spec->jack_present)
10727 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010728 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010729 /* mute/unmute internal speaker */
10730 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10731 HDA_AMP_MUTE, mute);
10732 /* mute/unmute HP */
10733 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10734 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010735}
10736
10737/* unsolicited event for HP jack sensing */
10738static void alc262_ultra_unsol_event(struct hda_codec *codec,
10739 unsigned int res)
10740{
10741 if ((res >> 26) != ALC880_HP_EVENT)
10742 return;
10743 alc262_ultra_automute(codec);
10744}
10745
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010746static struct hda_input_mux alc262_ultra_capture_source = {
10747 .num_items = 2,
10748 .items = {
10749 { "Mic", 0x1 },
10750 { "Headphone", 0x7 },
10751 },
10752};
10753
10754static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10755 struct snd_ctl_elem_value *ucontrol)
10756{
10757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10758 struct alc_spec *spec = codec->spec;
10759 int ret;
10760
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010761 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010762 if (!ret)
10763 return 0;
10764 /* reprogram the HP pin as mic or HP according to the input source */
10765 snd_hda_codec_write_cache(codec, 0x15, 0,
10766 AC_VERB_SET_PIN_WIDGET_CONTROL,
10767 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10768 alc262_ultra_automute(codec); /* mute/unmute HP */
10769 return ret;
10770}
10771
10772static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10773 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10774 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10775 {
10776 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10777 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010778 .info = alc_mux_enum_info,
10779 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010780 .put = alc262_ultra_mux_enum_put,
10781 },
10782 { } /* end */
10783};
10784
Kailang Yangdf694da2005-12-05 19:42:22 +010010785/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010786static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10787 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010788{
10789 hda_nid_t nid;
10790 int err;
10791
10792 spec->multiout.num_dacs = 1; /* only use one dac */
10793 spec->multiout.dac_nids = spec->private_dac_nids;
10794 spec->multiout.dac_nids[0] = 2;
10795
10796 nid = cfg->line_out_pins[0];
10797 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010798 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10799 "Front Playback Volume",
10800 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10801 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010803 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10804 "Front Playback Switch",
10805 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10806 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010807 return err;
10808 }
10809
Takashi Iwai82bc9552006-03-21 11:24:42 +010010810 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010811 if (nid) {
10812 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010813 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10814 "Speaker Playback Volume",
10815 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10816 HDA_OUTPUT));
10817 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010818 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010819 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10820 "Speaker Playback Switch",
10821 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10822 HDA_OUTPUT));
10823 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010824 return err;
10825 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010826 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10827 "Speaker Playback Switch",
10828 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10829 HDA_OUTPUT));
10830 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010831 return err;
10832 }
10833 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010834 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010835 if (nid) {
10836 /* spec->multiout.hp_nid = 2; */
10837 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010838 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10839 "Headphone Playback Volume",
10840 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10841 HDA_OUTPUT));
10842 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010843 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010844 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10845 "Headphone Playback Switch",
10846 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10847 HDA_OUTPUT));
10848 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010849 return err;
10850 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010851 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10852 "Headphone Playback Switch",
10853 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10854 HDA_OUTPUT));
10855 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010856 return err;
10857 }
10858 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010859 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010860}
10861
Takashi Iwai8c927b42009-06-22 10:56:54 +020010862static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10863 const struct auto_pin_cfg *cfg)
10864{
10865 int err;
10866
10867 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10868 if (err < 0)
10869 return err;
10870 /* digital-mic input pin is excluded in alc880_auto_create..()
10871 * because it's under 0x18
10872 */
10873 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10874 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10875 struct hda_input_mux *imux = &spec->private_imux[0];
10876 imux->items[imux->num_items].label = "Int Mic";
10877 imux->items[imux->num_items].index = 0x09;
10878 imux->num_items++;
10879 }
10880 return 0;
10881}
10882
Kailang Yangdf694da2005-12-05 19:42:22 +010010883
10884/*
10885 * generic initialization of ADC, input mixers and output mixers
10886 */
10887static struct hda_verb alc262_volume_init_verbs[] = {
10888 /*
10889 * Unmute ADC0-2 and set the default input to mic-in
10890 */
10891 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10892 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10893 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10894 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10895 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10897
Takashi Iwaicb53c622007-08-10 17:21:45 +020010898 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010899 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010900 * Note: PASD motherboards uses the Line In 2 as the input for
10901 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010902 */
10903 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010909
10910 /*
10911 * Set up output mixers (0x0c - 0x0f)
10912 */
10913 /* set vol=0 to output mixers */
10914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10915 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10916 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010917
Kailang Yangdf694da2005-12-05 19:42:22 +010010918 /* set up input amps for analog loopback */
10919 /* Amp Indices: DAC = 0, mixer = 1 */
10920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10922 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10923 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10924 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10925 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10926
10927 /* FIXME: use matrix-type input source selection */
10928 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10929 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10934 /* Input mixer2 */
10935 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10936 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10937 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10938 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10939 /* Input mixer3 */
10940 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10941 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10942 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10943 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10944
10945 { }
10946};
10947
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010948static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10949 /*
10950 * Unmute ADC0-2 and set the default input to mic-in
10951 */
10952 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10953 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10954 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10955 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10956 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10957 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10958
Takashi Iwaicb53c622007-08-10 17:21:45 +020010959 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010960 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010961 * Note: PASD motherboards uses the Line In 2 as the input for
10962 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010963 */
10964 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10971 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010972
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010973 /*
10974 * Set up output mixers (0x0c - 0x0e)
10975 */
10976 /* set vol=0 to output mixers */
10977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10978 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10979 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10980
10981 /* set up input amps for analog loopback */
10982 /* Amp Indices: DAC = 0, mixer = 1 */
10983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10984 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10986 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10988 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10989
Takashi Iwaice875f02008-01-28 18:17:43 +010010990 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010991 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10992 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10993
10994 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10996
10997 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10998 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10999
11000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11001 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11002 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11003 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11005
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011006 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011007 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11008 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011009 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11011 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11012
11013
11014 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011015 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11016 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011017 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011018 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11019 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11020 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11021 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11022 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11023 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11024 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11025 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011026 /* Input mixer2 */
11027 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011028 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11029 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11030 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11032 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11033 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11034 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11035 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011036 /* Input mixer3 */
11037 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11039 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11040 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11041 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11044 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011046
Takashi Iwaice875f02008-01-28 18:17:43 +010011047 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11048
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011049 { }
11050};
11051
Kailang Yangcd7509a2007-01-26 18:33:17 +010011052static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11053 /*
11054 * Unmute ADC0-2 and set the default input to mic-in
11055 */
11056 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11058 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11059 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11060 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11061 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062
Takashi Iwaicb53c622007-08-10 17:21:45 +020011063 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011064 * mixer widget
11065 * Note: PASD motherboards uses the Line In 2 as the input for front
11066 * panel mic (mic 2)
11067 */
11068 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011077 /*
11078 * Set up output mixers (0x0c - 0x0e)
11079 */
11080 /* set vol=0 to output mixers */
11081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11082 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11084
11085 /* set up input amps for analog loopback */
11086 /* Amp Indices: DAC = 0, mixer = 1 */
11087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11093
11094
11095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11096 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11097 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11098 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11099 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11100 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11101 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11102
11103 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11105
11106 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11107 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11108
11109 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11111 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11112 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11113 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11114 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11115
11116 /* FIXME: use matrix-type input source selection */
11117 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11118 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11119 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11121 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11123 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11124 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11125 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11126 /* Input mixer2 */
11127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11128 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11129 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11130 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11131 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11132 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11133 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11134 /* Input mixer3 */
11135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11136 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11140 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11141 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11142
Takashi Iwaice875f02008-01-28 18:17:43 +010011143 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11144
Kailang Yangcd7509a2007-01-26 18:33:17 +010011145 { }
11146};
11147
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011148static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11149
11150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11151 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11152 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11153
11154 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11155 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11156 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11157 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11158
11159 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11160 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11161 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11162 {}
11163};
11164
11165
Takashi Iwaicb53c622007-08-10 17:21:45 +020011166#ifdef CONFIG_SND_HDA_POWER_SAVE
11167#define alc262_loopbacks alc880_loopbacks
11168#endif
11169
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011170/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011171#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11172#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11173#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11174#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11175
11176/*
11177 * BIOS auto configuration
11178 */
11179static int alc262_parse_auto_config(struct hda_codec *codec)
11180{
11181 struct alc_spec *spec = codec->spec;
11182 int err;
11183 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11184
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011185 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11186 alc262_ignore);
11187 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011188 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011189 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011190 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011191 spec->multiout.max_channels = 2;
11192 spec->no_analog = 1;
11193 goto dig_only;
11194 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011195 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011196 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011197 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11198 if (err < 0)
11199 return err;
11200 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11201 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011202 return err;
11203
11204 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11205
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011206 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011207 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011208 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011209 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011210 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011211 if (spec->autocfg.dig_in_pin)
11212 spec->dig_in_nid = ALC262_DIGIN_NID;
11213
Takashi Iwai603c4012008-07-30 15:01:44 +020011214 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011215 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011216
Takashi Iwaid88897e2008-10-31 15:01:37 +010011217 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011218 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011219 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011220
Takashi Iwai776e1842007-08-29 15:07:11 +020011221 err = alc_auto_add_mic_boost(codec);
11222 if (err < 0)
11223 return err;
11224
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011225 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11226
Kailang Yangdf694da2005-12-05 19:42:22 +010011227 return 1;
11228}
11229
11230#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11231#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11232#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011233#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011234
11235
11236/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011237static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011238{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011239 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011240 alc262_auto_init_multi_out(codec);
11241 alc262_auto_init_hp_out(codec);
11242 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011243 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011244 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011245 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011246}
11247
11248/*
11249 * configuration and preset
11250 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011251static const char *alc262_models[ALC262_MODEL_LAST] = {
11252 [ALC262_BASIC] = "basic",
11253 [ALC262_HIPPO] = "hippo",
11254 [ALC262_HIPPO_1] = "hippo_1",
11255 [ALC262_FUJITSU] = "fujitsu",
11256 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011257 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011258 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011259 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011260 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011261 [ALC262_BENQ_T31] = "benq-t31",
11262 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011263 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011264 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011265 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011266 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011267 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011268 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011269 [ALC262_AUTO] = "auto",
11270};
11271
11272static struct snd_pci_quirk alc262_cfg_tbl[] = {
11273 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011274 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011275 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11276 ALC262_HP_BPC),
11277 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11278 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011279 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11280 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011281 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011282 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011283 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011284 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011285 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011286 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011287 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011288 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011289 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11290 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11291 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011292 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11293 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011294 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011295 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011296 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011297 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011298 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011299 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011300 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11301 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011302 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011303 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011304 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011305 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011306 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011307 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011308 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11309 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011310 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011311 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011312 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011313 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011314 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011315 {}
11316};
11317
11318static struct alc_config_preset alc262_presets[] = {
11319 [ALC262_BASIC] = {
11320 .mixers = { alc262_base_mixer },
11321 .init_verbs = { alc262_init_verbs },
11322 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11323 .dac_nids = alc262_dac_nids,
11324 .hp_nid = 0x03,
11325 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11326 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011327 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011328 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011329 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011330 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011331 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011332 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11333 .dac_nids = alc262_dac_nids,
11334 .hp_nid = 0x03,
11335 .dig_out_nid = ALC262_DIGOUT_NID,
11336 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11337 .channel_mode = alc262_modes,
11338 .input_mux = &alc262_capture_source,
11339 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011340 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011341 },
11342 [ALC262_HIPPO_1] = {
11343 .mixers = { alc262_hippo1_mixer },
11344 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11345 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11346 .dac_nids = alc262_dac_nids,
11347 .hp_nid = 0x02,
11348 .dig_out_nid = ALC262_DIGOUT_NID,
11349 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11350 .channel_mode = alc262_modes,
11351 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011352 .unsol_event = alc262_hippo_unsol_event,
11353 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011354 },
Takashi Iwai834be882006-03-01 14:16:17 +010011355 [ALC262_FUJITSU] = {
11356 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011357 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11358 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11360 .dac_nids = alc262_dac_nids,
11361 .hp_nid = 0x03,
11362 .dig_out_nid = ALC262_DIGOUT_NID,
11363 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11364 .channel_mode = alc262_modes,
11365 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011366 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011367 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011368 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011369 [ALC262_HP_BPC] = {
11370 .mixers = { alc262_HP_BPC_mixer },
11371 .init_verbs = { alc262_HP_BPC_init_verbs },
11372 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11373 .dac_nids = alc262_dac_nids,
11374 .hp_nid = 0x03,
11375 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11376 .channel_mode = alc262_modes,
11377 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011378 .unsol_event = alc262_hp_bpc_unsol_event,
11379 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011380 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011381 [ALC262_HP_BPC_D7000_WF] = {
11382 .mixers = { alc262_HP_BPC_WildWest_mixer },
11383 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11384 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11385 .dac_nids = alc262_dac_nids,
11386 .hp_nid = 0x03,
11387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11388 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011389 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011390 .unsol_event = alc262_hp_wildwest_unsol_event,
11391 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011392 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011393 [ALC262_HP_BPC_D7000_WL] = {
11394 .mixers = { alc262_HP_BPC_WildWest_mixer,
11395 alc262_HP_BPC_WildWest_option_mixer },
11396 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11397 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11398 .dac_nids = alc262_dac_nids,
11399 .hp_nid = 0x03,
11400 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11401 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011402 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011403 .unsol_event = alc262_hp_wildwest_unsol_event,
11404 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011405 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011406 [ALC262_HP_TC_T5735] = {
11407 .mixers = { alc262_hp_t5735_mixer },
11408 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11409 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11410 .dac_nids = alc262_dac_nids,
11411 .hp_nid = 0x03,
11412 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11413 .channel_mode = alc262_modes,
11414 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011415 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011416 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011417 },
11418 [ALC262_HP_RP5700] = {
11419 .mixers = { alc262_hp_rp5700_mixer },
11420 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11421 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11422 .dac_nids = alc262_dac_nids,
11423 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11424 .channel_mode = alc262_modes,
11425 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011426 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011427 [ALC262_BENQ_ED8] = {
11428 .mixers = { alc262_base_mixer },
11429 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11430 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11431 .dac_nids = alc262_dac_nids,
11432 .hp_nid = 0x03,
11433 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11434 .channel_mode = alc262_modes,
11435 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011436 },
Kailang Yang272a5272007-05-14 11:00:38 +020011437 [ALC262_SONY_ASSAMD] = {
11438 .mixers = { alc262_sony_mixer },
11439 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11440 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11441 .dac_nids = alc262_dac_nids,
11442 .hp_nid = 0x02,
11443 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11444 .channel_mode = alc262_modes,
11445 .input_mux = &alc262_capture_source,
11446 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011447 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011448 },
11449 [ALC262_BENQ_T31] = {
11450 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011451 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11452 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011453 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11454 .dac_nids = alc262_dac_nids,
11455 .hp_nid = 0x03,
11456 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11457 .channel_mode = alc262_modes,
11458 .input_mux = &alc262_capture_source,
11459 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011460 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011461 },
Tobin Davisf651b502007-10-26 12:40:47 +020011462 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011463 .mixers = { alc262_ultra_mixer },
11464 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011465 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011466 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11467 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011468 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11469 .channel_mode = alc262_modes,
11470 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011471 .adc_nids = alc262_adc_nids, /* ADC0 */
11472 .capsrc_nids = alc262_capsrc_nids,
11473 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011474 .unsol_event = alc262_ultra_unsol_event,
11475 .init_hook = alc262_ultra_automute,
11476 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011477 [ALC262_LENOVO_3000] = {
11478 .mixers = { alc262_lenovo_3000_mixer },
11479 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11480 alc262_lenovo_3000_unsol_verbs },
11481 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11482 .dac_nids = alc262_dac_nids,
11483 .hp_nid = 0x03,
11484 .dig_out_nid = ALC262_DIGOUT_NID,
11485 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11486 .channel_mode = alc262_modes,
11487 .input_mux = &alc262_fujitsu_capture_source,
11488 .unsol_event = alc262_lenovo_3000_unsol_event,
11489 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011490 [ALC262_NEC] = {
11491 .mixers = { alc262_nec_mixer },
11492 .init_verbs = { alc262_nec_verbs },
11493 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11494 .dac_nids = alc262_dac_nids,
11495 .hp_nid = 0x03,
11496 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11497 .channel_mode = alc262_modes,
11498 .input_mux = &alc262_capture_source,
11499 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011500 [ALC262_TOSHIBA_S06] = {
11501 .mixers = { alc262_toshiba_s06_mixer },
11502 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11503 alc262_eapd_verbs },
11504 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11505 .capsrc_nids = alc262_dmic_capsrc_nids,
11506 .dac_nids = alc262_dac_nids,
11507 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011508 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011509 .dig_out_nid = ALC262_DIGOUT_NID,
11510 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11511 .channel_mode = alc262_modes,
11512 .input_mux = &alc262_dmic_capture_source,
11513 .unsol_event = alc262_toshiba_s06_unsol_event,
11514 .init_hook = alc262_toshiba_s06_init_hook,
11515 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011516 [ALC262_TOSHIBA_RX1] = {
11517 .mixers = { alc262_toshiba_rx1_mixer },
11518 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
11519 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11520 .dac_nids = alc262_dac_nids,
11521 .hp_nid = 0x03,
11522 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11523 .channel_mode = alc262_modes,
11524 .input_mux = &alc262_capture_source,
11525 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011526 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011527 },
Tony Vroonba340e82009-02-02 19:01:30 +000011528 [ALC262_TYAN] = {
11529 .mixers = { alc262_tyan_mixer },
11530 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11531 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11532 .dac_nids = alc262_dac_nids,
11533 .hp_nid = 0x02,
11534 .dig_out_nid = ALC262_DIGOUT_NID,
11535 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11536 .channel_mode = alc262_modes,
11537 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011538 .unsol_event = alc_automute_amp_unsol_event,
11539 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011540 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011541};
11542
11543static int patch_alc262(struct hda_codec *codec)
11544{
11545 struct alc_spec *spec;
11546 int board_config;
11547 int err;
11548
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011549 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011550 if (spec == NULL)
11551 return -ENOMEM;
11552
11553 codec->spec = spec;
11554#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011555 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11556 * under-run
11557 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011558 {
11559 int tmp;
11560 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11561 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11562 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11563 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11564 }
11565#endif
11566
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011567 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11568
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011569 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11570 alc262_models,
11571 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011572
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011573 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011574 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11575 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011576 board_config = ALC262_AUTO;
11577 }
11578
11579 if (board_config == ALC262_AUTO) {
11580 /* automatic parse from the BIOS config */
11581 err = alc262_parse_auto_config(codec);
11582 if (err < 0) {
11583 alc_free(codec);
11584 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011585 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011586 printk(KERN_INFO
11587 "hda_codec: Cannot set up configuration "
11588 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011589 board_config = ALC262_BASIC;
11590 }
11591 }
11592
Takashi Iwai07eba612009-02-19 08:06:35 +010011593 if (!spec->no_analog) {
11594 err = snd_hda_attach_beep_device(codec, 0x1);
11595 if (err < 0) {
11596 alc_free(codec);
11597 return err;
11598 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011599 }
11600
Kailang Yangdf694da2005-12-05 19:42:22 +010011601 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011602 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010011603
Kailang Yangdf694da2005-12-05 19:42:22 +010011604 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11605 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011606
Kailang Yangdf694da2005-12-05 19:42:22 +010011607 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11608 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11609
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011610 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011611 int i;
11612 /* check whether the digital-mic has to be supported */
11613 for (i = 0; i < spec->input_mux->num_items; i++) {
11614 if (spec->input_mux->items[i].index >= 9)
11615 break;
11616 }
11617 if (i < spec->input_mux->num_items) {
11618 /* use only ADC0 */
11619 spec->adc_nids = alc262_dmic_adc_nids;
11620 spec->num_adc_nids = 1;
11621 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011622 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011623 /* all analog inputs */
11624 /* check whether NID 0x07 is valid */
11625 unsigned int wcap = get_wcaps(codec, 0x07);
11626
11627 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011628 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011629 if (wcap != AC_WID_AUD_IN) {
11630 spec->adc_nids = alc262_adc_nids_alt;
11631 spec->num_adc_nids =
11632 ARRAY_SIZE(alc262_adc_nids_alt);
11633 spec->capsrc_nids = alc262_capsrc_nids_alt;
11634 } else {
11635 spec->adc_nids = alc262_adc_nids;
11636 spec->num_adc_nids =
11637 ARRAY_SIZE(alc262_adc_nids);
11638 spec->capsrc_nids = alc262_capsrc_nids;
11639 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011640 }
11641 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011642 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011643 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011644 if (!spec->no_analog)
11645 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011646
Takashi Iwai2134ea42008-01-10 16:53:55 +010011647 spec->vmaster_nid = 0x0c;
11648
Kailang Yangdf694da2005-12-05 19:42:22 +010011649 codec->patch_ops = alc_patch_ops;
11650 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011651 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011652#ifdef CONFIG_SND_HDA_POWER_SAVE
11653 if (!spec->loopback.amplist)
11654 spec->loopback.amplist = alc262_loopbacks;
11655#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011656 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011657
Kailang Yangdf694da2005-12-05 19:42:22 +010011658 return 0;
11659}
11660
Kailang Yangdf694da2005-12-05 19:42:22 +010011661/*
Kailang Yanga361d842007-06-05 12:30:55 +020011662 * ALC268 channel source setting (2 channel)
11663 */
11664#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11665#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011666
Kailang Yanga361d842007-06-05 12:30:55 +020011667static hda_nid_t alc268_dac_nids[2] = {
11668 /* front, hp */
11669 0x02, 0x03
11670};
11671
11672static hda_nid_t alc268_adc_nids[2] = {
11673 /* ADC0-1 */
11674 0x08, 0x07
11675};
11676
11677static hda_nid_t alc268_adc_nids_alt[1] = {
11678 /* ADC0 */
11679 0x08
11680};
11681
Takashi Iwaie1406342008-02-11 18:32:32 +010011682static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11683
Kailang Yanga361d842007-06-05 12:30:55 +020011684static struct snd_kcontrol_new alc268_base_mixer[] = {
11685 /* output mixer control */
11686 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11687 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11688 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011690 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11691 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11692 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011693 { }
11694};
11695
Takashi Iwai42171c12009-05-08 14:11:43 +020011696static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11697 /* output mixer control */
11698 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11699 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11700 ALC262_HIPPO_MASTER_SWITCH,
11701 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11702 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11703 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11704 { }
11705};
11706
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011707/* bind Beep switches of both NID 0x0f and 0x10 */
11708static struct hda_bind_ctls alc268_bind_beep_sw = {
11709 .ops = &snd_hda_bind_sw,
11710 .values = {
11711 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11712 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11713 0
11714 },
11715};
11716
11717static struct snd_kcontrol_new alc268_beep_mixer[] = {
11718 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11719 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11720 { }
11721};
11722
Kailang Yangd1a991a2007-08-15 16:21:59 +020011723static struct hda_verb alc268_eapd_verbs[] = {
11724 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11725 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11726 { }
11727};
11728
Takashi Iwaid2738092007-08-16 14:59:45 +020011729/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011730static struct hda_verb alc268_toshiba_verbs[] = {
11731 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11732 { } /* end */
11733};
11734
Kailang Yang8ef355d2008-08-26 13:10:22 +020011735static struct hda_input_mux alc268_acer_lc_capture_source = {
11736 .num_items = 2,
11737 .items = {
11738 { "i-Mic", 0x6 },
11739 { "E-Mic", 0x0 },
11740 },
11741};
11742
Takashi Iwaid2738092007-08-16 14:59:45 +020011743/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011744/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011745static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11746 .ops = &snd_hda_bind_vol,
11747 .values = {
11748 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11749 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11750 0
11751 },
11752};
11753
Takashi Iwai889c4392007-08-23 18:56:52 +020011754/* mute/unmute internal speaker according to the hp jack and mute state */
11755static void alc268_acer_automute(struct hda_codec *codec, int force)
11756{
11757 struct alc_spec *spec = codec->spec;
11758 unsigned int mute;
11759
11760 if (force || !spec->sense_updated) {
11761 unsigned int present;
11762 present = snd_hda_codec_read(codec, 0x14, 0,
11763 AC_VERB_GET_PIN_SENSE, 0);
11764 spec->jack_present = (present & 0x80000000) != 0;
11765 spec->sense_updated = 1;
11766 }
11767 if (spec->jack_present)
11768 mute = HDA_AMP_MUTE; /* mute internal speaker */
11769 else /* unmute internal speaker if necessary */
11770 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11771 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11772 HDA_AMP_MUTE, mute);
11773}
11774
11775
11776/* bind hp and internal speaker mute (with plug check) */
11777static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11778 struct snd_ctl_elem_value *ucontrol)
11779{
11780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11781 long *valp = ucontrol->value.integer.value;
11782 int change;
11783
Takashi Iwai8de56b72009-07-24 16:51:47 +020011784 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011785 if (change)
11786 alc268_acer_automute(codec, 0);
11787 return change;
11788}
Takashi Iwaid2738092007-08-16 14:59:45 +020011789
Kailang Yang8ef355d2008-08-26 13:10:22 +020011790static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11791 /* output mixer control */
11792 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11793 {
11794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11795 .name = "Master Playback Switch",
11796 .info = snd_hda_mixer_amp_switch_info,
11797 .get = snd_hda_mixer_amp_switch_get,
11798 .put = alc268_acer_master_sw_put,
11799 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11800 },
11801 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11802 { }
11803};
11804
Takashi Iwaid2738092007-08-16 14:59:45 +020011805static struct snd_kcontrol_new alc268_acer_mixer[] = {
11806 /* output mixer control */
11807 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11808 {
11809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11810 .name = "Master Playback Switch",
11811 .info = snd_hda_mixer_amp_switch_info,
11812 .get = snd_hda_mixer_amp_switch_get,
11813 .put = alc268_acer_master_sw_put,
11814 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11815 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011816 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11817 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11818 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011819 { }
11820};
11821
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011822static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11823 /* output mixer control */
11824 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11825 {
11826 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11827 .name = "Master Playback Switch",
11828 .info = snd_hda_mixer_amp_switch_info,
11829 .get = snd_hda_mixer_amp_switch_get,
11830 .put = alc268_acer_master_sw_put,
11831 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11832 },
11833 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11834 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11835 { }
11836};
11837
Kailang Yang8ef355d2008-08-26 13:10:22 +020011838static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11839 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11841 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11842 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11843 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11844 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11845 { }
11846};
11847
Takashi Iwaid2738092007-08-16 14:59:45 +020011848static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011849 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11850 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011851 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11852 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011853 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11854 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011855 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11856 { }
11857};
11858
11859/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011860#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11861#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011862
11863static void alc268_acer_unsol_event(struct hda_codec *codec,
11864 unsigned int res)
11865{
Takashi Iwai889c4392007-08-23 18:56:52 +020011866 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011867 return;
11868 alc268_acer_automute(codec, 1);
11869}
11870
Takashi Iwai889c4392007-08-23 18:56:52 +020011871static void alc268_acer_init_hook(struct hda_codec *codec)
11872{
11873 alc268_acer_automute(codec, 1);
11874}
11875
Kailang Yang8ef355d2008-08-26 13:10:22 +020011876/* toggle speaker-output according to the hp-jack state */
11877static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11878{
11879 unsigned int present;
11880 unsigned char bits;
11881
11882 present = snd_hda_codec_read(codec, 0x15, 0,
11883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11884 bits = present ? AMP_IN_MUTE(0) : 0;
11885 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11886 AMP_IN_MUTE(0), bits);
11887 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11888 AMP_IN_MUTE(0), bits);
11889}
11890
11891
11892static void alc268_acer_mic_automute(struct hda_codec *codec)
11893{
11894 unsigned int present;
11895
11896 present = snd_hda_codec_read(codec, 0x18, 0,
11897 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11898 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11899 present ? 0x0 : 0x6);
11900}
11901
11902static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11903 unsigned int res)
11904{
11905 if ((res >> 26) == ALC880_HP_EVENT)
11906 alc268_aspire_one_speaker_automute(codec);
11907 if ((res >> 26) == ALC880_MIC_EVENT)
11908 alc268_acer_mic_automute(codec);
11909}
11910
11911static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11912{
11913 alc268_aspire_one_speaker_automute(codec);
11914 alc268_acer_mic_automute(codec);
11915}
11916
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011917static struct snd_kcontrol_new alc268_dell_mixer[] = {
11918 /* output mixer control */
11919 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11920 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11921 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11922 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11923 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11924 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11925 { }
11926};
11927
11928static struct hda_verb alc268_dell_verbs[] = {
11929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11931 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11932 { }
11933};
11934
11935/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011936static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011937{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011938 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011939
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011940 spec->autocfg.hp_pins[0] = 0x15;
11941 spec->autocfg.speaker_pins[0] = 0x14;
11942 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011943}
11944
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011945static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11946 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11947 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11948 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11949 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11950 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11951 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11952 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11953 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11954 { }
11955};
11956
11957static struct hda_verb alc267_quanta_il1_verbs[] = {
11958 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11959 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11960 { }
11961};
11962
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011963static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11964{
11965 unsigned int present;
11966
11967 present = snd_hda_codec_read(codec, 0x18, 0,
11968 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11969 snd_hda_codec_write(codec, 0x23, 0,
11970 AC_VERB_SET_CONNECT_SEL,
11971 present ? 0x00 : 0x01);
11972}
11973
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011974static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011975{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011976 struct alc_spec *spec = codec->spec;
11977
11978 spec->autocfg.hp_pins[0] = 0x15;
11979 spec->autocfg.speaker_pins[0] = 0x14;
11980 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011981 alc267_quanta_il1_mic_automute(codec);
11982}
11983
11984static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11985 unsigned int res)
11986{
11987 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011988 case ALC880_MIC_EVENT:
11989 alc267_quanta_il1_mic_automute(codec);
11990 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011991 default:
11992 alc_sku_unsol_event(codec, res);
11993 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011994 }
11995}
11996
Kailang Yanga361d842007-06-05 12:30:55 +020011997/*
11998 * generic initialization of ADC, input mixers and output mixers
11999 */
12000static struct hda_verb alc268_base_init_verbs[] = {
12001 /* Unmute DAC0-1 and set vol = 0 */
12002 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012003 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012004
12005 /*
12006 * Set up output mixers (0x0c - 0x0e)
12007 */
12008 /* set vol=0 to output mixers */
12009 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012010 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12011
12012 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12013 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12014
12015 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12017 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12018 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12019 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12020 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12021 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12022 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12023
12024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12025 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12026 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012029
12030 /* set PCBEEP vol = 0, mute connections */
12031 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12032 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12033 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012034
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012035 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012036
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012037 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12038 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12039 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012041
Kailang Yanga361d842007-06-05 12:30:55 +020012042 { }
12043};
12044
12045/*
12046 * generic initialization of ADC, input mixers and output mixers
12047 */
12048static struct hda_verb alc268_volume_init_verbs[] = {
12049 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012050 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12051 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012052
12053 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12054 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12055 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12056 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12057 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12058
Kailang Yanga361d842007-06-05 12:30:55 +020012059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012060 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12061 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12062
12063 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012064 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012065
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012066 /* set PCBEEP vol = 0, mute connections */
12067 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12068 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12069 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012070
12071 { }
12072};
12073
Kailang Yanga361d842007-06-05 12:30:55 +020012074static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12075 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12076 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12077 {
12078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12079 /* The multiple "Capture Source" controls confuse alsamixer
12080 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012081 */
12082 /* .name = "Capture Source", */
12083 .name = "Input Source",
12084 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012085 .info = alc_mux_enum_info,
12086 .get = alc_mux_enum_get,
12087 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012088 },
12089 { } /* end */
12090};
12091
12092static struct snd_kcontrol_new alc268_capture_mixer[] = {
12093 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12094 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12095 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12096 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12097 {
12098 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12099 /* The multiple "Capture Source" controls confuse alsamixer
12100 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012101 */
12102 /* .name = "Capture Source", */
12103 .name = "Input Source",
12104 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012105 .info = alc_mux_enum_info,
12106 .get = alc_mux_enum_get,
12107 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012108 },
12109 { } /* end */
12110};
12111
12112static struct hda_input_mux alc268_capture_source = {
12113 .num_items = 4,
12114 .items = {
12115 { "Mic", 0x0 },
12116 { "Front Mic", 0x1 },
12117 { "Line", 0x2 },
12118 { "CD", 0x3 },
12119 },
12120};
12121
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012122static struct hda_input_mux alc268_acer_capture_source = {
12123 .num_items = 3,
12124 .items = {
12125 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012126 { "Internal Mic", 0x1 },
12127 { "Line", 0x2 },
12128 },
12129};
12130
12131static struct hda_input_mux alc268_acer_dmic_capture_source = {
12132 .num_items = 3,
12133 .items = {
12134 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012135 { "Internal Mic", 0x6 },
12136 { "Line", 0x2 },
12137 },
12138};
12139
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012140#ifdef CONFIG_SND_DEBUG
12141static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012142 /* Volume widgets */
12143 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12144 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12145 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12146 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12147 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12148 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12149 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12150 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12151 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12152 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12153 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12154 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12155 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012156 /* The below appears problematic on some hardwares */
12157 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012158 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12159 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12160 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12161 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12162
12163 /* Modes for retasking pin widgets */
12164 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12165 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12166 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12167 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12168
12169 /* Controls for GPIO pins, assuming they are configured as outputs */
12170 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12171 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12172 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12173 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12174
12175 /* Switches to allow the digital SPDIF output pin to be enabled.
12176 * The ALC268 does not have an SPDIF input.
12177 */
12178 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12179
12180 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12181 * this output to turn on an external amplifier.
12182 */
12183 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12184 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12185
12186 { } /* end */
12187};
12188#endif
12189
Kailang Yanga361d842007-06-05 12:30:55 +020012190/* create input playback/capture controls for the given pin */
12191static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12192 const char *ctlname, int idx)
12193{
12194 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012195 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012196 int err;
12197
12198 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012199 switch (nid) {
12200 case 0x14:
12201 case 0x16:
12202 dac = 0x02;
12203 break;
12204 case 0x15:
12205 dac = 0x03;
12206 break;
12207 default:
12208 return 0;
12209 }
12210 if (spec->multiout.dac_nids[0] != dac &&
12211 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012212 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012213 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012214 HDA_OUTPUT));
12215 if (err < 0)
12216 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012217 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12218 }
12219
Kailang Yanga361d842007-06-05 12:30:55 +020012220 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012221 if (nid != 0x16)
12222 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012223 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012224 else /* mono */
12225 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12226 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012227 if (err < 0)
12228 return err;
12229 return 0;
12230}
12231
12232/* add playback controls from the parsed DAC table */
12233static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12234 const struct auto_pin_cfg *cfg)
12235{
12236 hda_nid_t nid;
12237 int err;
12238
Kailang Yanga361d842007-06-05 12:30:55 +020012239 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012240
12241 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012242 if (nid) {
12243 const char *name;
12244 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12245 name = "Speaker";
12246 else
12247 name = "Front";
12248 err = alc268_new_analog_output(spec, nid, name, 0);
12249 if (err < 0)
12250 return err;
12251 }
Kailang Yanga361d842007-06-05 12:30:55 +020012252
12253 nid = cfg->speaker_pins[0];
12254 if (nid == 0x1d) {
12255 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12256 "Speaker Playback Volume",
12257 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12258 if (err < 0)
12259 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012260 } else {
12261 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12262 if (err < 0)
12263 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012264 }
12265 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012266 if (nid) {
12267 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12268 if (err < 0)
12269 return err;
12270 }
Kailang Yanga361d842007-06-05 12:30:55 +020012271
12272 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12273 if (nid == 0x16) {
12274 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12275 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012276 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012277 if (err < 0)
12278 return err;
12279 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012280 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012281}
12282
12283/* create playback/capture controls for input pins */
12284static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12285 const struct auto_pin_cfg *cfg)
12286{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012287 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012288 int i, idx1;
12289
12290 for (i = 0; i < AUTO_PIN_LAST; i++) {
12291 switch(cfg->input_pins[i]) {
12292 case 0x18:
12293 idx1 = 0; /* Mic 1 */
12294 break;
12295 case 0x19:
12296 idx1 = 1; /* Mic 2 */
12297 break;
12298 case 0x1a:
12299 idx1 = 2; /* Line In */
12300 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012301 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012302 idx1 = 3; /* CD */
12303 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012304 case 0x12:
12305 case 0x13:
12306 idx1 = 6; /* digital mics */
12307 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012308 default:
12309 continue;
12310 }
12311 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12312 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012313 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012314 }
12315 return 0;
12316}
12317
12318static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12319{
12320 struct alc_spec *spec = codec->spec;
12321 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12322 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12323 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12324 unsigned int dac_vol1, dac_vol2;
12325
12326 if (speaker_nid) {
12327 snd_hda_codec_write(codec, speaker_nid, 0,
12328 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12329 snd_hda_codec_write(codec, 0x0f, 0,
12330 AC_VERB_SET_AMP_GAIN_MUTE,
12331 AMP_IN_UNMUTE(1));
12332 snd_hda_codec_write(codec, 0x10, 0,
12333 AC_VERB_SET_AMP_GAIN_MUTE,
12334 AMP_IN_UNMUTE(1));
12335 } else {
12336 snd_hda_codec_write(codec, 0x0f, 0,
12337 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12338 snd_hda_codec_write(codec, 0x10, 0,
12339 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12340 }
12341
12342 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012343 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012344 dac_vol2 = AMP_OUT_ZERO;
12345 else if (line_nid == 0x15)
12346 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012347 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012348 dac_vol2 = AMP_OUT_ZERO;
12349 else if (hp_nid == 0x15)
12350 dac_vol1 = AMP_OUT_ZERO;
12351 if (line_nid != 0x16 || hp_nid != 0x16 ||
12352 spec->autocfg.line_out_pins[1] != 0x16 ||
12353 spec->autocfg.line_out_pins[2] != 0x16)
12354 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12355
12356 snd_hda_codec_write(codec, 0x02, 0,
12357 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12358 snd_hda_codec_write(codec, 0x03, 0,
12359 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12360}
12361
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012362/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012363#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12364#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012365#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012366#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12367
12368/*
12369 * BIOS auto configuration
12370 */
12371static int alc268_parse_auto_config(struct hda_codec *codec)
12372{
12373 struct alc_spec *spec = codec->spec;
12374 int err;
12375 static hda_nid_t alc268_ignore[] = { 0 };
12376
12377 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12378 alc268_ignore);
12379 if (err < 0)
12380 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012381 if (!spec->autocfg.line_outs) {
12382 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12383 spec->multiout.max_channels = 2;
12384 spec->no_analog = 1;
12385 goto dig_only;
12386 }
Kailang Yanga361d842007-06-05 12:30:55 +020012387 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012388 }
Kailang Yanga361d842007-06-05 12:30:55 +020012389 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12390 if (err < 0)
12391 return err;
12392 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12393 if (err < 0)
12394 return err;
12395
12396 spec->multiout.max_channels = 2;
12397
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012398 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012399 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012400 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012401 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012402 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12403 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012404 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012405 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012406
Takashi Iwai892981f2009-03-02 08:04:35 +010012407 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012408 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012409
Takashi Iwaid88897e2008-10-31 15:01:37 +010012410 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012411 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012412 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012413
Takashi Iwai776e1842007-08-29 15:07:11 +020012414 err = alc_auto_add_mic_boost(codec);
12415 if (err < 0)
12416 return err;
12417
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012418 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12419
Kailang Yanga361d842007-06-05 12:30:55 +020012420 return 1;
12421}
12422
12423#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12424#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12425#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12426
12427/* init callback for auto-configuration model -- overriding the default init */
12428static void alc268_auto_init(struct hda_codec *codec)
12429{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012430 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012431 alc268_auto_init_multi_out(codec);
12432 alc268_auto_init_hp_out(codec);
12433 alc268_auto_init_mono_speaker_out(codec);
12434 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012435 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012436 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012437}
12438
12439/*
12440 * configuration and preset
12441 */
12442static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012443 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012444 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012445 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012446 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012447 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012448 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012449 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012450 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012451#ifdef CONFIG_SND_DEBUG
12452 [ALC268_TEST] = "test",
12453#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012454 [ALC268_AUTO] = "auto",
12455};
12456
12457static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012458 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012459 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012460 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012461 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012462 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012463 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12464 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012465 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012466 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012467 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12468 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012469 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012470 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12471 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12472 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012473 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012474 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012475 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012476 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012477 {}
12478};
12479
12480static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012481 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012482 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012483 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12484 alc267_quanta_il1_verbs },
12485 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12486 .dac_nids = alc268_dac_nids,
12487 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12488 .adc_nids = alc268_adc_nids_alt,
12489 .hp_nid = 0x03,
12490 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12491 .channel_mode = alc268_modes,
12492 .input_mux = &alc268_capture_source,
12493 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012494 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012495 },
Kailang Yanga361d842007-06-05 12:30:55 +020012496 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012497 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12498 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012499 .init_verbs = { alc268_base_init_verbs },
12500 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12501 .dac_nids = alc268_dac_nids,
12502 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12503 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012504 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012505 .hp_nid = 0x03,
12506 .dig_out_nid = ALC268_DIGOUT_NID,
12507 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12508 .channel_mode = alc268_modes,
12509 .input_mux = &alc268_capture_source,
12510 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012511 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012512 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012513 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012514 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12515 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012516 .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,
Takashi Iwaie1406342008-02-11 18:32:32 +010012520 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012521 .hp_nid = 0x03,
12522 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12523 .channel_mode = alc268_modes,
12524 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012525 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012526 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012527 },
12528 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012529 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12530 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012531 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12532 alc268_acer_verbs },
12533 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12534 .dac_nids = alc268_dac_nids,
12535 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12536 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012537 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012538 .hp_nid = 0x02,
12539 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12540 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012541 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012542 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012543 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012544 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012545 [ALC268_ACER_DMIC] = {
12546 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12547 alc268_beep_mixer },
12548 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12549 alc268_acer_verbs },
12550 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12551 .dac_nids = alc268_dac_nids,
12552 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12553 .adc_nids = alc268_adc_nids_alt,
12554 .capsrc_nids = alc268_capsrc_nids,
12555 .hp_nid = 0x02,
12556 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12557 .channel_mode = alc268_modes,
12558 .input_mux = &alc268_acer_dmic_capture_source,
12559 .unsol_event = alc268_acer_unsol_event,
12560 .init_hook = alc268_acer_init_hook,
12561 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012562 [ALC268_ACER_ASPIRE_ONE] = {
12563 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012564 alc268_beep_mixer,
12565 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012566 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12567 alc268_acer_aspire_one_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,
12572 .capsrc_nids = alc268_capsrc_nids,
12573 .hp_nid = 0x03,
12574 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12575 .channel_mode = alc268_modes,
12576 .input_mux = &alc268_acer_lc_capture_source,
12577 .unsol_event = alc268_acer_lc_unsol_event,
12578 .init_hook = alc268_acer_lc_init_hook,
12579 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012580 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012581 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012582 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12583 alc268_dell_verbs },
12584 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12585 .dac_nids = alc268_dac_nids,
12586 .hp_nid = 0x02,
12587 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12588 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012589 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012590 .init_hook = alc268_dell_init_hook,
12591 .input_mux = &alc268_capture_source,
12592 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012593 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012594 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12595 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012596 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12597 alc268_toshiba_verbs },
12598 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12599 .dac_nids = alc268_dac_nids,
12600 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12601 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012602 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012603 .hp_nid = 0x03,
12604 .dig_out_nid = ALC268_DIGOUT_NID,
12605 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12606 .channel_mode = alc268_modes,
12607 .input_mux = &alc268_capture_source,
12608 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012609 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012610 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012611#ifdef CONFIG_SND_DEBUG
12612 [ALC268_TEST] = {
12613 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12614 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12615 alc268_volume_init_verbs },
12616 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12617 .dac_nids = alc268_dac_nids,
12618 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12619 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012620 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012621 .hp_nid = 0x03,
12622 .dig_out_nid = ALC268_DIGOUT_NID,
12623 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12624 .channel_mode = alc268_modes,
12625 .input_mux = &alc268_capture_source,
12626 },
12627#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012628};
12629
12630static int patch_alc268(struct hda_codec *codec)
12631{
12632 struct alc_spec *spec;
12633 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012634 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012635
12636 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12637 if (spec == NULL)
12638 return -ENOMEM;
12639
12640 codec->spec = spec;
12641
12642 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12643 alc268_models,
12644 alc268_cfg_tbl);
12645
12646 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012647 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12648 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012649 board_config = ALC268_AUTO;
12650 }
12651
12652 if (board_config == ALC268_AUTO) {
12653 /* automatic parse from the BIOS config */
12654 err = alc268_parse_auto_config(codec);
12655 if (err < 0) {
12656 alc_free(codec);
12657 return err;
12658 } else if (!err) {
12659 printk(KERN_INFO
12660 "hda_codec: Cannot set up configuration "
12661 "from BIOS. Using base mode...\n");
12662 board_config = ALC268_3ST;
12663 }
12664 }
12665
12666 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012667 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020012668
Kailang Yanga361d842007-06-05 12:30:55 +020012669 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12670 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012671 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012672
Kailang Yanga361d842007-06-05 12:30:55 +020012673 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12674
Takashi Iwai22971e32009-02-10 11:56:44 +010012675 has_beep = 0;
12676 for (i = 0; i < spec->num_mixers; i++) {
12677 if (spec->mixers[i] == alc268_beep_mixer) {
12678 has_beep = 1;
12679 break;
12680 }
12681 }
12682
12683 if (has_beep) {
12684 err = snd_hda_attach_beep_device(codec, 0x1);
12685 if (err < 0) {
12686 alc_free(codec);
12687 return err;
12688 }
12689 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12690 /* override the amp caps for beep generator */
12691 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012692 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12693 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12694 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12695 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012696 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012697
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012698 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012699 /* check whether NID 0x07 is valid */
12700 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012701 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012702
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012703 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012704 wcap = get_wcaps_type(wcap);
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012705 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012706 spec->adc_nids = alc268_adc_nids_alt;
12707 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012708 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012709 } else {
12710 spec->adc_nids = alc268_adc_nids;
12711 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012712 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012713 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012714 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012715 /* set default input source */
12716 for (i = 0; i < spec->num_adc_nids; i++)
12717 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12718 0, AC_VERB_SET_CONNECT_SEL,
12719 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012720 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012721
12722 spec->vmaster_nid = 0x02;
12723
Kailang Yanga361d842007-06-05 12:30:55 +020012724 codec->patch_ops = alc_patch_ops;
12725 if (board_config == ALC268_AUTO)
12726 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012727
Takashi Iwaidaead532008-11-28 12:55:36 +010012728 codec->proc_widget_hook = print_realtek_coef;
12729
Kailang Yanga361d842007-06-05 12:30:55 +020012730 return 0;
12731}
12732
12733/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012734 * ALC269 channel source setting (2 channel)
12735 */
12736#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12737
12738#define alc269_dac_nids alc260_dac_nids
12739
12740static hda_nid_t alc269_adc_nids[1] = {
12741 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012742 0x08,
12743};
12744
Takashi Iwaie01bf502008-08-21 16:25:07 +020012745static hda_nid_t alc269_capsrc_nids[1] = {
12746 0x23,
12747};
12748
12749/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12750 * not a mux!
12751 */
12752
Kailang Yangf53281e2008-07-18 12:36:43 +020012753static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12754 .num_items = 2,
12755 .items = {
12756 { "i-Mic", 0x5 },
12757 { "e-Mic", 0x0 },
12758 },
12759};
12760
12761static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12762 .num_items = 2,
12763 .items = {
12764 { "i-Mic", 0x1 },
12765 { "e-Mic", 0x0 },
12766 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012767};
12768
12769#define alc269_modes alc260_modes
12770#define alc269_capture_source alc880_lg_lw_capture_source
12771
12772static struct snd_kcontrol_new alc269_base_mixer[] = {
12773 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12774 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12775 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12776 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12777 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12778 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12779 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12780 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12782 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12784 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12785 { } /* end */
12786};
12787
Kailang Yang60db6b52008-08-26 13:13:00 +020012788static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12789 /* output mixer control */
12790 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12791 {
12792 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12793 .name = "Master Playback Switch",
12794 .info = snd_hda_mixer_amp_switch_info,
12795 .get = snd_hda_mixer_amp_switch_get,
12796 .put = alc268_acer_master_sw_put,
12797 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12798 },
12799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12802 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12803 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12804 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012805 { }
12806};
12807
Tony Vroon64154832008-11-06 15:08:49 +000012808static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12809 /* output mixer control */
12810 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12811 {
12812 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12813 .name = "Master Playback Switch",
12814 .info = snd_hda_mixer_amp_switch_info,
12815 .get = snd_hda_mixer_amp_switch_get,
12816 .put = alc268_acer_master_sw_put,
12817 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12818 },
12819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12822 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12823 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12824 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12825 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12826 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12827 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012828 { }
12829};
12830
Kailang Yangf53281e2008-07-18 12:36:43 +020012831static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012832 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012833 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012835 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012836 { } /* end */
12837};
12838
Kailang Yangf6a92242007-12-13 16:52:54 +010012839/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012840static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12841 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12842 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12844 { } /* end */
12845};
12846
12847/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012848#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012849
Kailang Yang60db6b52008-08-26 13:13:00 +020012850static struct hda_verb alc269_quanta_fl1_verbs[] = {
12851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12852 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12854 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12855 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12856 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12857 { }
12858};
12859
Tony Vroon64154832008-11-06 15:08:49 +000012860static struct hda_verb alc269_lifebook_verbs[] = {
12861 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12862 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12863 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12867 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12868 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12870 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12871 { }
12872};
12873
Kailang Yang60db6b52008-08-26 13:13:00 +020012874/* toggle speaker-output according to the hp-jack state */
12875static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12876{
12877 unsigned int present;
12878 unsigned char bits;
12879
12880 present = snd_hda_codec_read(codec, 0x15, 0,
12881 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12882 bits = present ? AMP_IN_MUTE(0) : 0;
12883 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12884 AMP_IN_MUTE(0), bits);
12885 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12886 AMP_IN_MUTE(0), bits);
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, 0x680);
12892
12893 snd_hda_codec_write(codec, 0x20, 0,
12894 AC_VERB_SET_COEF_INDEX, 0x0c);
12895 snd_hda_codec_write(codec, 0x20, 0,
12896 AC_VERB_SET_PROC_COEF, 0x480);
12897}
12898
Tony Vroon64154832008-11-06 15:08:49 +000012899/* toggle speaker-output according to the hp-jacks state */
12900static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12901{
12902 unsigned int present;
12903 unsigned char bits;
12904
12905 /* Check laptop headphone socket */
12906 present = snd_hda_codec_read(codec, 0x15, 0,
12907 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12908
12909 /* Check port replicator headphone socket */
12910 present |= snd_hda_codec_read(codec, 0x1a, 0,
12911 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12912
12913 bits = present ? AMP_IN_MUTE(0) : 0;
12914 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12915 AMP_IN_MUTE(0), bits);
12916 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12917 AMP_IN_MUTE(0), bits);
12918
12919 snd_hda_codec_write(codec, 0x20, 0,
12920 AC_VERB_SET_COEF_INDEX, 0x0c);
12921 snd_hda_codec_write(codec, 0x20, 0,
12922 AC_VERB_SET_PROC_COEF, 0x680);
12923
12924 snd_hda_codec_write(codec, 0x20, 0,
12925 AC_VERB_SET_COEF_INDEX, 0x0c);
12926 snd_hda_codec_write(codec, 0x20, 0,
12927 AC_VERB_SET_PROC_COEF, 0x480);
12928}
12929
Kailang Yang60db6b52008-08-26 13:13:00 +020012930static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12931{
12932 unsigned int present;
12933
12934 present = snd_hda_codec_read(codec, 0x18, 0,
12935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12936 snd_hda_codec_write(codec, 0x23, 0,
12937 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12938}
12939
Tony Vroon64154832008-11-06 15:08:49 +000012940static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12941{
12942 unsigned int present_laptop;
12943 unsigned int present_dock;
12944
12945 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12946 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12947
12948 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12949 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12950
12951 /* Laptop mic port overrides dock mic port, design decision */
12952 if (present_dock)
12953 snd_hda_codec_write(codec, 0x23, 0,
12954 AC_VERB_SET_CONNECT_SEL, 0x3);
12955 if (present_laptop)
12956 snd_hda_codec_write(codec, 0x23, 0,
12957 AC_VERB_SET_CONNECT_SEL, 0x0);
12958 if (!present_dock && !present_laptop)
12959 snd_hda_codec_write(codec, 0x23, 0,
12960 AC_VERB_SET_CONNECT_SEL, 0x1);
12961}
12962
Kailang Yang60db6b52008-08-26 13:13:00 +020012963static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12964 unsigned int res)
12965{
12966 if ((res >> 26) == ALC880_HP_EVENT)
12967 alc269_quanta_fl1_speaker_automute(codec);
12968 if ((res >> 26) == ALC880_MIC_EVENT)
12969 alc269_quanta_fl1_mic_automute(codec);
12970}
12971
Tony Vroon64154832008-11-06 15:08:49 +000012972static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12973 unsigned int res)
12974{
12975 if ((res >> 26) == ALC880_HP_EVENT)
12976 alc269_lifebook_speaker_automute(codec);
12977 if ((res >> 26) == ALC880_MIC_EVENT)
12978 alc269_lifebook_mic_autoswitch(codec);
12979}
12980
Kailang Yang60db6b52008-08-26 13:13:00 +020012981static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12982{
12983 alc269_quanta_fl1_speaker_automute(codec);
12984 alc269_quanta_fl1_mic_automute(codec);
12985}
12986
Tony Vroon64154832008-11-06 15:08:49 +000012987static void alc269_lifebook_init_hook(struct hda_codec *codec)
12988{
12989 alc269_lifebook_speaker_automute(codec);
12990 alc269_lifebook_mic_autoswitch(codec);
12991}
12992
Kailang Yang60db6b52008-08-26 13:13:00 +020012993static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12994 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12995 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12996 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12998 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12999 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13000 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13001 {}
13002};
13003
13004static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
13005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13006 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13007 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13009 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13011 {}
13012};
13013
13014/* toggle speaker-output according to the hp-jack state */
13015static void alc269_speaker_automute(struct hda_codec *codec)
13016{
13017 unsigned int present;
13018 unsigned char bits;
13019
13020 present = snd_hda_codec_read(codec, 0x15, 0,
13021 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13022 bits = present ? AMP_IN_MUTE(0) : 0;
13023 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13024 AMP_IN_MUTE(0), bits);
13025 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13026 AMP_IN_MUTE(0), bits);
13027}
13028
13029static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13030{
13031 unsigned int present;
13032
13033 present = snd_hda_codec_read(codec, 0x18, 0,
13034 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13035 snd_hda_codec_write(codec, 0x23, 0,
13036 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13037}
13038
13039static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13040{
13041 unsigned int present;
13042
13043 present = snd_hda_codec_read(codec, 0x18, 0,
13044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13045 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13046 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13047 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13048 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13049}
13050
13051/* unsolicited event for HP jack sensing */
13052static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13053 unsigned int res)
13054{
13055 if ((res >> 26) == ALC880_HP_EVENT)
13056 alc269_speaker_automute(codec);
13057
13058 if ((res >> 26) == ALC880_MIC_EVENT)
13059 alc269_eeepc_dmic_automute(codec);
13060}
13061
13062static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13063{
13064 alc269_speaker_automute(codec);
13065 alc269_eeepc_dmic_automute(codec);
13066}
13067
13068/* unsolicited event for HP jack sensing */
13069static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13070 unsigned int res)
13071{
13072 if ((res >> 26) == ALC880_HP_EVENT)
13073 alc269_speaker_automute(codec);
13074
13075 if ((res >> 26) == ALC880_MIC_EVENT)
13076 alc269_eeepc_amic_automute(codec);
13077}
13078
13079static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13080{
13081 alc269_speaker_automute(codec);
13082 alc269_eeepc_amic_automute(codec);
13083}
13084
Kailang Yangf6a92242007-12-13 16:52:54 +010013085/*
13086 * generic initialization of ADC, input mixers and output mixers
13087 */
13088static struct hda_verb alc269_init_verbs[] = {
13089 /*
13090 * Unmute ADC0 and set the default input to mic-in
13091 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013092 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013093
13094 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13095 * analog-loopback mixer widget
13096 * Note: PASD motherboards uses the Line In 2 as the input for
13097 * front panel mic (mic 2)
13098 */
13099 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13104 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13105
13106 /*
13107 * Set up output mixers (0x0c - 0x0e)
13108 */
13109 /* set vol=0 to output mixers */
13110 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13111 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13112
13113 /* set up input amps for analog loopback */
13114 /* Amp Indices: DAC = 0, mixer = 1 */
13115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13121
13122 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13124 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13125 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13127 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13128 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13129
13130 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13132 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13134 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13135 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13136 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13137
13138 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13139 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13140
13141 /* FIXME: use matrix-type input source selection */
13142 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13143 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13148
13149 /* set EAPD */
13150 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13151 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13152 { }
13153};
13154
13155/* add playback controls from the parsed DAC table */
13156static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13157 const struct auto_pin_cfg *cfg)
13158{
13159 hda_nid_t nid;
13160 int err;
13161
13162 spec->multiout.num_dacs = 1; /* only use one dac */
13163 spec->multiout.dac_nids = spec->private_dac_nids;
13164 spec->multiout.dac_nids[0] = 2;
13165
13166 nid = cfg->line_out_pins[0];
13167 if (nid) {
13168 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13169 "Front Playback Volume",
13170 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13171 if (err < 0)
13172 return err;
13173 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13174 "Front Playback Switch",
13175 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13176 if (err < 0)
13177 return err;
13178 }
13179
13180 nid = cfg->speaker_pins[0];
13181 if (nid) {
13182 if (!cfg->line_out_pins[0]) {
13183 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13184 "Speaker Playback Volume",
13185 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13186 HDA_OUTPUT));
13187 if (err < 0)
13188 return err;
13189 }
13190 if (nid == 0x16) {
13191 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13192 "Speaker Playback Switch",
13193 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13194 HDA_OUTPUT));
13195 if (err < 0)
13196 return err;
13197 } else {
13198 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13199 "Speaker Playback Switch",
13200 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13201 HDA_OUTPUT));
13202 if (err < 0)
13203 return err;
13204 }
13205 }
13206 nid = cfg->hp_pins[0];
13207 if (nid) {
13208 /* spec->multiout.hp_nid = 2; */
13209 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13210 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13211 "Headphone Playback Volume",
13212 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13213 HDA_OUTPUT));
13214 if (err < 0)
13215 return err;
13216 }
13217 if (nid == 0x16) {
13218 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13219 "Headphone Playback Switch",
13220 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13221 HDA_OUTPUT));
13222 if (err < 0)
13223 return err;
13224 } else {
13225 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13226 "Headphone Playback Switch",
13227 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13228 HDA_OUTPUT));
13229 if (err < 0)
13230 return err;
13231 }
13232 }
13233 return 0;
13234}
13235
Takashi Iwai8c927b42009-06-22 10:56:54 +020013236#define alc269_auto_create_analog_input_ctls \
13237 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013238
13239#ifdef CONFIG_SND_HDA_POWER_SAVE
13240#define alc269_loopbacks alc880_loopbacks
13241#endif
13242
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013243/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013244#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13245#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13246#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13247#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13248
Takashi Iwaif03d3112009-03-05 14:18:16 +010013249static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13250 .substreams = 1,
13251 .channels_min = 2,
13252 .channels_max = 8,
13253 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13254 /* NID is set in alc_build_pcms */
13255 .ops = {
13256 .open = alc880_playback_pcm_open,
13257 .prepare = alc880_playback_pcm_prepare,
13258 .cleanup = alc880_playback_pcm_cleanup
13259 },
13260};
13261
13262static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13263 .substreams = 1,
13264 .channels_min = 2,
13265 .channels_max = 2,
13266 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13267 /* NID is set in alc_build_pcms */
13268};
13269
Kailang Yangf6a92242007-12-13 16:52:54 +010013270/*
13271 * BIOS auto configuration
13272 */
13273static int alc269_parse_auto_config(struct hda_codec *codec)
13274{
13275 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013276 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013277 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13278
13279 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13280 alc269_ignore);
13281 if (err < 0)
13282 return err;
13283
13284 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13285 if (err < 0)
13286 return err;
13287 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13288 if (err < 0)
13289 return err;
13290
13291 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13292
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013293 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013294 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13295
Takashi Iwai603c4012008-07-30 15:01:44 +020013296 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013297 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013298
Takashi Iwaid88897e2008-10-31 15:01:37 +010013299 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013300 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013301 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013302 /* set default input source */
13303 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13304 0, AC_VERB_SET_CONNECT_SEL,
13305 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013306
13307 err = alc_auto_add_mic_boost(codec);
13308 if (err < 0)
13309 return err;
13310
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013311 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013312 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013313
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013314 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13315
Kailang Yangf6a92242007-12-13 16:52:54 +010013316 return 1;
13317}
13318
13319#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13320#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13321#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13322
13323
13324/* init callback for auto-configuration model -- overriding the default init */
13325static void alc269_auto_init(struct hda_codec *codec)
13326{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013327 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013328 alc269_auto_init_multi_out(codec);
13329 alc269_auto_init_hp_out(codec);
13330 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013331 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013332 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013333}
13334
13335/*
13336 * configuration and preset
13337 */
13338static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013339 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013340 [ALC269_QUANTA_FL1] = "quanta",
13341 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013342 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013343 [ALC269_FUJITSU] = "fujitsu",
13344 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013345};
13346
13347static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013348 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013349 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13350 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013351 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13352 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13353 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13354 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13355 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13356 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013357 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13358 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013359 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13360 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013361 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013362 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013363 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013364 {}
13365};
13366
13367static struct alc_config_preset alc269_presets[] = {
13368 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013369 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013370 .init_verbs = { alc269_init_verbs },
13371 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13372 .dac_nids = alc269_dac_nids,
13373 .hp_nid = 0x03,
13374 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13375 .channel_mode = alc269_modes,
13376 .input_mux = &alc269_capture_source,
13377 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013378 [ALC269_QUANTA_FL1] = {
13379 .mixers = { alc269_quanta_fl1_mixer },
13380 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13381 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13382 .dac_nids = alc269_dac_nids,
13383 .hp_nid = 0x03,
13384 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13385 .channel_mode = alc269_modes,
13386 .input_mux = &alc269_capture_source,
13387 .unsol_event = alc269_quanta_fl1_unsol_event,
13388 .init_hook = alc269_quanta_fl1_init_hook,
13389 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013390 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013391 .mixers = { alc269_eeepc_mixer },
13392 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013393 .init_verbs = { alc269_init_verbs,
13394 alc269_eeepc_amic_init_verbs },
13395 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13396 .dac_nids = alc269_dac_nids,
13397 .hp_nid = 0x03,
13398 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13399 .channel_mode = alc269_modes,
13400 .input_mux = &alc269_eeepc_amic_capture_source,
13401 .unsol_event = alc269_eeepc_amic_unsol_event,
13402 .init_hook = alc269_eeepc_amic_inithook,
13403 },
13404 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013405 .mixers = { alc269_eeepc_mixer },
13406 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013407 .init_verbs = { alc269_init_verbs,
13408 alc269_eeepc_dmic_init_verbs },
13409 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13410 .dac_nids = alc269_dac_nids,
13411 .hp_nid = 0x03,
13412 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13413 .channel_mode = alc269_modes,
13414 .input_mux = &alc269_eeepc_dmic_capture_source,
13415 .unsol_event = alc269_eeepc_dmic_unsol_event,
13416 .init_hook = alc269_eeepc_dmic_inithook,
13417 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013418 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013419 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013420 .cap_mixer = alc269_epc_capture_mixer,
13421 .init_verbs = { alc269_init_verbs,
13422 alc269_eeepc_dmic_init_verbs },
13423 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13424 .dac_nids = alc269_dac_nids,
13425 .hp_nid = 0x03,
13426 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13427 .channel_mode = alc269_modes,
13428 .input_mux = &alc269_eeepc_dmic_capture_source,
13429 .unsol_event = alc269_eeepc_dmic_unsol_event,
13430 .init_hook = alc269_eeepc_dmic_inithook,
13431 },
Tony Vroon64154832008-11-06 15:08:49 +000013432 [ALC269_LIFEBOOK] = {
13433 .mixers = { alc269_lifebook_mixer },
13434 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
13435 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13436 .dac_nids = alc269_dac_nids,
13437 .hp_nid = 0x03,
13438 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13439 .channel_mode = alc269_modes,
13440 .input_mux = &alc269_capture_source,
13441 .unsol_event = alc269_lifebook_unsol_event,
13442 .init_hook = alc269_lifebook_init_hook,
13443 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013444};
13445
13446static int patch_alc269(struct hda_codec *codec)
13447{
13448 struct alc_spec *spec;
13449 int board_config;
13450 int err;
13451
13452 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13453 if (spec == NULL)
13454 return -ENOMEM;
13455
13456 codec->spec = spec;
13457
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013458 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13459
Kailang Yangf6a92242007-12-13 16:52:54 +010013460 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13461 alc269_models,
13462 alc269_cfg_tbl);
13463
13464 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013465 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13466 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013467 board_config = ALC269_AUTO;
13468 }
13469
13470 if (board_config == ALC269_AUTO) {
13471 /* automatic parse from the BIOS config */
13472 err = alc269_parse_auto_config(codec);
13473 if (err < 0) {
13474 alc_free(codec);
13475 return err;
13476 } else if (!err) {
13477 printk(KERN_INFO
13478 "hda_codec: Cannot set up configuration "
13479 "from BIOS. Using base mode...\n");
13480 board_config = ALC269_BASIC;
13481 }
13482 }
13483
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013484 err = snd_hda_attach_beep_device(codec, 0x1);
13485 if (err < 0) {
13486 alc_free(codec);
13487 return err;
13488 }
13489
Kailang Yangf6a92242007-12-13 16:52:54 +010013490 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013491 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010013492
Takashi Iwaif03d3112009-03-05 14:18:16 +010013493 if (codec->subsystem_id == 0x17aa3bf8) {
13494 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13495 * fix the sample rate of analog I/O to 44.1kHz
13496 */
13497 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13498 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13499 } else {
13500 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13501 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13502 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013503 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13504 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13505
13506 spec->adc_nids = alc269_adc_nids;
13507 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013508 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013509 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013510 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013511 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013512
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013513 spec->vmaster_nid = 0x02;
13514
Kailang Yangf6a92242007-12-13 16:52:54 +010013515 codec->patch_ops = alc_patch_ops;
13516 if (board_config == ALC269_AUTO)
13517 spec->init_hook = alc269_auto_init;
13518#ifdef CONFIG_SND_HDA_POWER_SAVE
13519 if (!spec->loopback.amplist)
13520 spec->loopback.amplist = alc269_loopbacks;
13521#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013522 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013523
13524 return 0;
13525}
13526
13527/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013528 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13529 */
13530
13531/*
13532 * set the path ways for 2 channel output
13533 * need to set the codec line out and mic 1 pin widgets to inputs
13534 */
13535static struct hda_verb alc861_threestack_ch2_init[] = {
13536 /* set pin widget 1Ah (line in) for input */
13537 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013538 /* set pin widget 18h (mic1/2) for input, for mic also enable
13539 * the vref
13540 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013541 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13542
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013543 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13544#if 0
13545 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13546 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13547#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013548 { } /* end */
13549};
13550/*
13551 * 6ch mode
13552 * need to set the codec line out and mic 1 pin widgets to outputs
13553 */
13554static struct hda_verb alc861_threestack_ch6_init[] = {
13555 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13556 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13557 /* set pin widget 18h (mic1) for output (CLFE)*/
13558 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13559
13560 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013561 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013562
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013563 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13564#if 0
13565 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13566 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13567#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013568 { } /* end */
13569};
13570
13571static struct hda_channel_mode alc861_threestack_modes[2] = {
13572 { 2, alc861_threestack_ch2_init },
13573 { 6, alc861_threestack_ch6_init },
13574};
Takashi Iwai22309c32006-08-09 16:57:28 +020013575/* Set mic1 as input and unmute the mixer */
13576static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13577 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13578 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13579 { } /* end */
13580};
13581/* Set mic1 as output and mute mixer */
13582static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13583 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13584 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13585 { } /* end */
13586};
13587
13588static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13589 { 2, alc861_uniwill_m31_ch2_init },
13590 { 4, alc861_uniwill_m31_ch4_init },
13591};
Kailang Yangdf694da2005-12-05 19:42:22 +010013592
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013593/* Set mic1 and line-in as input and unmute the mixer */
13594static struct hda_verb alc861_asus_ch2_init[] = {
13595 /* set pin widget 1Ah (line in) for input */
13596 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013597 /* set pin widget 18h (mic1/2) for input, for mic also enable
13598 * the vref
13599 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013600 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13601
13602 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13603#if 0
13604 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13605 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13606#endif
13607 { } /* end */
13608};
13609/* Set mic1 nad line-in as output and mute mixer */
13610static struct hda_verb alc861_asus_ch6_init[] = {
13611 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13612 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13613 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13614 /* set pin widget 18h (mic1) for output (CLFE)*/
13615 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13616 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13617 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13618 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13619
13620 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13621#if 0
13622 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13623 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13624#endif
13625 { } /* end */
13626};
13627
13628static struct hda_channel_mode alc861_asus_modes[2] = {
13629 { 2, alc861_asus_ch2_init },
13630 { 6, alc861_asus_ch6_init },
13631};
13632
Kailang Yangdf694da2005-12-05 19:42:22 +010013633/* patch-ALC861 */
13634
13635static struct snd_kcontrol_new alc861_base_mixer[] = {
13636 /* output mixer control */
13637 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13638 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13639 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13640 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13641 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13642
13643 /*Input mixer control */
13644 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13645 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13646 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13647 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13648 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13649 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13650 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13651 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13653 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013654
Kailang Yangdf694da2005-12-05 19:42:22 +010013655 { } /* end */
13656};
13657
13658static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13659 /* output mixer control */
13660 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13661 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13662 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13663 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13664 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13665
13666 /* Input mixer control */
13667 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13668 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13669 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13670 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13671 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13672 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13674 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13675 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013677
Kailang Yangdf694da2005-12-05 19:42:22 +010013678 {
13679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13680 .name = "Channel Mode",
13681 .info = alc_ch_mode_info,
13682 .get = alc_ch_mode_get,
13683 .put = alc_ch_mode_put,
13684 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13685 },
13686 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013687};
13688
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013689static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013690 /* output mixer control */
13691 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13692 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13693 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013694
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013695 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013696};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013697
Takashi Iwai22309c32006-08-09 16:57:28 +020013698static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13699 /* output mixer control */
13700 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13701 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13702 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13703 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13704 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13705
13706 /* Input mixer control */
13707 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13708 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13709 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13710 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13711 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13712 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13713 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13714 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13715 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13716 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013717
Takashi Iwai22309c32006-08-09 16:57:28 +020013718 {
13719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13720 .name = "Channel Mode",
13721 .info = alc_ch_mode_info,
13722 .get = alc_ch_mode_get,
13723 .put = alc_ch_mode_put,
13724 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13725 },
13726 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013727};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013728
13729static struct snd_kcontrol_new alc861_asus_mixer[] = {
13730 /* output mixer control */
13731 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13732 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13733 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13734 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13735 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13736
13737 /* Input mixer control */
13738 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13739 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13740 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13741 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13742 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13743 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13745 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13746 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13748
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013749 {
13750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13751 .name = "Channel Mode",
13752 .info = alc_ch_mode_info,
13753 .get = alc_ch_mode_get,
13754 .put = alc_ch_mode_put,
13755 .private_value = ARRAY_SIZE(alc861_asus_modes),
13756 },
13757 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013758};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013759
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013760/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013761static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013762 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13763 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013764 { }
13765};
13766
Kailang Yangdf694da2005-12-05 19:42:22 +010013767/*
13768 * generic initialization of ADC, input mixers and output mixers
13769 */
13770static struct hda_verb alc861_base_init_verbs[] = {
13771 /*
13772 * Unmute ADC0 and set the default input to mic-in
13773 */
13774 /* port-A for surround (rear panel) */
13775 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13776 { 0x0e, AC_VERB_SET_CONNECT_SEL, 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) */
13785 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13786 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013787 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013788 /* port-F for mic-in (front panel) with vref */
13789 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13790 /* port-G for CLFE (rear panel) */
13791 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13792 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13793 /* port-H for side (rear panel) */
13794 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13795 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13796 /* CD-in */
13797 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13798 /* route front mic to ADC1*/
13799 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13800 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013801
Kailang Yangdf694da2005-12-05 19:42:22 +010013802 /* Unmute DAC0~3 & spdif out*/
13803 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13804 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13805 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13806 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13807 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013808
Kailang Yangdf694da2005-12-05 19:42:22 +010013809 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13810 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13811 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13812 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13813 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013814
Kailang Yangdf694da2005-12-05 19:42:22 +010013815 /* Unmute Stereo Mixer 15 */
13816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13817 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013820
13821 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13822 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13823 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13824 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13826 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013829 /* hp used DAC 3 (Front) */
13830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13832
13833 { }
13834};
13835
13836static struct hda_verb alc861_threestack_init_verbs[] = {
13837 /*
13838 * Unmute ADC0 and set the default input to mic-in
13839 */
13840 /* port-A for surround (rear panel) */
13841 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13842 /* port-B for mic-in (rear panel) with vref */
13843 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13844 /* port-C for line-in (rear panel) */
13845 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13846 /* port-D for Front */
13847 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13848 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13849 /* port-E for HP out (front panel) */
13850 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13851 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013852 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013853 /* port-F for mic-in (front panel) with vref */
13854 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13855 /* port-G for CLFE (rear panel) */
13856 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13857 /* port-H for side (rear panel) */
13858 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13859 /* CD-in */
13860 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13861 /* route front mic to ADC1*/
13862 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13863 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13864 /* Unmute DAC0~3 & spdif out*/
13865 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13866 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13867 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13868 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13869 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013870
Kailang Yangdf694da2005-12-05 19:42:22 +010013871 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13872 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13873 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13874 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13875 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013876
Kailang Yangdf694da2005-12-05 19:42:22 +010013877 /* Unmute Stereo Mixer 15 */
13878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013881 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013882
13883 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13884 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13885 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13886 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13887 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13888 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13889 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13890 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013891 /* hp used DAC 3 (Front) */
13892 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013893 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13894 { }
13895};
Takashi Iwai22309c32006-08-09 16:57:28 +020013896
13897static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13898 /*
13899 * Unmute ADC0 and set the default input to mic-in
13900 */
13901 /* port-A for surround (rear panel) */
13902 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13903 /* port-B for mic-in (rear panel) with vref */
13904 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13905 /* port-C for line-in (rear panel) */
13906 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13907 /* port-D for Front */
13908 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13909 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13910 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013911 /* this has to be set to VREF80 */
13912 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013913 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013914 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013915 /* port-F for mic-in (front panel) with vref */
13916 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13917 /* port-G for CLFE (rear panel) */
13918 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13919 /* port-H for side (rear panel) */
13920 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13921 /* CD-in */
13922 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13923 /* route front mic to ADC1*/
13924 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13925 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13926 /* Unmute DAC0~3 & spdif out*/
13927 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13928 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13929 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13930 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013932
Takashi Iwai22309c32006-08-09 16:57:28 +020013933 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13934 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13935 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13936 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13937 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013938
Takashi Iwai22309c32006-08-09 16:57:28 +020013939 /* Unmute Stereo Mixer 15 */
13940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13941 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013943 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013944
13945 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13946 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13948 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13949 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13951 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13952 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013953 /* hp used DAC 3 (Front) */
13954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013955 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13956 { }
13957};
13958
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013959static struct hda_verb alc861_asus_init_verbs[] = {
13960 /*
13961 * Unmute ADC0 and set the default input to mic-in
13962 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013963 /* port-A for surround (rear panel)
13964 * according to codec#0 this is the HP jack
13965 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013966 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13967 /* route front PCM to HP */
13968 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13969 /* port-B for mic-in (rear panel) with vref */
13970 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13971 /* port-C for line-in (rear panel) */
13972 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13973 /* port-D for Front */
13974 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13975 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13976 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013977 /* this has to be set to VREF80 */
13978 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013979 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013980 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013981 /* port-F for mic-in (front panel) with vref */
13982 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13983 /* port-G for CLFE (rear panel) */
13984 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13985 /* port-H for side (rear panel) */
13986 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13987 /* CD-in */
13988 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13989 /* route front mic to ADC1*/
13990 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13991 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13992 /* Unmute DAC0~3 & spdif out*/
13993 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13994 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13995 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13996 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13997 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13998 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13999 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14000 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14001 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14002 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014003
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014004 /* Unmute Stereo Mixer 15 */
14005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14006 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14007 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014009
14010 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14011 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14012 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14013 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14014 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14016 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14017 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014018 /* hp used DAC 3 (Front) */
14019 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14021 { }
14022};
14023
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014024/* additional init verbs for ASUS laptops */
14025static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14026 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14027 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14028 { }
14029};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014030
Kailang Yangdf694da2005-12-05 19:42:22 +010014031/*
14032 * generic initialization of ADC, input mixers and output mixers
14033 */
14034static struct hda_verb alc861_auto_init_verbs[] = {
14035 /*
14036 * Unmute ADC0 and set the default input to mic-in
14037 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014038 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014040
Kailang Yangdf694da2005-12-05 19:42:22 +010014041 /* Unmute DAC0~3 & spdif out*/
14042 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14043 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14044 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14045 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14046 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014047
Kailang Yangdf694da2005-12-05 19:42:22 +010014048 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14049 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14050 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14051 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14052 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014053
Kailang Yangdf694da2005-12-05 19:42:22 +010014054 /* Unmute Stereo Mixer 15 */
14055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14059
Takashi Iwai1c209302009-07-22 15:17:45 +020014060 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14061 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14062 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14063 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14064 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14065 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14066 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14067 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014068
14069 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014071 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014073 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14074 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014075 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14076 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014077
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014079
14080 { }
14081};
14082
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014083static struct hda_verb alc861_toshiba_init_verbs[] = {
14084 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014085
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014086 { }
14087};
14088
14089/* toggle speaker-output according to the hp-jack state */
14090static void alc861_toshiba_automute(struct hda_codec *codec)
14091{
14092 unsigned int present;
14093
14094 present = snd_hda_codec_read(codec, 0x0f, 0,
14095 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014096 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14097 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14098 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14099 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014100}
14101
14102static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14103 unsigned int res)
14104{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014105 if ((res >> 26) == ALC880_HP_EVENT)
14106 alc861_toshiba_automute(codec);
14107}
14108
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014109/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014110#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14111#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14112#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14113#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14114
14115
14116#define ALC861_DIGOUT_NID 0x07
14117
14118static struct hda_channel_mode alc861_8ch_modes[1] = {
14119 { 8, NULL }
14120};
14121
14122static hda_nid_t alc861_dac_nids[4] = {
14123 /* front, surround, clfe, side */
14124 0x03, 0x06, 0x05, 0x04
14125};
14126
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014127static hda_nid_t alc660_dac_nids[3] = {
14128 /* front, clfe, surround */
14129 0x03, 0x05, 0x06
14130};
14131
Kailang Yangdf694da2005-12-05 19:42:22 +010014132static hda_nid_t alc861_adc_nids[1] = {
14133 /* ADC0-2 */
14134 0x08,
14135};
14136
14137static struct hda_input_mux alc861_capture_source = {
14138 .num_items = 5,
14139 .items = {
14140 { "Mic", 0x0 },
14141 { "Front Mic", 0x3 },
14142 { "Line", 0x1 },
14143 { "CD", 0x4 },
14144 { "Mixer", 0x5 },
14145 },
14146};
14147
Takashi Iwai1c209302009-07-22 15:17:45 +020014148static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14149{
14150 struct alc_spec *spec = codec->spec;
14151 hda_nid_t mix, srcs[5];
14152 int i, j, num;
14153
14154 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14155 return 0;
14156 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14157 if (num < 0)
14158 return 0;
14159 for (i = 0; i < num; i++) {
14160 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014161 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014162 if (type != AC_WID_AUD_OUT)
14163 continue;
14164 for (j = 0; j < spec->multiout.num_dacs; j++)
14165 if (spec->multiout.dac_nids[j] == srcs[i])
14166 break;
14167 if (j >= spec->multiout.num_dacs)
14168 return srcs[i];
14169 }
14170 return 0;
14171}
14172
Kailang Yangdf694da2005-12-05 19:42:22 +010014173/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014174static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014175 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014176{
Takashi Iwai1c209302009-07-22 15:17:45 +020014177 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014178 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014179 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014180
14181 spec->multiout.dac_nids = spec->private_dac_nids;
14182 for (i = 0; i < cfg->line_outs; i++) {
14183 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014184 dac = alc861_look_for_dac(codec, nid);
14185 if (!dac)
14186 continue;
14187 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014188 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014189 return 0;
14190}
14191
Takashi Iwai1c209302009-07-22 15:17:45 +020014192static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14193 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014194{
14195 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014196 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14197 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14198 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14199}
14200
14201/* add playback controls from the parsed DAC table */
14202static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14203 const struct auto_pin_cfg *cfg)
14204{
14205 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014206 static const char *chname[4] = {
14207 "Front", "Surround", NULL /*CLFE*/, "Side"
14208 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014209 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014210 int i, err;
14211
14212 if (cfg->line_outs == 1) {
14213 const char *pfx = NULL;
14214 if (!cfg->hp_outs)
14215 pfx = "Master";
14216 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14217 pfx = "Speaker";
14218 if (pfx) {
14219 nid = spec->multiout.dac_nids[0];
14220 return alc861_create_out_sw(codec, pfx, nid, 3);
14221 }
14222 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014223
14224 for (i = 0; i < cfg->line_outs; i++) {
14225 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014226 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014227 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014228 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014229 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014230 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014231 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014232 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014233 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014234 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014235 return err;
14236 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014237 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014238 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014239 return err;
14240 }
14241 }
14242 return 0;
14243}
14244
Takashi Iwai1c209302009-07-22 15:17:45 +020014245static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014246{
Takashi Iwai1c209302009-07-22 15:17:45 +020014247 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014248 int err;
14249 hda_nid_t nid;
14250
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014251 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014252 return 0;
14253
14254 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014255 nid = alc861_look_for_dac(codec, pin);
14256 if (nid) {
14257 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14258 if (err < 0)
14259 return err;
14260 spec->multiout.hp_nid = nid;
14261 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014262 }
14263 return 0;
14264}
14265
14266/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014267static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014268 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014269{
Takashi Iwai1c209302009-07-22 15:17:45 +020014270 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014271 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014272 int i, err, idx, idx1;
14273
14274 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014275 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014276 case 0x0c:
14277 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014278 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014279 break;
14280 case 0x0f:
14281 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014282 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014283 break;
14284 case 0x0d:
14285 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014286 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014287 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014288 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014289 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014290 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014291 break;
14292 case 0x11:
14293 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014294 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014295 break;
14296 default:
14297 continue;
14298 }
14299
Takashi Iwai4a471b72005-12-07 13:56:29 +010014300 err = new_analog_input(spec, cfg->input_pins[i],
14301 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014302 if (err < 0)
14303 return err;
14304
Takashi Iwai4a471b72005-12-07 13:56:29 +010014305 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014306 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014307 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014308 }
14309 return 0;
14310}
14311
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014312static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14313 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014314 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014315{
Takashi Iwai1c209302009-07-22 15:17:45 +020014316 hda_nid_t mix, srcs[5];
14317 int i, num;
14318
Jacek Luczak564c5be2008-05-03 18:41:23 +020014319 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14320 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014321 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014322 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014323 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14324 return;
14325 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14326 if (num < 0)
14327 return;
14328 for (i = 0; i < num; i++) {
14329 unsigned int mute;
14330 if (srcs[i] == dac || srcs[i] == 0x15)
14331 mute = AMP_IN_UNMUTE(i);
14332 else
14333 mute = AMP_IN_MUTE(i);
14334 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14335 mute);
14336 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014337}
14338
14339static void alc861_auto_init_multi_out(struct hda_codec *codec)
14340{
14341 struct alc_spec *spec = codec->spec;
14342 int i;
14343
14344 for (i = 0; i < spec->autocfg.line_outs; i++) {
14345 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014346 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014347 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014348 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014349 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014350 }
14351}
14352
14353static void alc861_auto_init_hp_out(struct hda_codec *codec)
14354{
14355 struct alc_spec *spec = codec->spec;
14356 hda_nid_t pin;
14357
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014358 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014359 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014360 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014361 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014362 pin = spec->autocfg.speaker_pins[0];
14363 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014364 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14365 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014366}
14367
14368static void alc861_auto_init_analog_input(struct hda_codec *codec)
14369{
14370 struct alc_spec *spec = codec->spec;
14371 int i;
14372
14373 for (i = 0; i < AUTO_PIN_LAST; i++) {
14374 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014375 if (nid >= 0x0c && nid <= 0x11)
14376 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014377 }
14378}
14379
14380/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014381/* return 1 if successful, 0 if the proper config is not found,
14382 * or a negative error code
14383 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014384static int alc861_parse_auto_config(struct hda_codec *codec)
14385{
14386 struct alc_spec *spec = codec->spec;
14387 int err;
14388 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014390 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14391 alc861_ignore);
14392 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014393 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014394 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014395 return 0; /* can't find valid BIOS pin config */
14396
Takashi Iwai1c209302009-07-22 15:17:45 +020014397 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014398 if (err < 0)
14399 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014400 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014401 if (err < 0)
14402 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014403 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014404 if (err < 0)
14405 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014406 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014407 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014408 return err;
14409
14410 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14411
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014412 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014413 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14414
Takashi Iwai603c4012008-07-30 15:01:44 +020014415 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014416 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014417
Takashi Iwaid88897e2008-10-31 15:01:37 +010014418 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014419
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014420 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014421 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014422
14423 spec->adc_nids = alc861_adc_nids;
14424 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014425 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014426
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014427 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14428
Kailang Yangdf694da2005-12-05 19:42:22 +010014429 return 1;
14430}
14431
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014432/* additional initialization for auto-configuration model */
14433static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014434{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014435 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014436 alc861_auto_init_multi_out(codec);
14437 alc861_auto_init_hp_out(codec);
14438 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014439 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014440 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014441}
14442
Takashi Iwaicb53c622007-08-10 17:21:45 +020014443#ifdef CONFIG_SND_HDA_POWER_SAVE
14444static struct hda_amp_list alc861_loopbacks[] = {
14445 { 0x15, HDA_INPUT, 0 },
14446 { 0x15, HDA_INPUT, 1 },
14447 { 0x15, HDA_INPUT, 2 },
14448 { 0x15, HDA_INPUT, 3 },
14449 { } /* end */
14450};
14451#endif
14452
Kailang Yangdf694da2005-12-05 19:42:22 +010014453
14454/*
14455 * configuration and preset
14456 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014457static const char *alc861_models[ALC861_MODEL_LAST] = {
14458 [ALC861_3ST] = "3stack",
14459 [ALC660_3ST] = "3stack-660",
14460 [ALC861_3ST_DIG] = "3stack-dig",
14461 [ALC861_6ST_DIG] = "6stack-dig",
14462 [ALC861_UNIWILL_M31] = "uniwill-m31",
14463 [ALC861_TOSHIBA] = "toshiba",
14464 [ALC861_ASUS] = "asus",
14465 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14466 [ALC861_AUTO] = "auto",
14467};
14468
14469static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014470 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014471 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14472 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14473 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014474 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014475 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014476 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014477 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14478 * Any other models that need this preset?
14479 */
14480 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014481 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14482 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014483 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14484 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14485 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14486 /* FIXME: the below seems conflict */
14487 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14488 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14489 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014490 {}
14491};
14492
14493static struct alc_config_preset alc861_presets[] = {
14494 [ALC861_3ST] = {
14495 .mixers = { alc861_3ST_mixer },
14496 .init_verbs = { alc861_threestack_init_verbs },
14497 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14498 .dac_nids = alc861_dac_nids,
14499 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14500 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014501 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014502 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14503 .adc_nids = alc861_adc_nids,
14504 .input_mux = &alc861_capture_source,
14505 },
14506 [ALC861_3ST_DIG] = {
14507 .mixers = { alc861_base_mixer },
14508 .init_verbs = { alc861_threestack_init_verbs },
14509 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14510 .dac_nids = alc861_dac_nids,
14511 .dig_out_nid = ALC861_DIGOUT_NID,
14512 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14513 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014514 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014515 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14516 .adc_nids = alc861_adc_nids,
14517 .input_mux = &alc861_capture_source,
14518 },
14519 [ALC861_6ST_DIG] = {
14520 .mixers = { alc861_base_mixer },
14521 .init_verbs = { alc861_base_init_verbs },
14522 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14523 .dac_nids = alc861_dac_nids,
14524 .dig_out_nid = ALC861_DIGOUT_NID,
14525 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14526 .channel_mode = alc861_8ch_modes,
14527 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14528 .adc_nids = alc861_adc_nids,
14529 .input_mux = &alc861_capture_source,
14530 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014531 [ALC660_3ST] = {
14532 .mixers = { alc861_3ST_mixer },
14533 .init_verbs = { alc861_threestack_init_verbs },
14534 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14535 .dac_nids = alc660_dac_nids,
14536 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14537 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014538 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014539 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14540 .adc_nids = alc861_adc_nids,
14541 .input_mux = &alc861_capture_source,
14542 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014543 [ALC861_UNIWILL_M31] = {
14544 .mixers = { alc861_uniwill_m31_mixer },
14545 .init_verbs = { alc861_uniwill_m31_init_verbs },
14546 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14547 .dac_nids = alc861_dac_nids,
14548 .dig_out_nid = ALC861_DIGOUT_NID,
14549 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14550 .channel_mode = alc861_uniwill_m31_modes,
14551 .need_dac_fix = 1,
14552 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14553 .adc_nids = alc861_adc_nids,
14554 .input_mux = &alc861_capture_source,
14555 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014556 [ALC861_TOSHIBA] = {
14557 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014558 .init_verbs = { alc861_base_init_verbs,
14559 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014560 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14561 .dac_nids = alc861_dac_nids,
14562 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14563 .channel_mode = alc883_3ST_2ch_modes,
14564 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14565 .adc_nids = alc861_adc_nids,
14566 .input_mux = &alc861_capture_source,
14567 .unsol_event = alc861_toshiba_unsol_event,
14568 .init_hook = alc861_toshiba_automute,
14569 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014570 [ALC861_ASUS] = {
14571 .mixers = { alc861_asus_mixer },
14572 .init_verbs = { alc861_asus_init_verbs },
14573 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14574 .dac_nids = alc861_dac_nids,
14575 .dig_out_nid = ALC861_DIGOUT_NID,
14576 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14577 .channel_mode = alc861_asus_modes,
14578 .need_dac_fix = 1,
14579 .hp_nid = 0x06,
14580 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14581 .adc_nids = alc861_adc_nids,
14582 .input_mux = &alc861_capture_source,
14583 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014584 [ALC861_ASUS_LAPTOP] = {
14585 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14586 .init_verbs = { alc861_asus_init_verbs,
14587 alc861_asus_laptop_init_verbs },
14588 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14589 .dac_nids = alc861_dac_nids,
14590 .dig_out_nid = ALC861_DIGOUT_NID,
14591 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14592 .channel_mode = alc883_3ST_2ch_modes,
14593 .need_dac_fix = 1,
14594 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14595 .adc_nids = alc861_adc_nids,
14596 .input_mux = &alc861_capture_source,
14597 },
14598};
Kailang Yangdf694da2005-12-05 19:42:22 +010014599
14600
14601static int patch_alc861(struct hda_codec *codec)
14602{
14603 struct alc_spec *spec;
14604 int board_config;
14605 int err;
14606
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014607 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014608 if (spec == NULL)
14609 return -ENOMEM;
14610
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014611 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014612
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014613 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14614 alc861_models,
14615 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014616
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014617 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014618 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14619 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014620 board_config = ALC861_AUTO;
14621 }
14622
14623 if (board_config == ALC861_AUTO) {
14624 /* automatic parse from the BIOS config */
14625 err = alc861_parse_auto_config(codec);
14626 if (err < 0) {
14627 alc_free(codec);
14628 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014629 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014630 printk(KERN_INFO
14631 "hda_codec: Cannot set up configuration "
14632 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014633 board_config = ALC861_3ST_DIG;
14634 }
14635 }
14636
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014637 err = snd_hda_attach_beep_device(codec, 0x23);
14638 if (err < 0) {
14639 alc_free(codec);
14640 return err;
14641 }
14642
Kailang Yangdf694da2005-12-05 19:42:22 +010014643 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014644 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014645
Kailang Yangdf694da2005-12-05 19:42:22 +010014646 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14647 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14648
Kailang Yangdf694da2005-12-05 19:42:22 +010014649 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14650 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14651
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014652 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14653
Takashi Iwai2134ea42008-01-10 16:53:55 +010014654 spec->vmaster_nid = 0x03;
14655
Kailang Yangdf694da2005-12-05 19:42:22 +010014656 codec->patch_ops = alc_patch_ops;
14657 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014658 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014659#ifdef CONFIG_SND_HDA_POWER_SAVE
14660 if (!spec->loopback.amplist)
14661 spec->loopback.amplist = alc861_loopbacks;
14662#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014663 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014664
Kailang Yangdf694da2005-12-05 19:42:22 +010014665 return 0;
14666}
14667
14668/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014669 * ALC861-VD support
14670 *
14671 * Based on ALC882
14672 *
14673 * In addition, an independent DAC
14674 */
14675#define ALC861VD_DIGOUT_NID 0x06
14676
14677static hda_nid_t alc861vd_dac_nids[4] = {
14678 /* front, surr, clfe, side surr */
14679 0x02, 0x03, 0x04, 0x05
14680};
14681
14682/* dac_nids for ALC660vd are in a different order - according to
14683 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014684 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014685 * of ALC660vd codecs, but for now there is only 3stack mixer
14686 * - and it is the same as in 861vd.
14687 * adc_nids in ALC660vd are (is) the same as in 861vd
14688 */
14689static hda_nid_t alc660vd_dac_nids[3] = {
14690 /* front, rear, clfe, rear_surr */
14691 0x02, 0x04, 0x03
14692};
14693
14694static hda_nid_t alc861vd_adc_nids[1] = {
14695 /* ADC0 */
14696 0x09,
14697};
14698
Takashi Iwaie1406342008-02-11 18:32:32 +010014699static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14700
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014701/* input MUX */
14702/* FIXME: should be a matrix-type input source selection */
14703static struct hda_input_mux alc861vd_capture_source = {
14704 .num_items = 4,
14705 .items = {
14706 { "Mic", 0x0 },
14707 { "Front Mic", 0x1 },
14708 { "Line", 0x2 },
14709 { "CD", 0x4 },
14710 },
14711};
14712
Kailang Yang272a5272007-05-14 11:00:38 +020014713static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014714 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014715 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014716 { "Ext Mic", 0x0 },
14717 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014718 },
14719};
14720
Kailang Yangd1a991a2007-08-15 16:21:59 +020014721static struct hda_input_mux alc861vd_hp_capture_source = {
14722 .num_items = 2,
14723 .items = {
14724 { "Front Mic", 0x0 },
14725 { "ATAPI Mic", 0x1 },
14726 },
14727};
14728
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014729/*
14730 * 2ch mode
14731 */
14732static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14733 { 2, NULL }
14734};
14735
14736/*
14737 * 6ch mode
14738 */
14739static struct hda_verb alc861vd_6stack_ch6_init[] = {
14740 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14744 { } /* end */
14745};
14746
14747/*
14748 * 8ch mode
14749 */
14750static struct hda_verb alc861vd_6stack_ch8_init[] = {
14751 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14752 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14753 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14754 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14755 { } /* end */
14756};
14757
14758static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14759 { 6, alc861vd_6stack_ch6_init },
14760 { 8, alc861vd_6stack_ch8_init },
14761};
14762
14763static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14764 {
14765 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14766 .name = "Channel Mode",
14767 .info = alc_ch_mode_info,
14768 .get = alc_ch_mode_get,
14769 .put = alc_ch_mode_put,
14770 },
14771 { } /* end */
14772};
14773
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014774/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14775 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14776 */
14777static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14778 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14779 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14780
14781 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14782 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14783
14784 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14785 HDA_OUTPUT),
14786 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14787 HDA_OUTPUT),
14788 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14789 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14790
14791 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14792 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14793
14794 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14795
14796 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14798 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14799
14800 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14802 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14803
14804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14806
14807 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14808 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14809
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014810 { } /* end */
14811};
14812
14813static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14814 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14815 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14816
14817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14818
14819 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14821 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14822
14823 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14824 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14825 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14826
14827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14829
14830 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14831 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14832
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014833 { } /* end */
14834};
14835
Kailang Yangbdd148a2007-05-08 15:19:08 +020014836static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14837 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14838 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14839 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14840
14841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14842
14843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14844 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14846
14847 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14848 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14849 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14850
14851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14853
14854 { } /* end */
14855};
14856
Tobin Davisb419f342008-03-07 11:57:51 +010014857/* Pin assignment: Speaker=0x14, HP = 0x15,
14858 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014859 */
14860static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014861 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14862 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014863 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14864 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014865 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14866 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14867 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14868 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14869 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14870 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014871 { } /* end */
14872};
14873
Kailang Yangd1a991a2007-08-15 16:21:59 +020014874/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14875 * Front Mic=0x18, ATAPI Mic = 0x19,
14876 */
14877static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14878 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14880 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14881 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14882 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14883 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14884 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14885 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014886
Kailang Yangd1a991a2007-08-15 16:21:59 +020014887 { } /* end */
14888};
14889
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014890/*
14891 * generic initialization of ADC, input mixers and output mixers
14892 */
14893static struct hda_verb alc861vd_volume_init_verbs[] = {
14894 /*
14895 * Unmute ADC0 and set the default input to mic-in
14896 */
14897 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14898 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14899
14900 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14901 * the analog-loopback mixer widget
14902 */
14903 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014904 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14905 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14906 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14907 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14908 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014909
14910 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014915
14916 /*
14917 * Set up output mixers (0x02 - 0x05)
14918 */
14919 /* set vol=0 to output mixers */
14920 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14921 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14922 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14923 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14924
14925 /* set up input amps for analog loopback */
14926 /* Amp Indices: DAC = 0, mixer = 1 */
14927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14929 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14930 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14931 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14932 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14933 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14934 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14935
14936 { }
14937};
14938
14939/*
14940 * 3-stack pin configuration:
14941 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14942 */
14943static struct hda_verb alc861vd_3stack_init_verbs[] = {
14944 /*
14945 * Set pin mode and muting
14946 */
14947 /* set front pin widgets 0x14 for output */
14948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14950 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14951
14952 /* Mic (rear) pin: input vref at 80% */
14953 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14954 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14955 /* Front Mic pin: input vref at 80% */
14956 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14957 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14958 /* Line In pin: input */
14959 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14960 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14961 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14965 /* CD pin widget for input */
14966 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14967
14968 { }
14969};
14970
14971/*
14972 * 6-stack pin configuration:
14973 */
14974static struct hda_verb alc861vd_6stack_init_verbs[] = {
14975 /*
14976 * Set pin mode and muting
14977 */
14978 /* set front pin widgets 0x14 for output */
14979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14981 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14982
14983 /* Rear Pin: output 1 (0x0d) */
14984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14986 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14987 /* CLFE Pin: output 2 (0x0e) */
14988 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14989 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14990 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14991 /* Side Pin: output 3 (0x0f) */
14992 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14993 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14994 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14995
14996 /* Mic (rear) pin: input vref at 80% */
14997 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14998 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14999 /* Front Mic pin: input vref at 80% */
15000 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15001 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15002 /* Line In pin: input */
15003 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15004 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15005 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15006 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15007 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15008 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15009 /* CD pin widget for input */
15010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15011
15012 { }
15013};
15014
Kailang Yangbdd148a2007-05-08 15:19:08 +020015015static struct hda_verb alc861vd_eapd_verbs[] = {
15016 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15017 { }
15018};
15019
Kailang Yangf9423e72008-05-27 12:32:25 +020015020static struct hda_verb alc660vd_eapd_verbs[] = {
15021 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15022 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15023 { }
15024};
15025
Kailang Yangbdd148a2007-05-08 15:19:08 +020015026static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15028 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15029 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15030 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015031 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015032 {}
15033};
15034
Kailang Yangbdd148a2007-05-08 15:19:08 +020015035static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15036{
15037 unsigned int present;
15038 unsigned char bits;
15039
15040 present = snd_hda_codec_read(codec, 0x18, 0,
15041 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015042 bits = present ? HDA_AMP_MUTE : 0;
15043 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15044 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015045}
15046
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015047static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015048{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015049 struct alc_spec *spec = codec->spec;
15050
15051 spec->autocfg.hp_pins[0] = 0x1b;
15052 spec->autocfg.speaker_pins[0] = 0x14;
15053 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015054 alc861vd_lenovo_mic_automute(codec);
15055}
15056
15057static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15058 unsigned int res)
15059{
15060 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015061 case ALC880_MIC_EVENT:
15062 alc861vd_lenovo_mic_automute(codec);
15063 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015064 default:
15065 alc_automute_amp_unsol_event(codec, res);
15066 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015067 }
15068}
15069
Kailang Yang272a5272007-05-14 11:00:38 +020015070static struct hda_verb alc861vd_dallas_verbs[] = {
15071 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15072 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15073 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15074 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15075
15076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15077 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015084
Kailang Yang272a5272007-05-14 11:00:38 +020015085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15091 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15092 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15093
15094 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15095 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15096 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15097 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15098 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15099 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15100 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15101 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15102
15103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15106 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15107
15108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015109 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15111
15112 { } /* end */
15113};
15114
15115/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015116static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015117{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015118 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015119
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015120 spec->autocfg.hp_pins[0] = 0x15;
15121 spec->autocfg.speaker_pins[0] = 0x14;
15122 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015123}
15124
Takashi Iwaicb53c622007-08-10 17:21:45 +020015125#ifdef CONFIG_SND_HDA_POWER_SAVE
15126#define alc861vd_loopbacks alc880_loopbacks
15127#endif
15128
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015129/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015130#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15131#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15132#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15133#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15134
15135/*
15136 * configuration and preset
15137 */
15138static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15139 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015140 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015141 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015142 [ALC861VD_3ST] = "3stack",
15143 [ALC861VD_3ST_DIG] = "3stack-digout",
15144 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015145 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015146 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015147 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015148 [ALC861VD_AUTO] = "auto",
15149};
15150
15151static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015152 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15153 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015154 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015155 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015156 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015157 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015158 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015159 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015160 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015161 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015162 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015163 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015164 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015165 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015166 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015167 {}
15168};
15169
15170static struct alc_config_preset alc861vd_presets[] = {
15171 [ALC660VD_3ST] = {
15172 .mixers = { alc861vd_3st_mixer },
15173 .init_verbs = { alc861vd_volume_init_verbs,
15174 alc861vd_3stack_init_verbs },
15175 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15176 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015177 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15178 .channel_mode = alc861vd_3stack_2ch_modes,
15179 .input_mux = &alc861vd_capture_source,
15180 },
Mike Crash6963f842007-06-25 12:12:51 +020015181 [ALC660VD_3ST_DIG] = {
15182 .mixers = { alc861vd_3st_mixer },
15183 .init_verbs = { alc861vd_volume_init_verbs,
15184 alc861vd_3stack_init_verbs },
15185 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15186 .dac_nids = alc660vd_dac_nids,
15187 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015188 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15189 .channel_mode = alc861vd_3stack_2ch_modes,
15190 .input_mux = &alc861vd_capture_source,
15191 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015192 [ALC861VD_3ST] = {
15193 .mixers = { alc861vd_3st_mixer },
15194 .init_verbs = { alc861vd_volume_init_verbs,
15195 alc861vd_3stack_init_verbs },
15196 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15197 .dac_nids = alc861vd_dac_nids,
15198 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15199 .channel_mode = alc861vd_3stack_2ch_modes,
15200 .input_mux = &alc861vd_capture_source,
15201 },
15202 [ALC861VD_3ST_DIG] = {
15203 .mixers = { alc861vd_3st_mixer },
15204 .init_verbs = { alc861vd_volume_init_verbs,
15205 alc861vd_3stack_init_verbs },
15206 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15207 .dac_nids = alc861vd_dac_nids,
15208 .dig_out_nid = ALC861VD_DIGOUT_NID,
15209 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15210 .channel_mode = alc861vd_3stack_2ch_modes,
15211 .input_mux = &alc861vd_capture_source,
15212 },
15213 [ALC861VD_6ST_DIG] = {
15214 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15215 .init_verbs = { alc861vd_volume_init_verbs,
15216 alc861vd_6stack_init_verbs },
15217 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15218 .dac_nids = alc861vd_dac_nids,
15219 .dig_out_nid = ALC861VD_DIGOUT_NID,
15220 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15221 .channel_mode = alc861vd_6stack_modes,
15222 .input_mux = &alc861vd_capture_source,
15223 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015224 [ALC861VD_LENOVO] = {
15225 .mixers = { alc861vd_lenovo_mixer },
15226 .init_verbs = { alc861vd_volume_init_verbs,
15227 alc861vd_3stack_init_verbs,
15228 alc861vd_eapd_verbs,
15229 alc861vd_lenovo_unsol_verbs },
15230 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15231 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015232 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15233 .channel_mode = alc861vd_3stack_2ch_modes,
15234 .input_mux = &alc861vd_capture_source,
15235 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015236 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015237 },
Kailang Yang272a5272007-05-14 11:00:38 +020015238 [ALC861VD_DALLAS] = {
15239 .mixers = { alc861vd_dallas_mixer },
15240 .init_verbs = { alc861vd_dallas_verbs },
15241 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15242 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015243 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15244 .channel_mode = alc861vd_3stack_2ch_modes,
15245 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015246 .unsol_event = alc_automute_amp_unsol_event,
15247 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015248 },
15249 [ALC861VD_HP] = {
15250 .mixers = { alc861vd_hp_mixer },
15251 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15252 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15253 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015254 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015255 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15256 .channel_mode = alc861vd_3stack_2ch_modes,
15257 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015258 .unsol_event = alc_automute_amp_unsol_event,
15259 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015260 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015261 [ALC660VD_ASUS_V1S] = {
15262 .mixers = { alc861vd_lenovo_mixer },
15263 .init_verbs = { alc861vd_volume_init_verbs,
15264 alc861vd_3stack_init_verbs,
15265 alc861vd_eapd_verbs,
15266 alc861vd_lenovo_unsol_verbs },
15267 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15268 .dac_nids = alc660vd_dac_nids,
15269 .dig_out_nid = ALC861VD_DIGOUT_NID,
15270 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15271 .channel_mode = alc861vd_3stack_2ch_modes,
15272 .input_mux = &alc861vd_capture_source,
15273 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015274 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015275 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015276};
15277
15278/*
15279 * BIOS auto configuration
15280 */
15281static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15282 hda_nid_t nid, int pin_type, int dac_idx)
15283{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015284 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015285}
15286
15287static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15288{
15289 struct alc_spec *spec = codec->spec;
15290 int i;
15291
15292 for (i = 0; i <= HDA_SIDE; i++) {
15293 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015294 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015295 if (nid)
15296 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015297 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015298 }
15299}
15300
15301
15302static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15303{
15304 struct alc_spec *spec = codec->spec;
15305 hda_nid_t pin;
15306
15307 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015308 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015309 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015310 pin = spec->autocfg.speaker_pins[0];
15311 if (pin)
15312 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015313}
15314
15315#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15316#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15317
15318static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15319{
15320 struct alc_spec *spec = codec->spec;
15321 int i;
15322
15323 for (i = 0; i < AUTO_PIN_LAST; i++) {
15324 hda_nid_t nid = spec->autocfg.input_pins[i];
15325 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015326 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015327 if (nid != ALC861VD_PIN_CD_NID &&
15328 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015329 snd_hda_codec_write(codec, nid, 0,
15330 AC_VERB_SET_AMP_GAIN_MUTE,
15331 AMP_OUT_MUTE);
15332 }
15333 }
15334}
15335
Takashi Iwaif511b012008-08-15 16:46:42 +020015336#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15337
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015338#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15339#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15340
15341/* add playback controls from the parsed DAC table */
15342/* Based on ALC880 version. But ALC861VD has separate,
15343 * different NIDs for mute/unmute switch and volume control */
15344static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15345 const struct auto_pin_cfg *cfg)
15346{
15347 char name[32];
15348 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15349 hda_nid_t nid_v, nid_s;
15350 int i, err;
15351
15352 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015353 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015354 continue;
15355 nid_v = alc861vd_idx_to_mixer_vol(
15356 alc880_dac_to_idx(
15357 spec->multiout.dac_nids[i]));
15358 nid_s = alc861vd_idx_to_mixer_switch(
15359 alc880_dac_to_idx(
15360 spec->multiout.dac_nids[i]));
15361
15362 if (i == 2) {
15363 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015364 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15365 "Center Playback Volume",
15366 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15367 HDA_OUTPUT));
15368 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015369 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015370 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15371 "LFE Playback Volume",
15372 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15373 HDA_OUTPUT));
15374 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015375 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015376 err = add_control(spec, ALC_CTL_BIND_MUTE,
15377 "Center Playback Switch",
15378 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15379 HDA_INPUT));
15380 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015382 err = add_control(spec, ALC_CTL_BIND_MUTE,
15383 "LFE Playback Switch",
15384 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15385 HDA_INPUT));
15386 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015387 return err;
15388 } else {
15389 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015390 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15391 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15392 HDA_OUTPUT));
15393 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015394 return err;
15395 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015396 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015397 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015398 HDA_INPUT));
15399 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015400 return err;
15401 }
15402 }
15403 return 0;
15404}
15405
15406/* add playback controls for speaker and HP outputs */
15407/* Based on ALC880 version. But ALC861VD has separate,
15408 * different NIDs for mute/unmute switch and volume control */
15409static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15410 hda_nid_t pin, const char *pfx)
15411{
15412 hda_nid_t nid_v, nid_s;
15413 int err;
15414 char name[32];
15415
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015416 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015417 return 0;
15418
15419 if (alc880_is_fixed_pin(pin)) {
15420 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15421 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015422 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015423 spec->multiout.hp_nid = nid_v;
15424 else
15425 spec->multiout.extra_out_nid[0] = nid_v;
15426 /* control HP volume/switch on the output mixer amp */
15427 nid_v = alc861vd_idx_to_mixer_vol(
15428 alc880_fixed_pin_idx(pin));
15429 nid_s = alc861vd_idx_to_mixer_switch(
15430 alc880_fixed_pin_idx(pin));
15431
15432 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015433 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15434 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15435 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015436 return err;
15437 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015438 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15439 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15440 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015441 return err;
15442 } else if (alc880_is_multi_pin(pin)) {
15443 /* set manual connection */
15444 /* we have only a switch on HP-out PIN */
15445 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015446 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15447 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15448 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015449 return err;
15450 }
15451 return 0;
15452}
15453
15454/* parse the BIOS configuration and set up the alc_spec
15455 * return 1 if successful, 0 if the proper config is not found,
15456 * or a negative error code
15457 * Based on ALC880 version - had to change it to override
15458 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15459static int alc861vd_parse_auto_config(struct hda_codec *codec)
15460{
15461 struct alc_spec *spec = codec->spec;
15462 int err;
15463 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15464
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015465 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15466 alc861vd_ignore);
15467 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015468 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015469 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015470 return 0; /* can't find valid BIOS pin config */
15471
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015472 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15473 if (err < 0)
15474 return err;
15475 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15476 if (err < 0)
15477 return err;
15478 err = alc861vd_auto_create_extra_out(spec,
15479 spec->autocfg.speaker_pins[0],
15480 "Speaker");
15481 if (err < 0)
15482 return err;
15483 err = alc861vd_auto_create_extra_out(spec,
15484 spec->autocfg.hp_pins[0],
15485 "Headphone");
15486 if (err < 0)
15487 return err;
15488 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15489 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015490 return err;
15491
15492 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15493
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015494 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015495 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15496
Takashi Iwai603c4012008-07-30 15:01:44 +020015497 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015498 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015499
Takashi Iwaid88897e2008-10-31 15:01:37 +010015500 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015501
15502 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015503 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015504
Takashi Iwai776e1842007-08-29 15:07:11 +020015505 err = alc_auto_add_mic_boost(codec);
15506 if (err < 0)
15507 return err;
15508
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015509 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15510
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015511 return 1;
15512}
15513
15514/* additional initialization for auto-configuration model */
15515static void alc861vd_auto_init(struct hda_codec *codec)
15516{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015517 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015518 alc861vd_auto_init_multi_out(codec);
15519 alc861vd_auto_init_hp_out(codec);
15520 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015521 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015522 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015523 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015524}
15525
15526static int patch_alc861vd(struct hda_codec *codec)
15527{
15528 struct alc_spec *spec;
15529 int err, board_config;
15530
15531 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15532 if (spec == NULL)
15533 return -ENOMEM;
15534
15535 codec->spec = spec;
15536
15537 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15538 alc861vd_models,
15539 alc861vd_cfg_tbl);
15540
15541 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015542 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15543 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015544 board_config = ALC861VD_AUTO;
15545 }
15546
15547 if (board_config == ALC861VD_AUTO) {
15548 /* automatic parse from the BIOS config */
15549 err = alc861vd_parse_auto_config(codec);
15550 if (err < 0) {
15551 alc_free(codec);
15552 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015553 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015554 printk(KERN_INFO
15555 "hda_codec: Cannot set up configuration "
15556 "from BIOS. Using base mode...\n");
15557 board_config = ALC861VD_3ST;
15558 }
15559 }
15560
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015561 err = snd_hda_attach_beep_device(codec, 0x23);
15562 if (err < 0) {
15563 alc_free(codec);
15564 return err;
15565 }
15566
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015567 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015568 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015569
Kailang Yang2f893282008-05-27 12:14:47 +020015570 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015571 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015572 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015573 }
15574
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015575 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15576 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15577
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015578 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15579 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15580
Takashi Iwaidd704692009-08-11 08:45:11 +020015581 if (!spec->adc_nids) {
15582 spec->adc_nids = alc861vd_adc_nids;
15583 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15584 }
15585 if (!spec->capsrc_nids)
15586 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015587
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015588 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015589 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015590
Takashi Iwai2134ea42008-01-10 16:53:55 +010015591 spec->vmaster_nid = 0x02;
15592
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015593 codec->patch_ops = alc_patch_ops;
15594
15595 if (board_config == ALC861VD_AUTO)
15596 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015597#ifdef CONFIG_SND_HDA_POWER_SAVE
15598 if (!spec->loopback.amplist)
15599 spec->loopback.amplist = alc861vd_loopbacks;
15600#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015601 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015602
15603 return 0;
15604}
15605
15606/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015607 * ALC662 support
15608 *
15609 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15610 * configuration. Each pin widget can choose any input DACs and a mixer.
15611 * Each ADC is connected from a mixer of all inputs. This makes possible
15612 * 6-channel independent captures.
15613 *
15614 * In addition, an independent DAC for the multi-playback (not used in this
15615 * driver yet).
15616 */
15617#define ALC662_DIGOUT_NID 0x06
15618#define ALC662_DIGIN_NID 0x0a
15619
15620static hda_nid_t alc662_dac_nids[4] = {
15621 /* front, rear, clfe, rear_surr */
15622 0x02, 0x03, 0x04
15623};
15624
Kailang Yang622e84c2009-04-21 07:39:04 +020015625static hda_nid_t alc272_dac_nids[2] = {
15626 0x02, 0x03
15627};
15628
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015629static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015630 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015631 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015632};
Takashi Iwaie1406342008-02-11 18:32:32 +010015633
Kailang Yang622e84c2009-04-21 07:39:04 +020015634static hda_nid_t alc272_adc_nids[1] = {
15635 /* ADC1-2 */
15636 0x08,
15637};
15638
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015639static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015640static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15641
Takashi Iwaie1406342008-02-11 18:32:32 +010015642
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015643/* input MUX */
15644/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015645static struct hda_input_mux alc662_capture_source = {
15646 .num_items = 4,
15647 .items = {
15648 { "Mic", 0x0 },
15649 { "Front Mic", 0x1 },
15650 { "Line", 0x2 },
15651 { "CD", 0x4 },
15652 },
15653};
15654
15655static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15656 .num_items = 2,
15657 .items = {
15658 { "Mic", 0x1 },
15659 { "Line", 0x2 },
15660 },
15661};
Kailang Yang291702f2007-10-16 14:28:03 +020015662
15663static struct hda_input_mux alc662_eeepc_capture_source = {
15664 .num_items = 2,
15665 .items = {
15666 { "i-Mic", 0x1 },
15667 { "e-Mic", 0x0 },
15668 },
15669};
15670
Kailang Yang6dda9f42008-05-27 12:05:31 +020015671static struct hda_input_mux alc663_capture_source = {
15672 .num_items = 3,
15673 .items = {
15674 { "Mic", 0x0 },
15675 { "Front Mic", 0x1 },
15676 { "Line", 0x2 },
15677 },
15678};
15679
15680static struct hda_input_mux alc663_m51va_capture_source = {
15681 .num_items = 2,
15682 .items = {
15683 { "Ext-Mic", 0x0 },
15684 { "D-Mic", 0x9 },
15685 },
15686};
15687
Chris Pockelé9541ba12009-05-12 08:08:53 +020015688#if 1 /* set to 0 for testing other input sources below */
15689static struct hda_input_mux alc272_nc10_capture_source = {
15690 .num_items = 2,
15691 .items = {
15692 { "Autoselect Mic", 0x0 },
15693 { "Internal Mic", 0x1 },
15694 },
15695};
15696#else
15697static struct hda_input_mux alc272_nc10_capture_source = {
15698 .num_items = 16,
15699 .items = {
15700 { "Autoselect Mic", 0x0 },
15701 { "Internal Mic", 0x1 },
15702 { "In-0x02", 0x2 },
15703 { "In-0x03", 0x3 },
15704 { "In-0x04", 0x4 },
15705 { "In-0x05", 0x5 },
15706 { "In-0x06", 0x6 },
15707 { "In-0x07", 0x7 },
15708 { "In-0x08", 0x8 },
15709 { "In-0x09", 0x9 },
15710 { "In-0x0a", 0x0a },
15711 { "In-0x0b", 0x0b },
15712 { "In-0x0c", 0x0c },
15713 { "In-0x0d", 0x0d },
15714 { "In-0x0e", 0x0e },
15715 { "In-0x0f", 0x0f },
15716 },
15717};
15718#endif
15719
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015720/*
15721 * 2ch mode
15722 */
15723static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15724 { 2, NULL }
15725};
15726
15727/*
15728 * 2ch mode
15729 */
15730static struct hda_verb alc662_3ST_ch2_init[] = {
15731 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15732 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15735 { } /* end */
15736};
15737
15738/*
15739 * 6ch mode
15740 */
15741static struct hda_verb alc662_3ST_ch6_init[] = {
15742 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15743 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15744 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15745 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15746 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15747 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15748 { } /* end */
15749};
15750
15751static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15752 { 2, alc662_3ST_ch2_init },
15753 { 6, alc662_3ST_ch6_init },
15754};
15755
15756/*
15757 * 2ch mode
15758 */
15759static struct hda_verb alc662_sixstack_ch6_init[] = {
15760 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15761 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15762 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15763 { } /* end */
15764};
15765
15766/*
15767 * 6ch mode
15768 */
15769static struct hda_verb alc662_sixstack_ch8_init[] = {
15770 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15771 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15772 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15773 { } /* end */
15774};
15775
15776static struct hda_channel_mode alc662_5stack_modes[2] = {
15777 { 2, alc662_sixstack_ch6_init },
15778 { 6, alc662_sixstack_ch8_init },
15779};
15780
15781/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15782 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15783 */
15784
15785static struct snd_kcontrol_new alc662_base_mixer[] = {
15786 /* output mixer control */
15787 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015788 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015789 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015790 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015791 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15792 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015793 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15794 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015795 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15796
15797 /*Input mixer control */
15798 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15799 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15800 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15801 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15802 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15803 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15804 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15805 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015806 { } /* end */
15807};
15808
15809static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15810 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015811 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15813 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15814 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15818 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15819 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15820 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015821 { } /* end */
15822};
15823
15824static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15825 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015826 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015827 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015828 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015829 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15830 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015831 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15832 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015833 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15834 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15835 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15836 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15837 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15840 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15841 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015842 { } /* end */
15843};
15844
15845static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15846 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15847 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015848 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15849 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015855 { } /* end */
15856};
15857
Kailang Yang291702f2007-10-16 14:28:03 +020015858static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015859 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15860 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015861
15862 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15863 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15864 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15865
15866 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15867 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15868 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15869 { } /* end */
15870};
15871
Kailang Yang8c427222008-01-10 13:03:59 +010015872static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015873 ALC262_HIPPO_MASTER_SWITCH,
15874 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015875 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015876 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15877 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015878 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15879 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15880 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15881 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15882 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15883 { } /* end */
15884};
15885
Kailang Yangf1d4e282008-08-26 14:03:29 +020015886static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15887 .ops = &snd_hda_bind_vol,
15888 .values = {
15889 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15890 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15891 0
15892 },
15893};
15894
15895static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15896 .ops = &snd_hda_bind_sw,
15897 .values = {
15898 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15899 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15900 0
15901 },
15902};
15903
Kailang Yang6dda9f42008-05-27 12:05:31 +020015904static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015905 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15906 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15908 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15909 { } /* end */
15910};
15911
15912static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15913 .ops = &snd_hda_bind_sw,
15914 .values = {
15915 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15916 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15917 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15918 0
15919 },
15920};
15921
15922static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15923 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15924 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15925 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15927 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15928 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15929
15930 { } /* end */
15931};
15932
15933static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15934 .ops = &snd_hda_bind_sw,
15935 .values = {
15936 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15937 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15938 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15939 0
15940 },
15941};
15942
15943static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15944 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15945 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15947 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15948 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15949 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15950 { } /* end */
15951};
15952
15953static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015954 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15955 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15958 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15959 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15960 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15961 { } /* end */
15962};
15963
15964static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15965 .ops = &snd_hda_bind_vol,
15966 .values = {
15967 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15968 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15969 0
15970 },
15971};
15972
15973static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15974 .ops = &snd_hda_bind_sw,
15975 .values = {
15976 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15977 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15978 0
15979 },
15980};
15981
15982static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15983 HDA_BIND_VOL("Master Playback Volume",
15984 &alc663_asus_two_bind_master_vol),
15985 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15986 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15988 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15989 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015990 { } /* end */
15991};
15992
15993static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15994 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15995 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15996 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15997 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016000 { } /* end */
16001};
16002
16003static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16004 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16005 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16006 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16007 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16008 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16009
16010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16011 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16012 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16013 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16014 { } /* end */
16015};
16016
16017static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16019 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16021
16022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16024 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16025 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16026 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16027 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16028 { } /* end */
16029};
16030
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016031static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16032 {
16033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16034 .name = "Channel Mode",
16035 .info = alc_ch_mode_info,
16036 .get = alc_ch_mode_get,
16037 .put = alc_ch_mode_put,
16038 },
16039 { } /* end */
16040};
16041
16042static struct hda_verb alc662_init_verbs[] = {
16043 /* ADC: mute amp left and right */
16044 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16045 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16046 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16047
Takashi Iwaicb53c622007-08-10 17:21:45 +020016048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016053
Kailang Yangb60dd392007-09-20 12:50:29 +020016054 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16057 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16058 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16059 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016060
16061 /* Front Pin: output 0 (0x0c) */
16062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16063 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16064
16065 /* Rear Pin: output 1 (0x0d) */
16066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16068
16069 /* CLFE Pin: output 2 (0x0e) */
16070 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16071 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16072
16073 /* Mic (rear) pin: input vref at 80% */
16074 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16076 /* Front Mic pin: input vref at 80% */
16077 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16079 /* Line In pin: input */
16080 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16082 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16083 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16084 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16085 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16086 /* CD pin widget for input */
16087 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16088
16089 /* FIXME: use matrix-type input source selection */
16090 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16091 /* Input mixer */
16092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016093 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016094
16095 /* always trun on EAPD */
16096 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16097 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16098
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016099 { }
16100};
16101
16102static struct hda_verb alc662_sue_init_verbs[] = {
16103 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16104 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016105 {}
16106};
16107
16108static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16109 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16110 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16111 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016112};
16113
Kailang Yang8c427222008-01-10 13:03:59 +010016114/* Set Unsolicited Event*/
16115static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16117 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16118 {}
16119};
16120
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016121/*
16122 * generic initialization of ADC, input mixers and output mixers
16123 */
16124static struct hda_verb alc662_auto_init_verbs[] = {
16125 /*
16126 * Unmute ADC and set the default input to mic-in
16127 */
16128 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16129 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16130
16131 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16132 * mixer widget
16133 * Note: PASD motherboards uses the Line In 2 as the input for front
16134 * panel mic (mic 2)
16135 */
16136 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016137 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16138 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16139 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16140 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016142
16143 /*
16144 * Set up output mixers (0x0c - 0x0f)
16145 */
16146 /* set vol=0 to output mixers */
16147 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16148 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16149 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16150
16151 /* set up input amps for analog loopback */
16152 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16154 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16155 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16156 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16157 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016159
16160
16161 /* FIXME: use matrix-type input source selection */
16162 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16163 /* Input mixer */
16164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016166 { }
16167};
16168
Takashi Iwai24fb9172008-09-02 14:48:20 +020016169/* additional verbs for ALC663 */
16170static struct hda_verb alc663_auto_init_verbs[] = {
16171 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16173 { }
16174};
16175
Kailang Yang6dda9f42008-05-27 12:05:31 +020016176static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16178 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016179 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16180 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016181 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016184 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16185 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16186 {}
16187};
16188
Kailang Yangf1d4e282008-08-26 14:03:29 +020016189static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16190 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16191 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16192 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16195 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16196 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16197 {}
16198};
16199
16200static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16201 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16202 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16203 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16204 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16207 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16208 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16209 {}
16210};
16211
16212static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16215 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16218 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16219 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16220 {}
16221};
16222
16223static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16224 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16225 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16226 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16227 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16230 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16231 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16232 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16233 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16234 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16235 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16236 {}
16237};
16238
16239static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16240 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16242 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16243 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16245 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16246 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16247 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16249 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16250 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16251 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16252 {}
16253};
16254
Kailang Yang6dda9f42008-05-27 12:05:31 +020016255static struct hda_verb alc663_g71v_init_verbs[] = {
16256 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16257 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16258 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16259
16260 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16261 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16262 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16263
16264 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16266 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16267 {}
16268};
16269
16270static struct hda_verb alc663_g50v_init_verbs[] = {
16271 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16272 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16273 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16274
16275 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16276 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16277 {}
16278};
16279
Kailang Yangf1d4e282008-08-26 14:03:29 +020016280static struct hda_verb alc662_ecs_init_verbs[] = {
16281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16283 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16284 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16285 {}
16286};
16287
Kailang Yang622e84c2009-04-21 07:39:04 +020016288static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16289 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16290 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16291 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16292 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16293 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16294 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16295 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16298 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16299 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16300 {}
16301};
16302
16303static struct hda_verb alc272_dell_init_verbs[] = {
16304 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16305 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16306 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16307 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16308 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16309 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16310 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16311 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16312 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16313 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16314 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16315 {}
16316};
16317
Kailang Yangf1d4e282008-08-26 14:03:29 +020016318static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16319 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16320 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16321 { } /* end */
16322};
16323
Kailang Yang622e84c2009-04-21 07:39:04 +020016324static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16325 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16326 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16327 { } /* end */
16328};
16329
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016330static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16331{
16332 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016333 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016334
16335 present = snd_hda_codec_read(codec, 0x14, 0,
16336 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016337 bits = present ? HDA_AMP_MUTE : 0;
16338 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16339 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016340}
16341
16342static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16343{
16344 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016345 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016346
16347 present = snd_hda_codec_read(codec, 0x1b, 0,
16348 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016349 bits = present ? HDA_AMP_MUTE : 0;
16350 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16351 HDA_AMP_MUTE, bits);
16352 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16353 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016354}
16355
16356static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16357 unsigned int res)
16358{
16359 if ((res >> 26) == ALC880_HP_EVENT)
16360 alc662_lenovo_101e_all_automute(codec);
16361 if ((res >> 26) == ALC880_FRONT_EVENT)
16362 alc662_lenovo_101e_ispeaker_automute(codec);
16363}
16364
Kailang Yang291702f2007-10-16 14:28:03 +020016365static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16366{
16367 unsigned int present;
16368
16369 present = snd_hda_codec_read(codec, 0x18, 0,
16370 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16371 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16372 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16373 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16374 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16375 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16376 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16377 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16378 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16379}
16380
16381/* unsolicited event for HP jack sensing */
16382static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16383 unsigned int res)
16384{
Kailang Yang291702f2007-10-16 14:28:03 +020016385 if ((res >> 26) == ALC880_MIC_EVENT)
16386 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016387 else
16388 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016389}
16390
16391static void alc662_eeepc_inithook(struct hda_codec *codec)
16392{
Takashi Iwai42171c12009-05-08 14:11:43 +020016393 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016394 alc662_eeepc_mic_automute(codec);
16395}
16396
Kailang Yang8c427222008-01-10 13:03:59 +010016397static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16398{
Takashi Iwai42171c12009-05-08 14:11:43 +020016399 struct alc_spec *spec = codec->spec;
16400
16401 spec->autocfg.hp_pins[0] = 0x14;
16402 spec->autocfg.speaker_pins[0] = 0x1b;
16403 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016404}
16405
Kailang Yang6dda9f42008-05-27 12:05:31 +020016406static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16407{
16408 unsigned int present;
16409 unsigned char bits;
16410
16411 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016412 AC_VERB_GET_PIN_SENSE, 0)
16413 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016414 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016415 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16416 AMP_IN_MUTE(0), bits);
16417 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16418 AMP_IN_MUTE(0), bits);
16419}
16420
16421static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16422{
16423 unsigned int present;
16424 unsigned char bits;
16425
16426 present = snd_hda_codec_read(codec, 0x21, 0,
16427 AC_VERB_GET_PIN_SENSE, 0)
16428 & AC_PINSENSE_PRESENCE;
16429 bits = present ? HDA_AMP_MUTE : 0;
16430 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16431 AMP_IN_MUTE(0), bits);
16432 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16433 AMP_IN_MUTE(0), bits);
16434 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16435 AMP_IN_MUTE(0), bits);
16436 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16437 AMP_IN_MUTE(0), bits);
16438}
16439
16440static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16441{
16442 unsigned int present;
16443 unsigned char bits;
16444
16445 present = snd_hda_codec_read(codec, 0x15, 0,
16446 AC_VERB_GET_PIN_SENSE, 0)
16447 & AC_PINSENSE_PRESENCE;
16448 bits = present ? HDA_AMP_MUTE : 0;
16449 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16450 AMP_IN_MUTE(0), bits);
16451 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16452 AMP_IN_MUTE(0), bits);
16453 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16454 AMP_IN_MUTE(0), bits);
16455 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16456 AMP_IN_MUTE(0), bits);
16457}
16458
16459static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16460{
16461 unsigned int present;
16462 unsigned char bits;
16463
16464 present = snd_hda_codec_read(codec, 0x1b, 0,
16465 AC_VERB_GET_PIN_SENSE, 0)
16466 & AC_PINSENSE_PRESENCE;
16467 bits = present ? 0 : PIN_OUT;
16468 snd_hda_codec_write(codec, 0x14, 0,
16469 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16470}
16471
16472static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16473{
16474 unsigned int present1, present2;
16475
16476 present1 = snd_hda_codec_read(codec, 0x21, 0,
16477 AC_VERB_GET_PIN_SENSE, 0)
16478 & AC_PINSENSE_PRESENCE;
16479 present2 = snd_hda_codec_read(codec, 0x15, 0,
16480 AC_VERB_GET_PIN_SENSE, 0)
16481 & AC_PINSENSE_PRESENCE;
16482
16483 if (present1 || present2) {
16484 snd_hda_codec_write_cache(codec, 0x14, 0,
16485 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16486 } else {
16487 snd_hda_codec_write_cache(codec, 0x14, 0,
16488 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16489 }
16490}
16491
16492static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16493{
16494 unsigned int present1, present2;
16495
16496 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16497 AC_VERB_GET_PIN_SENSE, 0)
16498 & AC_PINSENSE_PRESENCE;
16499 present2 = snd_hda_codec_read(codec, 0x15, 0,
16500 AC_VERB_GET_PIN_SENSE, 0)
16501 & AC_PINSENSE_PRESENCE;
16502
16503 if (present1 || present2) {
16504 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16505 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16506 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16507 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16508 } else {
16509 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16510 AMP_IN_MUTE(0), 0);
16511 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16512 AMP_IN_MUTE(0), 0);
16513 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016514}
16515
16516static void alc663_m51va_mic_automute(struct hda_codec *codec)
16517{
16518 unsigned int present;
16519
16520 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016521 AC_VERB_GET_PIN_SENSE, 0)
16522 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016523 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016524 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016525 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016526 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016527 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016528 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016529 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016530 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016531}
16532
16533static void alc663_m51va_unsol_event(struct hda_codec *codec,
16534 unsigned int res)
16535{
16536 switch (res >> 26) {
16537 case ALC880_HP_EVENT:
16538 alc663_m51va_speaker_automute(codec);
16539 break;
16540 case ALC880_MIC_EVENT:
16541 alc663_m51va_mic_automute(codec);
16542 break;
16543 }
16544}
16545
16546static void alc663_m51va_inithook(struct hda_codec *codec)
16547{
16548 alc663_m51va_speaker_automute(codec);
16549 alc663_m51va_mic_automute(codec);
16550}
16551
Kailang Yangf1d4e282008-08-26 14:03:29 +020016552/* ***************** Mode1 ******************************/
16553static void alc663_mode1_unsol_event(struct hda_codec *codec,
16554 unsigned int res)
16555{
16556 switch (res >> 26) {
16557 case ALC880_HP_EVENT:
16558 alc663_m51va_speaker_automute(codec);
16559 break;
16560 case ALC880_MIC_EVENT:
16561 alc662_eeepc_mic_automute(codec);
16562 break;
16563 }
16564}
16565
16566static void alc663_mode1_inithook(struct hda_codec *codec)
16567{
16568 alc663_m51va_speaker_automute(codec);
16569 alc662_eeepc_mic_automute(codec);
16570}
16571/* ***************** Mode2 ******************************/
16572static void alc662_mode2_unsol_event(struct hda_codec *codec,
16573 unsigned int res)
16574{
16575 switch (res >> 26) {
16576 case ALC880_HP_EVENT:
16577 alc662_f5z_speaker_automute(codec);
16578 break;
16579 case ALC880_MIC_EVENT:
16580 alc662_eeepc_mic_automute(codec);
16581 break;
16582 }
16583}
16584
16585static void alc662_mode2_inithook(struct hda_codec *codec)
16586{
16587 alc662_f5z_speaker_automute(codec);
16588 alc662_eeepc_mic_automute(codec);
16589}
16590/* ***************** Mode3 ******************************/
16591static void alc663_mode3_unsol_event(struct hda_codec *codec,
16592 unsigned int res)
16593{
16594 switch (res >> 26) {
16595 case ALC880_HP_EVENT:
16596 alc663_two_hp_m1_speaker_automute(codec);
16597 break;
16598 case ALC880_MIC_EVENT:
16599 alc662_eeepc_mic_automute(codec);
16600 break;
16601 }
16602}
16603
16604static void alc663_mode3_inithook(struct hda_codec *codec)
16605{
16606 alc663_two_hp_m1_speaker_automute(codec);
16607 alc662_eeepc_mic_automute(codec);
16608}
16609/* ***************** Mode4 ******************************/
16610static void alc663_mode4_unsol_event(struct hda_codec *codec,
16611 unsigned int res)
16612{
16613 switch (res >> 26) {
16614 case ALC880_HP_EVENT:
16615 alc663_21jd_two_speaker_automute(codec);
16616 break;
16617 case ALC880_MIC_EVENT:
16618 alc662_eeepc_mic_automute(codec);
16619 break;
16620 }
16621}
16622
16623static void alc663_mode4_inithook(struct hda_codec *codec)
16624{
16625 alc663_21jd_two_speaker_automute(codec);
16626 alc662_eeepc_mic_automute(codec);
16627}
16628/* ***************** Mode5 ******************************/
16629static void alc663_mode5_unsol_event(struct hda_codec *codec,
16630 unsigned int res)
16631{
16632 switch (res >> 26) {
16633 case ALC880_HP_EVENT:
16634 alc663_15jd_two_speaker_automute(codec);
16635 break;
16636 case ALC880_MIC_EVENT:
16637 alc662_eeepc_mic_automute(codec);
16638 break;
16639 }
16640}
16641
16642static void alc663_mode5_inithook(struct hda_codec *codec)
16643{
16644 alc663_15jd_two_speaker_automute(codec);
16645 alc662_eeepc_mic_automute(codec);
16646}
16647/* ***************** Mode6 ******************************/
16648static void alc663_mode6_unsol_event(struct hda_codec *codec,
16649 unsigned int res)
16650{
16651 switch (res >> 26) {
16652 case ALC880_HP_EVENT:
16653 alc663_two_hp_m2_speaker_automute(codec);
16654 break;
16655 case ALC880_MIC_EVENT:
16656 alc662_eeepc_mic_automute(codec);
16657 break;
16658 }
16659}
16660
16661static void alc663_mode6_inithook(struct hda_codec *codec)
16662{
16663 alc663_two_hp_m2_speaker_automute(codec);
16664 alc662_eeepc_mic_automute(codec);
16665}
16666
Kailang Yang6dda9f42008-05-27 12:05:31 +020016667static void alc663_g71v_hp_automute(struct hda_codec *codec)
16668{
16669 unsigned int present;
16670 unsigned char bits;
16671
16672 present = snd_hda_codec_read(codec, 0x21, 0,
16673 AC_VERB_GET_PIN_SENSE, 0)
16674 & AC_PINSENSE_PRESENCE;
16675 bits = present ? HDA_AMP_MUTE : 0;
16676 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16677 HDA_AMP_MUTE, bits);
16678 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16679 HDA_AMP_MUTE, bits);
16680}
16681
16682static void alc663_g71v_front_automute(struct hda_codec *codec)
16683{
16684 unsigned int present;
16685 unsigned char bits;
16686
16687 present = snd_hda_codec_read(codec, 0x15, 0,
16688 AC_VERB_GET_PIN_SENSE, 0)
16689 & AC_PINSENSE_PRESENCE;
16690 bits = present ? HDA_AMP_MUTE : 0;
16691 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16692 HDA_AMP_MUTE, bits);
16693}
16694
16695static void alc663_g71v_unsol_event(struct hda_codec *codec,
16696 unsigned int res)
16697{
16698 switch (res >> 26) {
16699 case ALC880_HP_EVENT:
16700 alc663_g71v_hp_automute(codec);
16701 break;
16702 case ALC880_FRONT_EVENT:
16703 alc663_g71v_front_automute(codec);
16704 break;
16705 case ALC880_MIC_EVENT:
16706 alc662_eeepc_mic_automute(codec);
16707 break;
16708 }
16709}
16710
16711static void alc663_g71v_inithook(struct hda_codec *codec)
16712{
16713 alc663_g71v_front_automute(codec);
16714 alc663_g71v_hp_automute(codec);
16715 alc662_eeepc_mic_automute(codec);
16716}
16717
16718static void alc663_g50v_unsol_event(struct hda_codec *codec,
16719 unsigned int res)
16720{
16721 switch (res >> 26) {
16722 case ALC880_HP_EVENT:
16723 alc663_m51va_speaker_automute(codec);
16724 break;
16725 case ALC880_MIC_EVENT:
16726 alc662_eeepc_mic_automute(codec);
16727 break;
16728 }
16729}
16730
16731static void alc663_g50v_inithook(struct hda_codec *codec)
16732{
16733 alc663_m51va_speaker_automute(codec);
16734 alc662_eeepc_mic_automute(codec);
16735}
16736
Kailang Yangf1d4e282008-08-26 14:03:29 +020016737static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16738 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016739 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016740
16741 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16742 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16743 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16744
16745 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16746 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16747 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16748 { } /* end */
16749};
16750
Chris Pockelé9541ba12009-05-12 08:08:53 +020016751static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16752 /* Master Playback automatically created from Speaker and Headphone */
16753 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16754 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16755 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16756 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16757
16758 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16759 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16760 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16761
16762 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16763 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16764 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16765 { } /* end */
16766};
16767
Takashi Iwaicb53c622007-08-10 17:21:45 +020016768#ifdef CONFIG_SND_HDA_POWER_SAVE
16769#define alc662_loopbacks alc880_loopbacks
16770#endif
16771
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016772
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016773/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016774#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16775#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16776#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16777#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16778
16779/*
16780 * configuration and preset
16781 */
16782static const char *alc662_models[ALC662_MODEL_LAST] = {
16783 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16784 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16785 [ALC662_3ST_6ch] = "3stack-6ch",
16786 [ALC662_5ST_DIG] = "6stack-dig",
16787 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016788 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016789 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016790 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016791 [ALC663_ASUS_M51VA] = "m51va",
16792 [ALC663_ASUS_G71V] = "g71v",
16793 [ALC663_ASUS_H13] = "h13",
16794 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016795 [ALC663_ASUS_MODE1] = "asus-mode1",
16796 [ALC662_ASUS_MODE2] = "asus-mode2",
16797 [ALC663_ASUS_MODE3] = "asus-mode3",
16798 [ALC663_ASUS_MODE4] = "asus-mode4",
16799 [ALC663_ASUS_MODE5] = "asus-mode5",
16800 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016801 [ALC272_DELL] = "dell",
16802 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016803 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016804 [ALC662_AUTO] = "auto",
16805};
16806
16807static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016808 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016809 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16810 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016811 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16812 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16813 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16814 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16815 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16816 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16817 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16818 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16819 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16820 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16821 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16822 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016823 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16824 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16825 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016826 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16827 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16828 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16829 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016830 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016831 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16832 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016833 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016834 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16835 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16836 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016837 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16838 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16839 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016840 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16841 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16842 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016843 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016844 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16845 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016846 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016847 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016848 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016849 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16850 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16851 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016852 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016853 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16854 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016855 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016856 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016857 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016858 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016859 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16860 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016861 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016862 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16863 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016864 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016865 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016866 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016867 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016868 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016869 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16870 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016871 {}
16872};
16873
16874static struct alc_config_preset alc662_presets[] = {
16875 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016876 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016877 .init_verbs = { alc662_init_verbs },
16878 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16879 .dac_nids = alc662_dac_nids,
16880 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016881 .dig_in_nid = ALC662_DIGIN_NID,
16882 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16883 .channel_mode = alc662_3ST_2ch_modes,
16884 .input_mux = &alc662_capture_source,
16885 },
16886 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016887 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016888 .init_verbs = { alc662_init_verbs },
16889 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16890 .dac_nids = alc662_dac_nids,
16891 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016892 .dig_in_nid = ALC662_DIGIN_NID,
16893 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16894 .channel_mode = alc662_3ST_6ch_modes,
16895 .need_dac_fix = 1,
16896 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016897 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016898 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016899 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016900 .init_verbs = { alc662_init_verbs },
16901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16902 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016903 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16904 .channel_mode = alc662_3ST_6ch_modes,
16905 .need_dac_fix = 1,
16906 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016907 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016908 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016909 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016910 .init_verbs = { alc662_init_verbs },
16911 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16912 .dac_nids = alc662_dac_nids,
16913 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016914 .dig_in_nid = ALC662_DIGIN_NID,
16915 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16916 .channel_mode = alc662_5stack_modes,
16917 .input_mux = &alc662_capture_source,
16918 },
16919 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016920 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016921 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16922 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16923 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016924 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16925 .channel_mode = alc662_3ST_2ch_modes,
16926 .input_mux = &alc662_lenovo_101e_capture_source,
16927 .unsol_event = alc662_lenovo_101e_unsol_event,
16928 .init_hook = alc662_lenovo_101e_all_automute,
16929 },
Kailang Yang291702f2007-10-16 14:28:03 +020016930 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016931 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016932 .init_verbs = { alc662_init_verbs,
16933 alc662_eeepc_sue_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16935 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016936 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16937 .channel_mode = alc662_3ST_2ch_modes,
16938 .input_mux = &alc662_eeepc_capture_source,
16939 .unsol_event = alc662_eeepc_unsol_event,
16940 .init_hook = alc662_eeepc_inithook,
16941 },
Kailang Yang8c427222008-01-10 13:03:59 +010016942 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016943 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016944 alc662_chmode_mixer },
16945 .init_verbs = { alc662_init_verbs,
16946 alc662_eeepc_ep20_sue_init_verbs },
16947 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16948 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016949 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16950 .channel_mode = alc662_3ST_6ch_modes,
16951 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016952 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016953 .init_hook = alc662_eeepc_ep20_inithook,
16954 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016955 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016956 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016957 .init_verbs = { alc662_init_verbs,
16958 alc662_ecs_init_verbs },
16959 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16960 .dac_nids = alc662_dac_nids,
16961 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16962 .channel_mode = alc662_3ST_2ch_modes,
16963 .input_mux = &alc662_eeepc_capture_source,
16964 .unsol_event = alc662_eeepc_unsol_event,
16965 .init_hook = alc662_eeepc_inithook,
16966 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016967 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016968 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016969 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16970 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16971 .dac_nids = alc662_dac_nids,
16972 .dig_out_nid = ALC662_DIGOUT_NID,
16973 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16974 .channel_mode = alc662_3ST_2ch_modes,
16975 .input_mux = &alc663_m51va_capture_source,
16976 .unsol_event = alc663_m51va_unsol_event,
16977 .init_hook = alc663_m51va_inithook,
16978 },
16979 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016980 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016981 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16982 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16983 .dac_nids = alc662_dac_nids,
16984 .dig_out_nid = ALC662_DIGOUT_NID,
16985 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16986 .channel_mode = alc662_3ST_2ch_modes,
16987 .input_mux = &alc662_eeepc_capture_source,
16988 .unsol_event = alc663_g71v_unsol_event,
16989 .init_hook = alc663_g71v_inithook,
16990 },
16991 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016992 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016993 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16994 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16995 .dac_nids = alc662_dac_nids,
16996 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16997 .channel_mode = alc662_3ST_2ch_modes,
16998 .input_mux = &alc663_m51va_capture_source,
16999 .unsol_event = alc663_m51va_unsol_event,
17000 .init_hook = alc663_m51va_inithook,
17001 },
17002 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017003 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017004 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17005 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17006 .dac_nids = alc662_dac_nids,
17007 .dig_out_nid = ALC662_DIGOUT_NID,
17008 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17009 .channel_mode = alc662_3ST_6ch_modes,
17010 .input_mux = &alc663_capture_source,
17011 .unsol_event = alc663_g50v_unsol_event,
17012 .init_hook = alc663_g50v_inithook,
17013 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017014 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017015 .mixers = { alc663_m51va_mixer },
17016 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017017 .init_verbs = { alc662_init_verbs,
17018 alc663_21jd_amic_init_verbs },
17019 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17020 .hp_nid = 0x03,
17021 .dac_nids = alc662_dac_nids,
17022 .dig_out_nid = ALC662_DIGOUT_NID,
17023 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17024 .channel_mode = alc662_3ST_2ch_modes,
17025 .input_mux = &alc662_eeepc_capture_source,
17026 .unsol_event = alc663_mode1_unsol_event,
17027 .init_hook = alc663_mode1_inithook,
17028 },
17029 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017030 .mixers = { alc662_1bjd_mixer },
17031 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017032 .init_verbs = { alc662_init_verbs,
17033 alc662_1bjd_amic_init_verbs },
17034 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17035 .dac_nids = alc662_dac_nids,
17036 .dig_out_nid = ALC662_DIGOUT_NID,
17037 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17038 .channel_mode = alc662_3ST_2ch_modes,
17039 .input_mux = &alc662_eeepc_capture_source,
17040 .unsol_event = alc662_mode2_unsol_event,
17041 .init_hook = alc662_mode2_inithook,
17042 },
17043 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017044 .mixers = { alc663_two_hp_m1_mixer },
17045 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017046 .init_verbs = { alc662_init_verbs,
17047 alc663_two_hp_amic_m1_init_verbs },
17048 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17049 .hp_nid = 0x03,
17050 .dac_nids = alc662_dac_nids,
17051 .dig_out_nid = ALC662_DIGOUT_NID,
17052 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17053 .channel_mode = alc662_3ST_2ch_modes,
17054 .input_mux = &alc662_eeepc_capture_source,
17055 .unsol_event = alc663_mode3_unsol_event,
17056 .init_hook = alc663_mode3_inithook,
17057 },
17058 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017059 .mixers = { alc663_asus_21jd_clfe_mixer },
17060 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017061 .init_verbs = { alc662_init_verbs,
17062 alc663_21jd_amic_init_verbs},
17063 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17064 .hp_nid = 0x03,
17065 .dac_nids = alc662_dac_nids,
17066 .dig_out_nid = ALC662_DIGOUT_NID,
17067 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17068 .channel_mode = alc662_3ST_2ch_modes,
17069 .input_mux = &alc662_eeepc_capture_source,
17070 .unsol_event = alc663_mode4_unsol_event,
17071 .init_hook = alc663_mode4_inithook,
17072 },
17073 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017074 .mixers = { alc663_asus_15jd_clfe_mixer },
17075 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017076 .init_verbs = { alc662_init_verbs,
17077 alc663_15jd_amic_init_verbs },
17078 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17079 .hp_nid = 0x03,
17080 .dac_nids = alc662_dac_nids,
17081 .dig_out_nid = ALC662_DIGOUT_NID,
17082 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17083 .channel_mode = alc662_3ST_2ch_modes,
17084 .input_mux = &alc662_eeepc_capture_source,
17085 .unsol_event = alc663_mode5_unsol_event,
17086 .init_hook = alc663_mode5_inithook,
17087 },
17088 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017089 .mixers = { alc663_two_hp_m2_mixer },
17090 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017091 .init_verbs = { alc662_init_verbs,
17092 alc663_two_hp_amic_m2_init_verbs },
17093 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17094 .hp_nid = 0x03,
17095 .dac_nids = alc662_dac_nids,
17096 .dig_out_nid = ALC662_DIGOUT_NID,
17097 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17098 .channel_mode = alc662_3ST_2ch_modes,
17099 .input_mux = &alc662_eeepc_capture_source,
17100 .unsol_event = alc663_mode6_unsol_event,
17101 .init_hook = alc663_mode6_inithook,
17102 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017103 [ALC272_DELL] = {
17104 .mixers = { alc663_m51va_mixer },
17105 .cap_mixer = alc272_auto_capture_mixer,
17106 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17107 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17108 .dac_nids = alc662_dac_nids,
17109 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17110 .adc_nids = alc272_adc_nids,
17111 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17112 .capsrc_nids = alc272_capsrc_nids,
17113 .channel_mode = alc662_3ST_2ch_modes,
17114 .input_mux = &alc663_m51va_capture_source,
17115 .unsol_event = alc663_m51va_unsol_event,
17116 .init_hook = alc663_m51va_inithook,
17117 },
17118 [ALC272_DELL_ZM1] = {
17119 .mixers = { alc663_m51va_mixer },
17120 .cap_mixer = alc662_auto_capture_mixer,
17121 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17122 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17123 .dac_nids = alc662_dac_nids,
17124 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17125 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017126 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017127 .capsrc_nids = alc662_capsrc_nids,
17128 .channel_mode = alc662_3ST_2ch_modes,
17129 .input_mux = &alc663_m51va_capture_source,
17130 .unsol_event = alc663_m51va_unsol_event,
17131 .init_hook = alc663_m51va_inithook,
17132 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017133 [ALC272_SAMSUNG_NC10] = {
17134 .mixers = { alc272_nc10_mixer },
17135 .init_verbs = { alc662_init_verbs,
17136 alc663_21jd_amic_init_verbs },
17137 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17138 .dac_nids = alc272_dac_nids,
17139 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17140 .channel_mode = alc662_3ST_2ch_modes,
17141 .input_mux = &alc272_nc10_capture_source,
17142 .unsol_event = alc663_mode4_unsol_event,
17143 .init_hook = alc663_mode4_inithook,
17144 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017145};
17146
17147
17148/*
17149 * BIOS auto configuration
17150 */
17151
17152/* add playback controls from the parsed DAC table */
17153static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17154 const struct auto_pin_cfg *cfg)
17155{
17156 char name[32];
17157 static const char *chname[4] = {
17158 "Front", "Surround", NULL /*CLFE*/, "Side"
17159 };
17160 hda_nid_t nid;
17161 int i, err;
17162
17163 for (i = 0; i < cfg->line_outs; i++) {
17164 if (!spec->multiout.dac_nids[i])
17165 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017166 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017167 if (i == 2) {
17168 /* Center/LFE */
17169 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17170 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017171 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17172 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173 if (err < 0)
17174 return err;
17175 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17176 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017177 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17178 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017179 if (err < 0)
17180 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017181 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017182 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017183 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017184 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017185 if (err < 0)
17186 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017187 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017188 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017189 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017190 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017191 if (err < 0)
17192 return err;
17193 } else {
17194 sprintf(name, "%s Playback Volume", chname[i]);
17195 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017196 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17197 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017198 if (err < 0)
17199 return err;
17200 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017201 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17202 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17203 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017204 if (err < 0)
17205 return err;
17206 }
17207 }
17208 return 0;
17209}
17210
17211/* add playback controls for speaker and HP outputs */
17212static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17213 const char *pfx)
17214{
17215 hda_nid_t nid;
17216 int err;
17217 char name[32];
17218
17219 if (!pin)
17220 return 0;
17221
Takashi Iwai24fb9172008-09-02 14:48:20 +020017222 if (pin == 0x17) {
17223 /* ALC663 has a mono output pin on 0x17 */
17224 sprintf(name, "%s Playback Switch", pfx);
17225 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17226 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17227 return err;
17228 }
17229
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017230 if (alc880_is_fixed_pin(pin)) {
17231 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017232 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017233 /* specify the DAC as the extra output */
17234 if (!spec->multiout.hp_nid)
17235 spec->multiout.hp_nid = nid;
17236 else
17237 spec->multiout.extra_out_nid[0] = nid;
17238 /* control HP volume/switch on the output mixer amp */
17239 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17240 sprintf(name, "%s Playback Volume", pfx);
17241 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17242 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17243 if (err < 0)
17244 return err;
17245 sprintf(name, "%s Playback Switch", pfx);
17246 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17247 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17248 if (err < 0)
17249 return err;
17250 } else if (alc880_is_multi_pin(pin)) {
17251 /* set manual connection */
17252 /* we have only a switch on HP-out PIN */
17253 sprintf(name, "%s Playback Switch", pfx);
17254 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17255 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17256 if (err < 0)
17257 return err;
17258 }
17259 return 0;
17260}
17261
Takashi Iwai2d864c42009-03-20 12:52:47 +010017262static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17263{
Takashi Iwai1327a322009-03-23 13:07:47 +010017264 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017265 return (pincap & AC_PINCAP_IN) != 0;
17266}
17267
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017268/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017269static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017270 const struct auto_pin_cfg *cfg)
17271{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017272 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017273 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017274 int i, err, idx;
17275
17276 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017277 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
Takashi Iwai6c819492009-08-10 18:47:44 +020017278 idx = get_connection_index(codec, 0x0b,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017279 cfg->input_pins[i]);
17280 if (idx >= 0) {
17281 err = new_analog_input(spec, cfg->input_pins[i],
17282 auto_pin_cfg_labels[i],
17283 idx, 0x0b);
17284 if (err < 0)
17285 return err;
17286 }
Takashi Iwai6c819492009-08-10 18:47:44 +020017287 idx = get_connection_index(codec, 0x22,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017288 cfg->input_pins[i]);
17289 if (idx >= 0) {
17290 imux->items[imux->num_items].label =
17291 auto_pin_cfg_labels[i];
17292 imux->items[imux->num_items].index = idx;
17293 imux->num_items++;
17294 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017295 }
17296 }
17297 return 0;
17298}
17299
17300static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17301 hda_nid_t nid, int pin_type,
17302 int dac_idx)
17303{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017304 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017305 /* need the manual connection? */
17306 if (alc880_is_multi_pin(nid)) {
17307 struct alc_spec *spec = codec->spec;
17308 int idx = alc880_multi_pin_idx(nid);
17309 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17310 AC_VERB_SET_CONNECT_SEL,
17311 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17312 }
17313}
17314
17315static void alc662_auto_init_multi_out(struct hda_codec *codec)
17316{
17317 struct alc_spec *spec = codec->spec;
17318 int i;
17319
17320 for (i = 0; i <= HDA_SIDE; i++) {
17321 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017322 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017323 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017324 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017325 i);
17326 }
17327}
17328
17329static void alc662_auto_init_hp_out(struct hda_codec *codec)
17330{
17331 struct alc_spec *spec = codec->spec;
17332 hda_nid_t pin;
17333
17334 pin = spec->autocfg.hp_pins[0];
17335 if (pin) /* connect to front */
17336 /* use dac 0 */
17337 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017338 pin = spec->autocfg.speaker_pins[0];
17339 if (pin)
17340 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017341}
17342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017343#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17344
17345static void alc662_auto_init_analog_input(struct hda_codec *codec)
17346{
17347 struct alc_spec *spec = codec->spec;
17348 int i;
17349
17350 for (i = 0; i < AUTO_PIN_LAST; i++) {
17351 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017352 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017353 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017354 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017355 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017356 snd_hda_codec_write(codec, nid, 0,
17357 AC_VERB_SET_AMP_GAIN_MUTE,
17358 AMP_OUT_MUTE);
17359 }
17360 }
17361}
17362
Takashi Iwaif511b012008-08-15 16:46:42 +020017363#define alc662_auto_init_input_src alc882_auto_init_input_src
17364
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017365static int alc662_parse_auto_config(struct hda_codec *codec)
17366{
17367 struct alc_spec *spec = codec->spec;
17368 int err;
17369 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17370
17371 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17372 alc662_ignore);
17373 if (err < 0)
17374 return err;
17375 if (!spec->autocfg.line_outs)
17376 return 0; /* can't find valid BIOS pin config */
17377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017378 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17379 if (err < 0)
17380 return err;
17381 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17382 if (err < 0)
17383 return err;
17384 err = alc662_auto_create_extra_out(spec,
17385 spec->autocfg.speaker_pins[0],
17386 "Speaker");
17387 if (err < 0)
17388 return err;
17389 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17390 "Headphone");
17391 if (err < 0)
17392 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017393 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017394 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017395 return err;
17396
17397 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17398
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017399 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017400 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17401
Takashi Iwai603c4012008-07-30 15:01:44 +020017402 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017403 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017404
17405 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017406 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017407
Takashi Iwaid88897e2008-10-31 15:01:37 +010017408 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017409 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017410 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017411
17412 err = alc_auto_add_mic_boost(codec);
17413 if (err < 0)
17414 return err;
17415
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017416 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17417
Takashi Iwai8c872862007-06-19 12:11:16 +020017418 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017419}
17420
17421/* additional initialization for auto-configuration model */
17422static void alc662_auto_init(struct hda_codec *codec)
17423{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017424 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017425 alc662_auto_init_multi_out(codec);
17426 alc662_auto_init_hp_out(codec);
17427 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017428 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017429 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017430 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017431}
17432
17433static int patch_alc662(struct hda_codec *codec)
17434{
17435 struct alc_spec *spec;
17436 int err, board_config;
17437
17438 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17439 if (!spec)
17440 return -ENOMEM;
17441
17442 codec->spec = spec;
17443
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017444 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17445
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17447 alc662_models,
17448 alc662_cfg_tbl);
17449 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017450 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17451 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017452 board_config = ALC662_AUTO;
17453 }
17454
17455 if (board_config == ALC662_AUTO) {
17456 /* automatic parse from the BIOS config */
17457 err = alc662_parse_auto_config(codec);
17458 if (err < 0) {
17459 alc_free(codec);
17460 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020017461 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017462 printk(KERN_INFO
17463 "hda_codec: Cannot set up configuration "
17464 "from BIOS. Using base mode...\n");
17465 board_config = ALC662_3ST_2ch_DIG;
17466 }
17467 }
17468
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017469 err = snd_hda_attach_beep_device(codec, 0x1);
17470 if (err < 0) {
17471 alc_free(codec);
17472 return err;
17473 }
17474
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017475 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017476 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017477
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017478 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17479 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17480
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017481 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17482 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17483
Takashi Iwaidd704692009-08-11 08:45:11 +020017484 if (!spec->adc_nids) {
17485 spec->adc_nids = alc662_adc_nids;
17486 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17487 }
17488 if (!spec->capsrc_nids)
17489 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017490
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017491 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017492 set_capture_mixer(codec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017493 if (codec->vendor_id == 0x10ec0662)
17494 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17495 else
17496 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017497
Takashi Iwai2134ea42008-01-10 16:53:55 +010017498 spec->vmaster_nid = 0x02;
17499
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017500 codec->patch_ops = alc_patch_ops;
17501 if (board_config == ALC662_AUTO)
17502 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017503#ifdef CONFIG_SND_HDA_POWER_SAVE
17504 if (!spec->loopback.amplist)
17505 spec->loopback.amplist = alc662_loopbacks;
17506#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017507 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017508
17509 return 0;
17510}
17511
17512/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017513 * patch entries
17514 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017515static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017516 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017517 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017518 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017519 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017520 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017521 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017522 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017523 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017524 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17525 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17526 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017527 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017528 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017529 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17530 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017531 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017532 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017533 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017534 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017535 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017536 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017537 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017538 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017539 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017540 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017541 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017542 .patch = patch_alc882 },
17543 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17544 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017545 {} /* terminator */
17546};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017547
17548MODULE_ALIAS("snd-hda-codec-id:10ec*");
17549
17550MODULE_LICENSE("GPL");
17551MODULE_DESCRIPTION("Realtek HD-audio codec");
17552
17553static struct hda_codec_preset_list realtek_list = {
17554 .preset = snd_hda_preset_realtek,
17555 .owner = THIS_MODULE,
17556};
17557
17558static int __init patch_realtek_init(void)
17559{
17560 return snd_hda_add_codec_preset(&realtek_list);
17561}
17562
17563static void __exit patch_realtek_exit(void)
17564{
17565 snd_hda_delete_codec_preset(&realtek_list);
17566}
17567
17568module_init(patch_realtek_init)
17569module_exit(patch_realtek_exit)