blob: 678c2d7b7f989388f3d817c08525a0d738d7e19c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200134 ALC269_ASUS_EEEPC_P703,
135 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100136 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000137 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100138 ALC269_AUTO,
139 ALC269_MODEL_LAST /* last tag */
140};
141
Kailang Yangdf694da2005-12-05 19:42:22 +0100142/* ALC861 models */
143enum {
144 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200145 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_3ST_DIG,
147 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200148 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200149 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200150 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100151 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100152 ALC861_AUTO,
153 ALC861_MODEL_LAST,
154};
155
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100156/* ALC861-VD models */
157enum {
158 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200159 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100160 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100161 ALC861VD_3ST,
162 ALC861VD_3ST_DIG,
163 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200164 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200165 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200166 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100167 ALC861VD_AUTO,
168 ALC861VD_MODEL_LAST,
169};
170
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200171/* ALC662 models */
172enum {
173 ALC662_3ST_2ch_DIG,
174 ALC662_3ST_6ch_DIG,
175 ALC662_3ST_6ch,
176 ALC662_5ST_DIG,
177 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200178 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100179 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200180 ALC663_ASUS_M51VA,
181 ALC663_ASUS_G71V,
182 ALC663_ASUS_H13,
183 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200184 ALC662_ECS,
185 ALC663_ASUS_MODE1,
186 ALC662_ASUS_MODE2,
187 ALC663_ASUS_MODE3,
188 ALC663_ASUS_MODE4,
189 ALC663_ASUS_MODE5,
190 ALC663_ASUS_MODE6,
Kailang Yang622e84c2009-04-21 07:39:04 +0200191 ALC272_DELL,
192 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200193 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200194 ALC662_AUTO,
195 ALC662_MODEL_LAST,
196};
197
Kailang Yangdf694da2005-12-05 19:42:22 +0100198/* ALC882 models */
199enum {
200 ALC882_3ST_DIG,
201 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200202 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200203 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200204 ALC882_TARGA,
205 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200206 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100207 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200208 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200209 ALC885_MB5,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200210 ALC885_IMAC24,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200217 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100221 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200222 ALC888_ACER_ASPIRE_8930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200223 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200224 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100225 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200226 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200227 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200228 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200229 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200230 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200231 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100232 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100233 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100234 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100235 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800236 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200237 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200238 ALC889A_INTEL,
239 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_ASUS_M90V,
241 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200242 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100243 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200244 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200245 ALC882_AUTO,
246 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200247};
248
Kailang Yangdf694da2005-12-05 19:42:22 +0100249/* for GPIO Poll */
250#define GPIO_MASK 0x03
251
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200252/* extra amp-initialization sequence types */
253enum {
254 ALC_INIT_NONE,
255 ALC_INIT_DEFAULT,
256 ALC_INIT_GPIO1,
257 ALC_INIT_GPIO2,
258 ALC_INIT_GPIO3,
259};
260
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);
382 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200383#ifdef CONFIG_SND_HDA_POWER_SAVE
384 struct hda_amp_list *loopbacks;
385#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386};
387
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388
389/*
390 * input MUX handling
391 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200392static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200397 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
398 if (mux_idx >= spec->num_mux_defs)
399 mux_idx = 0;
400 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401}
402
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200403static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
404 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405{
406 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
407 struct alc_spec *spec = codec->spec;
408 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
409
410 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
411 return 0;
412}
413
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200414static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
415 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416{
417 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
418 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100419 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100421 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100422 hda_nid_t nid = spec->capsrc_nids ?
423 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200424 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425
Takashi Iwaicd896c32008-11-18 12:36:33 +0100426 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
427 imux = &spec->input_mux[mux_idx];
428
Takashi Iwaia22d5432009-07-27 12:54:26 +0200429 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200430 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100431 /* Matrix-mixer style (e.g. ALC882) */
432 unsigned int *cur_val = &spec->cur_mux[adc_idx];
433 unsigned int i, idx;
434
435 idx = ucontrol->value.enumerated.item[0];
436 if (idx >= imux->num_items)
437 idx = imux->num_items - 1;
438 if (*cur_val == idx)
439 return 0;
440 for (i = 0; i < imux->num_items; i++) {
441 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
442 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
443 imux->items[i].index,
444 HDA_AMP_MUTE, v);
445 }
446 *cur_val = idx;
447 return 1;
448 } else {
449 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100450 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100451 &spec->cur_mux[adc_idx]);
452 }
453}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455/*
456 * channel mode setting
457 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100463 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
464 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465}
466
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200467static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
468 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469{
470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
471 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100472 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200473 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200474 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475}
476
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200477static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
481 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200482 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
483 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200484 &spec->ext_channel_count);
485 if (err >= 0 && !spec->const_channel_count) {
486 spec->multiout.max_channels = spec->ext_channel_count;
487 if (spec->need_dac_fix)
488 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
489 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200490 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491}
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100494 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200495 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100496 * being part of a format specifier. Maximum allowed length of a value is
497 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100498 *
499 * Note: some retasking pin complexes seem to ignore requests for input
500 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
501 * are requested. Therefore order this list so that this behaviour will not
502 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200503 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
504 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200505 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100507 "Mic 50pc bias", "Mic 80pc bias",
508 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100509};
510static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100511 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512};
513/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200514 * in the pin being assumed to be exclusively an input or an output pin. In
515 * addition, "input" pins may or may not process the mic bias option
516 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
517 * accept requests for bias as of chip versions up to March 2006) and/or
518 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100519 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200520#define ALC_PIN_DIR_IN 0x00
521#define ALC_PIN_DIR_OUT 0x01
522#define ALC_PIN_DIR_INOUT 0x02
523#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
524#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525
Kailang Yangea1fb292008-08-26 12:58:38 +0200526/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527 * For each direction the minimum and maximum values are given.
528 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200529static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530 { 0, 2 }, /* ALC_PIN_DIR_IN */
531 { 3, 4 }, /* ALC_PIN_DIR_OUT */
532 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200533 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
534 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535};
536#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
537#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
538#define alc_pin_mode_n_items(_dir) \
539 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
540
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200541static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
542 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200543{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100544 unsigned int item_num = uinfo->value.enumerated.item;
545 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
546
547 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200548 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100549 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
550
551 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
552 item_num = alc_pin_mode_min(dir);
553 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200554 return 0;
555}
556
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
558 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200559{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100560 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
562 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200564 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200565 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
566 AC_VERB_GET_PIN_WIDGET_CONTROL,
567 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200568
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569 /* Find enumerated value for current pinctl setting */
570 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200571 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200573 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 return 0;
575}
576
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200577static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
578 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100579{
580 signed int change;
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 hda_nid_t nid = kcontrol->private_value & 0xffff;
583 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
584 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200585 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
586 AC_VERB_GET_PIN_WIDGET_CONTROL,
587 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200589 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590 val = alc_pin_mode_min(dir);
591
592 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100593 if (change) {
594 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200595 snd_hda_codec_write_cache(codec, nid, 0,
596 AC_VERB_SET_PIN_WIDGET_CONTROL,
597 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100598
Kailang Yangea1fb292008-08-26 12:58:38 +0200599 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100600 * for the requested pin mode. Enum values of 2 or less are
601 * input modes.
602 *
603 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200604 * reduces noise slightly (particularly on input) so we'll
605 * do it. However, having both input and output buffers
606 * enabled simultaneously doesn't seem to be problematic if
607 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100608 */
609 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200610 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
611 HDA_AMP_MUTE, HDA_AMP_MUTE);
612 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
613 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100614 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200615 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
616 HDA_AMP_MUTE, HDA_AMP_MUTE);
617 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
618 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100619 }
620 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200621 return change;
622}
623
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100624#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 .info = alc_pin_mode_info, \
627 .get = alc_pin_mode_get, \
628 .put = alc_pin_mode_put, \
629 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100630
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100631/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
632 * together using a mask with more than one bit set. This control is
633 * currently used only by the ALC260 test model. At this stage they are not
634 * needed for any "production" models.
635 */
636#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200637#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200638
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200639static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
640 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100641{
642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
643 hda_nid_t nid = kcontrol->private_value & 0xffff;
644 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
645 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200646 unsigned int val = snd_hda_codec_read(codec, nid, 0,
647 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100648
649 *valp = (val & mask) != 0;
650 return 0;
651}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200652static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100654{
655 signed int change;
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 hda_nid_t nid = kcontrol->private_value & 0xffff;
658 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
659 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200660 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
661 AC_VERB_GET_GPIO_DATA,
662 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100663
664 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
666 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667 gpio_data &= ~mask;
668 else
669 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200670 snd_hda_codec_write_cache(codec, nid, 0,
671 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100672
673 return change;
674}
675#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
676 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
677 .info = alc_gpio_data_info, \
678 .get = alc_gpio_data_get, \
679 .put = alc_gpio_data_put, \
680 .private_value = nid | (mask<<16) }
681#endif /* CONFIG_SND_DEBUG */
682
Jonathan Woithe92621f12006-02-28 11:47:47 +0100683/* A switch control to allow the enabling of the digital IO pins on the
684 * ALC260. This is incredibly simplistic; the intention of this control is
685 * to provide something in the test model allowing digital outputs to be
686 * identified if present. If models are found which can utilise these
687 * outputs a more complete mixer control can be devised for those models if
688 * necessary.
689 */
690#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200691#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200692
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200693static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
694 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100695{
696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
697 hda_nid_t nid = kcontrol->private_value & 0xffff;
698 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
699 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200700 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100701 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100702
703 *valp = (val & mask) != 0;
704 return 0;
705}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200706static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
707 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100708{
709 signed int change;
710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
711 hda_nid_t nid = kcontrol->private_value & 0xffff;
712 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
713 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200714 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100715 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200716 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100717
718 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100720 if (val==0)
721 ctrl_data &= ~mask;
722 else
723 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200724 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
725 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100726
727 return change;
728}
729#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
730 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
731 .info = alc_spdif_ctrl_info, \
732 .get = alc_spdif_ctrl_get, \
733 .put = alc_spdif_ctrl_put, \
734 .private_value = nid | (mask<<16) }
735#endif /* CONFIG_SND_DEBUG */
736
Jonathan Woithef8225f62008-01-08 12:16:54 +0100737/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
738 * Again, this is only used in the ALC26x test models to help identify when
739 * the EAPD line must be asserted for features to work.
740 */
741#ifdef CONFIG_SND_DEBUG
742#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
743
744static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
745 struct snd_ctl_elem_value *ucontrol)
746{
747 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
748 hda_nid_t nid = kcontrol->private_value & 0xffff;
749 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
750 long *valp = ucontrol->value.integer.value;
751 unsigned int val = snd_hda_codec_read(codec, nid, 0,
752 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
753
754 *valp = (val & mask) != 0;
755 return 0;
756}
757
758static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
759 struct snd_ctl_elem_value *ucontrol)
760{
761 int change;
762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
763 hda_nid_t nid = kcontrol->private_value & 0xffff;
764 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
765 long val = *ucontrol->value.integer.value;
766 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
767 AC_VERB_GET_EAPD_BTLENABLE,
768 0x00);
769
770 /* Set/unset the masked control bit(s) as needed */
771 change = (!val ? 0 : mask) != (ctrl_data & mask);
772 if (!val)
773 ctrl_data &= ~mask;
774 else
775 ctrl_data |= mask;
776 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
777 ctrl_data);
778
779 return change;
780}
781
782#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
783 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
784 .info = alc_eapd_ctrl_info, \
785 .get = alc_eapd_ctrl_get, \
786 .put = alc_eapd_ctrl_put, \
787 .private_value = nid | (mask<<16) }
788#endif /* CONFIG_SND_DEBUG */
789
Kailang Yangdf694da2005-12-05 19:42:22 +0100790/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100791 * set up the input pin config (depending on the given auto-pin type)
792 */
793static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
794 int auto_pin_type)
795{
796 unsigned int val = PIN_IN;
797
798 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
799 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100800 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100801 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
802 if (pincap & AC_PINCAP_VREF_80)
803 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200804 else if (pincap & AC_PINCAP_VREF_50)
805 val = PIN_VREF50;
806 else if (pincap & AC_PINCAP_VREF_100)
807 val = PIN_VREF100;
808 else if (pincap & AC_PINCAP_VREF_GRD)
809 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100810 }
811 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
812}
813
814/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100815 */
816static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
817{
818 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
819 return;
820 spec->mixers[spec->num_mixers++] = mix;
821}
822
823static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
824{
825 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
826 return;
827 spec->init_verbs[spec->num_init_verbs++] = verb;
828}
829
Takashi Iwaidaead532008-11-28 12:55:36 +0100830#ifdef CONFIG_PROC_FS
831/*
832 * hook for proc
833 */
834static void print_realtek_coef(struct snd_info_buffer *buffer,
835 struct hda_codec *codec, hda_nid_t nid)
836{
837 int coeff;
838
839 if (nid != 0x20)
840 return;
841 coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0);
842 snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff);
843 coeff = snd_hda_codec_read(codec, nid, 0,
844 AC_VERB_GET_COEF_INDEX, 0);
845 snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff);
846}
847#else
848#define print_realtek_coef NULL
849#endif
850
Takashi Iwaid88897e2008-10-31 15:01:37 +0100851/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100852 * set up from the preset table
853 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200854static void setup_preset(struct alc_spec *spec,
855 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100856{
857 int i;
858
859 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100860 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100861 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200862 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
863 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100864 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200865
Kailang Yangdf694da2005-12-05 19:42:22 +0100866 spec->channel_mode = preset->channel_mode;
867 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200868 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200869 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100870
Hector Martin3b315d72009-06-02 10:54:19 +0200871 if (preset->const_channel_count)
872 spec->multiout.max_channels = preset->const_channel_count;
873 else
874 spec->multiout.max_channels = spec->channel_mode[0].channels;
875 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100876
877 spec->multiout.num_dacs = preset->num_dacs;
878 spec->multiout.dac_nids = preset->dac_nids;
879 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800880 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100881 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200882
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200883 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200884 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100886 spec->input_mux = preset->input_mux;
887
888 spec->num_adc_nids = preset->num_adc_nids;
889 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100890 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100891 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100892
893 spec->unsol_event = preset->unsol_event;
894 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200895#ifdef CONFIG_SND_HDA_POWER_SAVE
896 spec->loopback.amplist = preset->loopbacks;
897#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100898}
899
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200900/* Enable GPIO mask and set output */
901static struct hda_verb alc_gpio1_init_verbs[] = {
902 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
903 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
904 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
905 { }
906};
907
908static struct hda_verb alc_gpio2_init_verbs[] = {
909 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
910 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
911 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
912 { }
913};
914
Kailang Yangbdd148a2007-05-08 15:19:08 +0200915static struct hda_verb alc_gpio3_init_verbs[] = {
916 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
917 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
918 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
919 { }
920};
921
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200922/*
923 * Fix hardware PLL issue
924 * On some codecs, the analog PLL gating control must be off while
925 * the default value is 1.
926 */
927static void alc_fix_pll(struct hda_codec *codec)
928{
929 struct alc_spec *spec = codec->spec;
930 unsigned int val;
931
932 if (!spec->pll_nid)
933 return;
934 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
935 spec->pll_coef_idx);
936 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
937 AC_VERB_GET_PROC_COEF, 0);
938 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
939 spec->pll_coef_idx);
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
941 val & ~(1 << spec->pll_coef_bit));
942}
943
944static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
945 unsigned int coef_idx, unsigned int coef_bit)
946{
947 struct alc_spec *spec = codec->spec;
948 spec->pll_nid = nid;
949 spec->pll_coef_idx = coef_idx;
950 spec->pll_coef_bit = coef_bit;
951 alc_fix_pll(codec);
952}
953
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200954static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200955{
956 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +0200957 unsigned int present, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200958 unsigned int nid = spec->autocfg.hp_pins[0];
959 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200960
Takashi Iwai261c2402009-06-25 08:13:40 +0200961 pincap = snd_hda_query_pin_caps(codec, nid);
962 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
963 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200964 present = snd_hda_codec_read(codec, nid, 0,
Kailang Yangc9b58002007-10-16 14:30:01 +0200965 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200966 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
967 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
968 nid = spec->autocfg.speaker_pins[i];
969 if (!nid)
970 break;
971 snd_hda_codec_write(codec, nid, 0,
972 AC_VERB_SET_PIN_WIDGET_CONTROL,
973 spec->jack_present ? 0 : PIN_OUT);
974 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200975}
976
Takashi Iwai6c819492009-08-10 18:47:44 +0200977static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
978 hda_nid_t nid)
979{
980 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
981 int i, nums;
982
983 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
984 for (i = 0; i < nums; i++)
985 if (conn[i] == nid)
986 return i;
987 return -1;
988}
989
990static int set_mic_mux_idx(struct hda_codec *codec, hda_nid_t cap,
991 struct alc_mic_route *mic)
992{
993 int idx = get_connection_index(codec, cap, mic->pin);
994 if (idx < 0)
995 return 1; /* invalid */
996 mic->mux_idx = idx;
997 return 0;
998}
999
Kailang Yang7fb0d782008-10-15 11:12:35 +02001000static void alc_mic_automute(struct hda_codec *codec)
1001{
1002 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001003 struct alc_mic_route *dead, *alive;
1004 unsigned int present, type;
1005 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001006
Takashi Iwai6c819492009-08-10 18:47:44 +02001007 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1008 return;
1009 if (snd_BUG_ON(!spec->adc_nids))
1010 return;
1011
1012 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1013
1014 present = snd_hda_codec_read(codec, spec->ext_mic.pin, 0,
1015 AC_VERB_GET_PIN_SENSE, 0);
1016 present &= AC_PINSENSE_PRESENCE;
1017 if (present) {
1018 alive = &spec->ext_mic;
1019 dead = &spec->int_mic;
1020 } else {
1021 alive = &spec->int_mic;
1022 dead = &spec->ext_mic;
1023 }
1024
1025 if (alive->mux_idx == MUX_IDX_UNDEF &&
1026 set_mic_mux_idx(codec, cap_nid, alive))
1027 return;
1028 if (dead->mux_idx == MUX_IDX_UNDEF &&
1029 set_mic_mux_idx(codec, cap_nid, dead))
1030 return;
1031
1032 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1033 if (type == AC_WID_AUD_MIX) {
1034 /* Matrix-mixer style (e.g. ALC882) */
1035 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1036 alive->mux_idx,
1037 HDA_AMP_MUTE, 0);
1038 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1039 dead->mux_idx,
1040 HDA_AMP_MUTE, HDA_AMP_MUTE);
1041 } else {
1042 /* MUX style (e.g. ALC880) */
1043 snd_hda_codec_write_cache(codec, cap_nid, 0,
1044 AC_VERB_SET_CONNECT_SEL,
1045 alive->mux_idx);
1046 }
1047
1048 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001049}
1050
Kailang Yangc9b58002007-10-16 14:30:01 +02001051/* unsolicited event for HP jack sensing */
1052static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1053{
1054 if (codec->vendor_id == 0x10ec0880)
1055 res >>= 28;
1056 else
1057 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 switch (res) {
1059 case ALC880_HP_EVENT:
1060 alc_automute_pin(codec);
1061 break;
1062 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001063 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001064 break;
1065 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001066}
1067
1068static void alc_inithook(struct hda_codec *codec)
1069{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001070 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001071 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001072}
1073
Kailang Yangf9423e72008-05-27 12:32:25 +02001074/* additional initialization for ALC888 variants */
1075static void alc888_coef_init(struct hda_codec *codec)
1076{
1077 unsigned int tmp;
1078
1079 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1080 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1081 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001082 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001083 /* alc888S-VC */
1084 snd_hda_codec_read(codec, 0x20, 0,
1085 AC_VERB_SET_PROC_COEF, 0x830);
1086 else
1087 /* alc888-VB */
1088 snd_hda_codec_read(codec, 0x20, 0,
1089 AC_VERB_SET_PROC_COEF, 0x3030);
1090}
1091
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001092static void alc889_coef_init(struct hda_codec *codec)
1093{
1094 unsigned int tmp;
1095
1096 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1097 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1098 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1099 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1100}
1101
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001102static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001103{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001104 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001105
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001106 switch (type) {
1107 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001108 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1109 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001110 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001111 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1112 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001113 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001114 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1115 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001116 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001117 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001118 case 0x10ec0260:
1119 snd_hda_codec_write(codec, 0x0f, 0,
1120 AC_VERB_SET_EAPD_BTLENABLE, 2);
1121 snd_hda_codec_write(codec, 0x10, 0,
1122 AC_VERB_SET_EAPD_BTLENABLE, 2);
1123 break;
1124 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001125 case 0x10ec0267:
1126 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001127 case 0x10ec0269:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001128 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001129 case 0x10ec0660:
1130 case 0x10ec0662:
1131 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001133 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001134 snd_hda_codec_write(codec, 0x14, 0,
1135 AC_VERB_SET_EAPD_BTLENABLE, 2);
1136 snd_hda_codec_write(codec, 0x15, 0,
1137 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001138 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001139 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001140 switch (codec->vendor_id) {
1141 case 0x10ec0260:
1142 snd_hda_codec_write(codec, 0x1a, 0,
1143 AC_VERB_SET_COEF_INDEX, 7);
1144 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1145 AC_VERB_GET_PROC_COEF, 0);
1146 snd_hda_codec_write(codec, 0x1a, 0,
1147 AC_VERB_SET_COEF_INDEX, 7);
1148 snd_hda_codec_write(codec, 0x1a, 0,
1149 AC_VERB_SET_PROC_COEF,
1150 tmp | 0x2010);
1151 break;
1152 case 0x10ec0262:
1153 case 0x10ec0880:
1154 case 0x10ec0882:
1155 case 0x10ec0883:
1156 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001157 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001158 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001159 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001160 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001161 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001162 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001163 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001164 case 0x10ec0267:
1165 case 0x10ec0268:
1166 snd_hda_codec_write(codec, 0x20, 0,
1167 AC_VERB_SET_COEF_INDEX, 7);
1168 tmp = snd_hda_codec_read(codec, 0x20, 0,
1169 AC_VERB_GET_PROC_COEF, 0);
1170 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001171 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001172 snd_hda_codec_write(codec, 0x20, 0,
1173 AC_VERB_SET_PROC_COEF,
1174 tmp | 0x3000);
1175 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001176 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001177 break;
1178 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001179}
Kailang Yangea1fb292008-08-26 12:58:38 +02001180
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181static void alc_init_auto_hp(struct hda_codec *codec)
1182{
1183 struct alc_spec *spec = codec->spec;
1184
1185 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001186 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001187
Kailang Yangc9b58002007-10-16 14:30:01 +02001188 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001189 if (spec->autocfg.line_out_pins[0] &&
1190 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001191 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001192 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001193 else
1194 return;
1195 }
1196
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001197 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1198 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001199 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1200 AC_VERB_SET_UNSOLICITED_ENABLE,
1201 AC_USRSP_EN | ALC880_HP_EVENT);
1202 spec->unsol_event = alc_sku_unsol_event;
1203}
1204
Takashi Iwai6c819492009-08-10 18:47:44 +02001205static void alc_init_auto_mic(struct hda_codec *codec)
1206{
1207 struct alc_spec *spec = codec->spec;
1208 struct auto_pin_cfg *cfg = &spec->autocfg;
1209 hda_nid_t fixed, ext;
1210 int i;
1211
1212 /* there must be only two mic inputs exclusively */
1213 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1214 if (cfg->input_pins[i])
1215 return;
1216
1217 fixed = ext = 0;
1218 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1219 hda_nid_t nid = cfg->input_pins[i];
1220 unsigned int defcfg;
1221 if (!nid)
1222 return;
1223 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1224 switch (get_defcfg_connect(defcfg)) {
1225 case AC_JACK_PORT_FIXED:
1226 if (fixed)
1227 return; /* already occupied */
1228 fixed = nid;
1229 break;
1230 case AC_JACK_PORT_COMPLEX:
1231 if (ext)
1232 return; /* already occupied */
1233 ext = nid;
1234 break;
1235 default:
1236 return; /* invalid entry */
1237 }
1238 }
1239 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1240 return; /* no unsol support */
1241 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1242 ext, fixed);
1243 spec->ext_mic.pin = ext;
1244 spec->int_mic.pin = fixed;
1245 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1246 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1247 spec->auto_mic = 1;
1248 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1249 AC_VERB_SET_UNSOLICITED_ENABLE,
1250 AC_USRSP_EN | ALC880_MIC_EVENT);
1251 spec->unsol_event = alc_sku_unsol_event;
1252}
1253
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001254/* check subsystem ID and set up device-specific initialization;
1255 * return 1 if initialized, 0 if invalid SSID
1256 */
1257/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1258 * 31 ~ 16 : Manufacture ID
1259 * 15 ~ 8 : SKU ID
1260 * 7 ~ 0 : Assembly ID
1261 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1262 */
1263static int alc_subsystem_id(struct hda_codec *codec,
1264 hda_nid_t porta, hda_nid_t porte,
1265 hda_nid_t portd)
1266{
1267 unsigned int ass, tmp, i;
1268 unsigned nid;
1269 struct alc_spec *spec = codec->spec;
1270
1271 ass = codec->subsystem_id & 0xffff;
1272 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1273 goto do_sku;
1274
1275 /* invalid SSID, check the special NID pin defcfg instead */
1276 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001277 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001278 * 29~21 : reserve
1279 * 20 : PCBEEP input
1280 * 19~16 : Check sum (15:1)
1281 * 15~1 : Custom
1282 * 0 : override
1283 */
1284 nid = 0x1d;
1285 if (codec->vendor_id == 0x10ec0260)
1286 nid = 0x17;
1287 ass = snd_hda_codec_get_pincfg(codec, nid);
1288 snd_printd("realtek: No valid SSID, "
1289 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001290 ass, nid);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001291 if (!(ass & 1) && !(ass & 0x100000))
1292 return 0;
1293 if ((ass >> 30) != 1) /* no physical connection */
1294 return 0;
1295
1296 /* check sum */
1297 tmp = 0;
1298 for (i = 1; i < 16; i++) {
1299 if ((ass >> i) & 1)
1300 tmp++;
1301 }
1302 if (((ass >> 16) & 0xf) != tmp)
1303 return 0;
1304do_sku:
1305 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1306 ass & 0xffff, codec->vendor_id);
1307 /*
1308 * 0 : override
1309 * 1 : Swap Jack
1310 * 2 : 0 --> Desktop, 1 --> Laptop
1311 * 3~5 : External Amplifier control
1312 * 7~6 : Reserved
1313 */
1314 tmp = (ass & 0x38) >> 3; /* external Amp control */
1315 switch (tmp) {
1316 case 1:
1317 spec->init_amp = ALC_INIT_GPIO1;
1318 break;
1319 case 3:
1320 spec->init_amp = ALC_INIT_GPIO2;
1321 break;
1322 case 7:
1323 spec->init_amp = ALC_INIT_GPIO3;
1324 break;
1325 case 5:
1326 spec->init_amp = ALC_INIT_DEFAULT;
1327 break;
1328 }
1329
1330 /* is laptop or Desktop and enable the function "Mute internal speaker
1331 * when the external headphone out jack is plugged"
1332 */
1333 if (!(ass & 0x8000))
1334 return 1;
1335 /*
1336 * 10~8 : Jack location
1337 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1338 * 14~13: Resvered
1339 * 15 : 1 --> enable the function "Mute internal speaker
1340 * when the external headphone out jack is plugged"
1341 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001342 if (!spec->autocfg.hp_pins[0]) {
1343 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1344 if (tmp == 0)
1345 spec->autocfg.hp_pins[0] = porta;
1346 else if (tmp == 1)
1347 spec->autocfg.hp_pins[0] = porte;
1348 else if (tmp == 2)
1349 spec->autocfg.hp_pins[0] = portd;
1350 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001351 return 1;
Kailang Yangc9b58002007-10-16 14:30:01 +02001352 }
1353
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001354 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001355 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001356 return 1;
1357}
Kailang Yangea1fb292008-08-26 12:58:38 +02001358
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359static void alc_ssid_check(struct hda_codec *codec,
1360 hda_nid_t porta, hda_nid_t porte, hda_nid_t portd)
1361{
1362 if (!alc_subsystem_id(codec, porta, porte, portd)) {
1363 struct alc_spec *spec = codec->spec;
1364 snd_printd("realtek: "
1365 "Enable default setup for auto mode as fallback\n");
1366 spec->init_amp = ALC_INIT_DEFAULT;
1367 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001368 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001369 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001370}
1371
Takashi Iwai41e41f12005-06-08 14:48:49 +02001372/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001373 * Fix-up pin default configurations
1374 */
1375
1376struct alc_pincfg {
1377 hda_nid_t nid;
1378 u32 val;
1379};
1380
1381static void alc_fix_pincfg(struct hda_codec *codec,
1382 const struct snd_pci_quirk *quirk,
1383 const struct alc_pincfg **pinfix)
1384{
1385 const struct alc_pincfg *cfg;
1386
1387 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1388 if (!quirk)
1389 return;
1390
1391 cfg = pinfix[quirk->value];
Takashi Iwai0e8a21b2009-02-20 14:13:06 +01001392 for (; cfg->nid; cfg++)
1393 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001394}
1395
1396/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001397 * ALC888
1398 */
1399
1400/*
1401 * 2ch mode
1402 */
1403static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1404/* Mic-in jack as mic in */
1405 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1406 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1407/* Line-in jack as Line in */
1408 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1409 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1410/* Line-Out as Front */
1411 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1412 { } /* end */
1413};
1414
1415/*
1416 * 4ch mode
1417 */
1418static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1419/* Mic-in jack as mic in */
1420 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1421 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1422/* Line-in jack as Surround */
1423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1425/* Line-Out as Front */
1426 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1427 { } /* end */
1428};
1429
1430/*
1431 * 6ch mode
1432 */
1433static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1434/* Mic-in jack as CLFE */
1435 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1436 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1437/* Line-in jack as Surround */
1438 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1439 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1440/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1441 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1442 { } /* end */
1443};
1444
1445/*
1446 * 8ch mode
1447 */
1448static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1449/* Mic-in jack as CLFE */
1450 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1451 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1452/* Line-in jack as Surround */
1453 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1454 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1455/* Line-Out as Side */
1456 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1457 { } /* end */
1458};
1459
1460static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1461 { 2, alc888_4ST_ch2_intel_init },
1462 { 4, alc888_4ST_ch4_intel_init },
1463 { 6, alc888_4ST_ch6_intel_init },
1464 { 8, alc888_4ST_ch8_intel_init },
1465};
1466
1467/*
1468 * ALC888 Fujitsu Siemens Amillo xa3530
1469 */
1470
1471static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1472/* Front Mic: set to PIN_IN (empty by default) */
1473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1474/* Connect Internal HP to Front */
1475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1477 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1478/* Connect Bass HP to Front */
1479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1480 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1481 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1482/* Connect Line-Out side jack (SPDIF) to Side */
1483 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1484 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1485 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1486/* Connect Mic jack to CLFE */
1487 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1489 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1490/* Connect Line-in jack to Surround */
1491 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1492 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1493 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1494/* Connect HP out jack to Front */
1495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1496 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1497 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1498/* Enable unsolicited event for HP jack and Line-out jack */
1499 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1500 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1501 {}
1502};
1503
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001504static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001505{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001506 struct alc_spec *spec = codec->spec;
Takashi Iwai261c2402009-06-25 08:13:40 +02001507 unsigned int val, mute, pincap;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001508 hda_nid_t nid;
1509 int i;
1510
1511 spec->jack_present = 0;
1512 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1513 nid = spec->autocfg.hp_pins[i];
1514 if (!nid)
1515 break;
Takashi Iwai261c2402009-06-25 08:13:40 +02001516 pincap = snd_hda_query_pin_caps(codec, nid);
1517 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1518 snd_hda_codec_read(codec, nid, 0,
1519 AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001520 val = snd_hda_codec_read(codec, nid, 0,
1521 AC_VERB_GET_PIN_SENSE, 0);
1522 if (val & AC_PINSENSE_PRESENCE) {
1523 spec->jack_present = 1;
1524 break;
1525 }
1526 }
1527
1528 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001529 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001530 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1531 nid = spec->autocfg.speaker_pins[i];
1532 if (!nid)
1533 break;
1534 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1535 HDA_AMP_MUTE, mute);
1536 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001537}
1538
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001539static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1540 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001541{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001542 if (codec->vendor_id == 0x10ec0880)
1543 res >>= 28;
1544 else
1545 res >>= 26;
1546 if (res == ALC880_HP_EVENT)
1547 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548}
1549
Wu Fengguang6732bd02009-07-30 09:19:14 +02001550static void alc889_automute_init(struct hda_codec *codec)
1551{
1552 struct alc_spec *spec = codec->spec;
1553
1554 spec->autocfg.hp_pins[0] = 0x15;
1555 spec->autocfg.speaker_pins[0] = 0x14;
1556 spec->autocfg.speaker_pins[1] = 0x16;
1557 spec->autocfg.speaker_pins[2] = 0x17;
1558 spec->autocfg.speaker_pins[3] = 0x19;
1559 spec->autocfg.speaker_pins[4] = 0x1a;
1560 alc_automute_amp(codec);
1561}
1562
1563static void alc889_intel_init_hook(struct hda_codec *codec)
1564{
1565 alc889_coef_init(codec);
1566 alc889_automute_init(codec);
1567}
1568
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001569static void alc888_fujitsu_xa3530_init_hook(struct hda_codec *codec)
1570{
1571 struct alc_spec *spec = codec->spec;
1572
1573 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1574 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1575 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1576 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
1577 alc_automute_amp(codec);
1578}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001579
1580/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001581 * ALC888 Acer Aspire 4930G model
1582 */
1583
1584static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1585/* Front Mic: set to PIN_IN (empty by default) */
1586 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1587/* Unselect Front Mic by default in input mixer 3 */
1588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001589/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001590 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1591/* Connect Internal HP to front */
1592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1593 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1594 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1595/* Connect HP out to front */
1596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1598 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1599 { }
1600};
1601
Hector Martin3b315d72009-06-02 10:54:19 +02001602/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001603 * ALC888 Acer Aspire 6530G model
1604 */
1605
1606static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1607/* Bias voltage on for external mic port */
1608 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001609/* Front Mic: set to PIN_IN (empty by default) */
1610 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1611/* Unselect Front Mic by default in input mixer 3 */
1612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001613/* Enable unsolicited event for HP jack */
1614 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1615/* Enable speaker output */
1616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1618/* Enable headphone output */
1619 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1620 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1621 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1622 { }
1623};
1624
1625/*
Hector Martin018df412009-06-04 00:13:40 +02001626 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001627 */
1628
Hector Martin018df412009-06-04 00:13:40 +02001629static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001630/* Front Mic: set to PIN_IN (empty by default) */
1631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1632/* Unselect Front Mic by default in input mixer 3 */
1633 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1634/* Enable unsolicited event for HP jack */
1635 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1636/* Connect Internal Front to Front */
1637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1638 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1639 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1640/* Connect Internal Rear to Rear */
1641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1643 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1644/* Connect Internal CLFE to CLFE */
1645 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1646 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1647 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1648/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001650 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1651 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1652/* Enable all DACs */
1653/* DAC DISABLE/MUTE 1? */
1654/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1655 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1656 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1657/* DAC DISABLE/MUTE 2? */
1658/* some bit here disables the other DACs. Init=0x4900 */
1659 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1660 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1661/* Enable amplifiers */
1662 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
1663 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
Hector Martin018df412009-06-04 00:13:40 +02001664/* DMIC fix
1665 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1666 * which makes the stereo useless. However, either the mic or the ALC889
1667 * makes the signal become a difference/sum signal instead of standard
1668 * stereo, which is annoying. So instead we flip this bit which makes the
1669 * codec replicate the sum signal to both channels, turning it into a
1670 * normal mono mic.
1671 */
1672/* DMIC_CONTROL? Init value = 0x0001 */
1673 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1674 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001675 { }
1676};
1677
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001678static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001679 /* Front mic only available on one ADC */
1680 {
1681 .num_items = 4,
1682 .items = {
1683 { "Mic", 0x0 },
1684 { "Line", 0x2 },
1685 { "CD", 0x4 },
1686 { "Front Mic", 0xb },
1687 },
1688 },
1689 {
1690 .num_items = 3,
1691 .items = {
1692 { "Mic", 0x0 },
1693 { "Line", 0x2 },
1694 { "CD", 0x4 },
1695 },
1696 }
1697};
1698
Tony Vroond2fd4b02009-06-21 00:40:10 +01001699static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1700 /* Interal mic only available on one ADC */
1701 {
Tony Vroon684a8842009-06-26 09:27:50 +01001702 .num_items = 5,
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 { "Int Mic", 0xb },
1709 },
1710 },
1711 {
Tony Vroon684a8842009-06-26 09:27:50 +01001712 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713 .items = {
1714 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001715 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001716 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001717 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001718 },
1719 }
1720};
1721
Hector Martin018df412009-06-04 00:13:40 +02001722static struct hda_input_mux alc889_capture_sources[3] = {
1723 /* Digital mic only available on first "ADC" */
1724 {
1725 .num_items = 5,
1726 .items = {
1727 { "Mic", 0x0 },
1728 { "Line", 0x2 },
1729 { "CD", 0x4 },
1730 { "Front Mic", 0xb },
1731 { "Input Mix", 0xa },
1732 },
1733 },
1734 {
1735 .num_items = 4,
1736 .items = {
1737 { "Mic", 0x0 },
1738 { "Line", 0x2 },
1739 { "CD", 0x4 },
1740 { "Input Mix", 0xa },
1741 },
1742 },
1743 {
1744 .num_items = 4,
1745 .items = {
1746 { "Mic", 0x0 },
1747 { "Line", 0x2 },
1748 { "CD", 0x4 },
1749 { "Input Mix", 0xa },
1750 },
1751 }
1752};
1753
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001754static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1756 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1757 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1758 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1759 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1760 HDA_OUTPUT),
1761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1764 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1765 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1768 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1769 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1770 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001773 { } /* end */
1774};
1775
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001776static void alc888_acer_aspire_4930g_init_hook(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001777{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001778 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001779
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001780 spec->autocfg.hp_pins[0] = 0x15;
1781 spec->autocfg.speaker_pins[0] = 0x14;
1782 alc_automute_amp(codec);
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001783}
1784
Emilio López320d5922009-06-25 08:18:44 +02001785static void alc888_acer_aspire_6530g_init_hook(struct hda_codec *codec)
1786{
1787 struct alc_spec *spec = codec->spec;
1788
1789 spec->autocfg.hp_pins[0] = 0x15;
1790 spec->autocfg.speaker_pins[0] = 0x14;
1791 spec->autocfg.speaker_pins[1] = 0x16;
1792 spec->autocfg.speaker_pins[2] = 0x17;
1793 alc_automute_amp(codec);
1794}
1795
Hector Martin018df412009-06-04 00:13:40 +02001796static void alc889_acer_aspire_8930g_init_hook(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001797{
1798 struct alc_spec *spec = codec->spec;
1799
1800 spec->autocfg.hp_pins[0] = 0x15;
1801 spec->autocfg.speaker_pins[0] = 0x14;
1802 spec->autocfg.speaker_pins[1] = 0x16;
1803 spec->autocfg.speaker_pins[2] = 0x1b;
1804 alc_automute_amp(codec);
1805}
1806
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001807/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001808 * ALC880 3-stack model
1809 *
1810 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001811 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1812 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 */
1814
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001815static hda_nid_t alc880_dac_nids[4] = {
1816 /* front, rear, clfe, rear_surr */
1817 0x02, 0x05, 0x04, 0x03
1818};
1819
1820static hda_nid_t alc880_adc_nids[3] = {
1821 /* ADC0-2 */
1822 0x07, 0x08, 0x09,
1823};
1824
1825/* The datasheet says the node 0x07 is connected from inputs,
1826 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001827 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829static hda_nid_t alc880_adc_nids_alt[2] = {
1830 /* ADC1-2 */
1831 0x08, 0x09,
1832};
1833
1834#define ALC880_DIGOUT_NID 0x06
1835#define ALC880_DIGIN_NID 0x0a
1836
1837static struct hda_input_mux alc880_capture_source = {
1838 .num_items = 4,
1839 .items = {
1840 { "Mic", 0x0 },
1841 { "Front Mic", 0x3 },
1842 { "Line", 0x2 },
1843 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001845};
1846
1847/* channel source setting (2/6 channel selection for 3-stack) */
1848/* 2ch mode */
1849static struct hda_verb alc880_threestack_ch2_init[] = {
1850 /* set line-in to input, mute it */
1851 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1852 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1853 /* set mic-in to input vref 80%, mute it */
1854 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1855 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001856 { } /* end */
1857};
1858
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001859/* 6ch mode */
1860static struct hda_verb alc880_threestack_ch6_init[] = {
1861 /* set line-in to output, unmute it */
1862 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1863 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1864 /* set mic-in to output, unmute it */
1865 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1866 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1867 { } /* end */
1868};
1869
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001870static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001871 { 2, alc880_threestack_ch2_init },
1872 { 6, alc880_threestack_ch6_init },
1873};
1874
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001875static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001878 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001879 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001880 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1881 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001884 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1885 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1890 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1891 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001893 {
1894 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1895 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001896 .info = alc_ch_mode_info,
1897 .get = alc_ch_mode_get,
1898 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001899 },
1900 { } /* end */
1901};
1902
1903/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001904static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1905 struct snd_ctl_elem_info *uinfo)
1906{
1907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1908 struct alc_spec *spec = codec->spec;
1909 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001910
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001911 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001912 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1913 HDA_INPUT);
1914 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001915 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001916 return err;
1917}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001919static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1920 unsigned int size, unsigned int __user *tlv)
1921{
1922 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1923 struct alc_spec *spec = codec->spec;
1924 int err;
1925
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001926 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001927 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1928 HDA_INPUT);
1929 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001930 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001931 return err;
1932}
1933
1934typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1935 struct snd_ctl_elem_value *ucontrol);
1936
1937static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1938 struct snd_ctl_elem_value *ucontrol,
1939 getput_call_t func)
1940{
1941 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1942 struct alc_spec *spec = codec->spec;
1943 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1944 int err;
1945
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001946 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001947 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1948 3, 0, HDA_INPUT);
1949 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001950 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951 return err;
1952}
1953
1954static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1955 struct snd_ctl_elem_value *ucontrol)
1956{
1957 return alc_cap_getput_caller(kcontrol, ucontrol,
1958 snd_hda_mixer_amp_volume_get);
1959}
1960
1961static int alc_cap_vol_put(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_volume_put);
1966}
1967
1968/* capture mixer elements */
1969#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1970
1971static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1972 struct snd_ctl_elem_value *ucontrol)
1973{
1974 return alc_cap_getput_caller(kcontrol, ucontrol,
1975 snd_hda_mixer_amp_switch_get);
1976}
1977
1978static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1979 struct snd_ctl_elem_value *ucontrol)
1980{
1981 return alc_cap_getput_caller(kcontrol, ucontrol,
1982 snd_hda_mixer_amp_switch_put);
1983}
1984
Takashi Iwaia23b6882009-03-23 15:21:36 +01001985#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001986 { \
1987 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1988 .name = "Capture Switch", \
1989 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1990 .count = num, \
1991 .info = alc_cap_sw_info, \
1992 .get = alc_cap_sw_get, \
1993 .put = alc_cap_sw_put, \
1994 }, \
1995 { \
1996 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1997 .name = "Capture Volume", \
1998 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1999 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2000 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2001 .count = num, \
2002 .info = alc_cap_vol_info, \
2003 .get = alc_cap_vol_get, \
2004 .put = alc_cap_vol_put, \
2005 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002006 }
2007
2008#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002009 { \
2010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2011 /* .name = "Capture Source", */ \
2012 .name = "Input Source", \
2013 .count = num, \
2014 .info = alc_mux_enum_info, \
2015 .get = alc_mux_enum_get, \
2016 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002017 }
2018
2019#define DEFINE_CAPMIX(num) \
2020static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2021 _DEFINE_CAPMIX(num), \
2022 _DEFINE_CAPSRC(num), \
2023 { } /* end */ \
2024}
2025
2026#define DEFINE_CAPMIX_NOSRC(num) \
2027static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2028 _DEFINE_CAPMIX(num), \
2029 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002030}
2031
2032/* up to three ADCs */
2033DEFINE_CAPMIX(1);
2034DEFINE_CAPMIX(2);
2035DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002036DEFINE_CAPMIX_NOSRC(1);
2037DEFINE_CAPMIX_NOSRC(2);
2038DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002039
2040/*
2041 * ALC880 5-stack model
2042 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002043 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2044 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2046 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2047 */
2048
2049/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002050static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002051 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002052 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 { } /* end */
2054};
2055
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002056/* channel source setting (6/8 channel selection for 5-stack) */
2057/* 6ch mode */
2058static struct hda_verb alc880_fivestack_ch6_init[] = {
2059 /* set line-in to input, mute it */
2060 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2061 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002062 { } /* end */
2063};
2064
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002065/* 8ch mode */
2066static struct hda_verb alc880_fivestack_ch8_init[] = {
2067 /* set line-in to output, unmute it */
2068 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2069 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2070 { } /* end */
2071};
2072
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002073static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002074 { 6, alc880_fivestack_ch6_init },
2075 { 8, alc880_fivestack_ch8_init },
2076};
2077
2078
2079/*
2080 * ALC880 6-stack model
2081 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002082 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2083 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002084 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2085 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2086 */
2087
2088static hda_nid_t alc880_6st_dac_nids[4] = {
2089 /* front, rear, clfe, rear_surr */
2090 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002091};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002092
2093static struct hda_input_mux alc880_6stack_capture_source = {
2094 .num_items = 4,
2095 .items = {
2096 { "Mic", 0x0 },
2097 { "Front Mic", 0x1 },
2098 { "Line", 0x2 },
2099 { "CD", 0x4 },
2100 },
2101};
2102
2103/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002104static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105 { 8, NULL },
2106};
2107
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002108static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002109 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002110 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002111 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002112 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002113 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2114 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002115 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2116 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002117 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002118 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002119 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2125 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2126 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002127 {
2128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2129 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002130 .info = alc_ch_mode_info,
2131 .get = alc_ch_mode_get,
2132 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002133 },
2134 { } /* end */
2135};
2136
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002137
2138/*
2139 * ALC880 W810 model
2140 *
2141 * W810 has rear IO for:
2142 * Front (DAC 02)
2143 * Surround (DAC 03)
2144 * Center/LFE (DAC 04)
2145 * Digital out (06)
2146 *
2147 * The system also has a pair of internal speakers, and a headphone jack.
2148 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002149 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002150 * There is a variable resistor to control the speaker or headphone
2151 * volume. This is a hardware-only device without a software API.
2152 *
2153 * Plugging headphones in will disable the internal speakers. This is
2154 * implemented in hardware, not via the driver using jack sense. In
2155 * a similar fashion, plugging into the rear socket marked "front" will
2156 * disable both the speakers and headphones.
2157 *
2158 * For input, there's a microphone jack, and an "audio in" jack.
2159 * These may not do anything useful with this driver yet, because I
2160 * haven't setup any initialization verbs for these yet...
2161 */
2162
2163static hda_nid_t alc880_w810_dac_nids[3] = {
2164 /* front, rear/surround, clfe */
2165 0x02, 0x03, 0x04
2166};
2167
2168/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002169static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002170 { 6, NULL }
2171};
2172
2173/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002174static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002176 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002177 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002178 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002179 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2180 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002181 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2182 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2184 { } /* end */
2185};
2186
2187
2188/*
2189 * Z710V model
2190 *
2191 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002192 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2193 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002194 */
2195
2196static hda_nid_t alc880_z71v_dac_nids[1] = {
2197 0x02
2198};
2199#define ALC880_Z71V_HP_DAC 0x03
2200
2201/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002202static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002203 { 2, NULL }
2204};
2205
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002206static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002210 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2212 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2214 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2215 { } /* end */
2216};
2217
2218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219/*
2220 * ALC880 F1734 model
2221 *
2222 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2223 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2224 */
2225
2226static hda_nid_t alc880_f1734_dac_nids[1] = {
2227 0x03
2228};
2229#define ALC880_F1734_HP_DAC 0x02
2230
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002231static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002232 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002233 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002234 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2235 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002236 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2237 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002238 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2239 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002240 { } /* end */
2241};
2242
Takashi Iwai937b4162008-02-11 14:52:36 +01002243static struct hda_input_mux alc880_f1734_capture_source = {
2244 .num_items = 2,
2245 .items = {
2246 { "Mic", 0x1 },
2247 { "CD", 0x4 },
2248 },
2249};
2250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002252/*
2253 * ALC880 ASUS model
2254 *
2255 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2256 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2257 * Mic = 0x18, Line = 0x1a
2258 */
2259
2260#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2261#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2262
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002263static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002265 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002266 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002267 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2269 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002270 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2271 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2273 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2274 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2275 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2276 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2277 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002278 {
2279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2280 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002281 .info = alc_ch_mode_info,
2282 .get = alc_ch_mode_get,
2283 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002284 },
2285 { } /* end */
2286};
2287
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002288/*
2289 * ALC880 ASUS W1V model
2290 *
2291 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2292 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2293 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2294 */
2295
2296/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002297static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002298 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2299 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 { } /* end */
2301};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002302
Kailang Yangdf694da2005-12-05 19:42:22 +01002303/* TCL S700 */
2304static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2305 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2306 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2308 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2309 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2312 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2313 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002314 { } /* end */
2315};
2316
Kailang Yangccc656c2006-10-17 12:32:26 +02002317/* Uniwill */
2318static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002319 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2320 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2321 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2322 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002323 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2324 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2325 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2326 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2327 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2328 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2329 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2330 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2333 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2334 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002335 {
2336 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2337 .name = "Channel Mode",
2338 .info = alc_ch_mode_info,
2339 .get = alc_ch_mode_get,
2340 .put = alc_ch_mode_put,
2341 },
2342 { } /* end */
2343};
2344
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002345static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2346 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2347 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2348 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2349 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2350 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2351 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2352 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2353 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2355 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2356 { } /* end */
2357};
2358
Kailang Yangccc656c2006-10-17 12:32:26 +02002359static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002360 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2361 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2362 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2363 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002364 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2365 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2366 { } /* end */
2367};
2368
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002370 * virtual master controls
2371 */
2372
2373/*
2374 * slave controls for virtual master
2375 */
2376static const char *alc_slave_vols[] = {
2377 "Front Playback Volume",
2378 "Surround Playback Volume",
2379 "Center Playback Volume",
2380 "LFE Playback Volume",
2381 "Side Playback Volume",
2382 "Headphone Playback Volume",
2383 "Speaker Playback Volume",
2384 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002385 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002386 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002387 NULL,
2388};
2389
2390static const char *alc_slave_sws[] = {
2391 "Front Playback Switch",
2392 "Surround Playback Switch",
2393 "Center Playback Switch",
2394 "LFE Playback Switch",
2395 "Side Playback Switch",
2396 "Headphone Playback Switch",
2397 "Speaker Playback Switch",
2398 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002399 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002400 NULL,
2401};
2402
2403/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002404 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002406
2407static void alc_free_kctls(struct hda_codec *codec);
2408
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002409/* additional beep mixers; the actual parameters are overwritten at build */
2410static struct snd_kcontrol_new alc_beep_mixer[] = {
2411 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
2412 HDA_CODEC_MUTE("Beep Playback Switch", 0, 0, HDA_INPUT),
2413 { } /* end */
2414};
2415
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416static int alc_build_controls(struct hda_codec *codec)
2417{
2418 struct alc_spec *spec = codec->spec;
2419 int err;
2420 int i;
2421
2422 for (i = 0; i < spec->num_mixers; i++) {
2423 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2424 if (err < 0)
2425 return err;
2426 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002427 if (spec->cap_mixer) {
2428 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2429 if (err < 0)
2430 return err;
2431 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002433 err = snd_hda_create_spdif_out_ctls(codec,
2434 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 if (err < 0)
2436 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002437 if (!spec->no_analog) {
2438 err = snd_hda_create_spdif_share_sw(codec,
2439 &spec->multiout);
2440 if (err < 0)
2441 return err;
2442 spec->multiout.share_spdif = 1;
2443 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 }
2445 if (spec->dig_in_nid) {
2446 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2447 if (err < 0)
2448 return err;
2449 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002450
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002451 /* create beep controls if needed */
2452 if (spec->beep_amp) {
2453 struct snd_kcontrol_new *knew;
2454 for (knew = alc_beep_mixer; knew->name; knew++) {
2455 struct snd_kcontrol *kctl;
2456 kctl = snd_ctl_new1(knew, codec);
2457 if (!kctl)
2458 return -ENOMEM;
2459 kctl->private_value = spec->beep_amp;
2460 err = snd_hda_ctl_add(codec, kctl);
2461 if (err < 0)
2462 return err;
2463 }
2464 }
2465
Takashi Iwai2134ea42008-01-10 16:53:55 +01002466 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002467 if (!spec->no_analog &&
2468 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002469 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002470 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002471 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002472 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002473 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002474 if (err < 0)
2475 return err;
2476 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002477 if (!spec->no_analog &&
2478 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002479 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2480 NULL, alc_slave_sws);
2481 if (err < 0)
2482 return err;
2483 }
2484
Takashi Iwai603c4012008-07-30 15:01:44 +02002485 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486 return 0;
2487}
2488
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002489
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490/*
2491 * initialize the codec volumes, etc
2492 */
2493
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002494/*
2495 * generic initialization of ADC, input mixers and output mixers
2496 */
2497static struct hda_verb alc880_volume_init_verbs[] = {
2498 /*
2499 * Unmute ADC0-2 and set the default input to mic-in
2500 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002501 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002503 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002505 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002508 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2509 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002510 * Note: PASD motherboards uses the Line In 2 as the input for front
2511 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002514 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2515 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2516 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2517 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2518 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2519 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2520 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522 /*
2523 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002525 /* set vol=0 to output mixers */
2526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2528 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2530 /* set up input amps for analog loopback */
2531 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2537 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2539 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540
2541 { }
2542};
2543
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544/*
2545 * 3-stack pin configuration:
2546 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2547 */
2548static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2549 /*
2550 * preset connection lists of input pins
2551 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2552 */
2553 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2554 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2555 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2556
2557 /*
2558 * Set pin mode and muting
2559 */
2560 /* set front pin widgets 0x14 for output */
2561 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2562 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2563 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2564 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2565 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2566 /* Mic2 (as headphone out) for HP output */
2567 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2568 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2569 /* Line In pin widget for input */
2570 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2571 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2572 /* Line2 (as front mic) pin widget for input and vref at 80% */
2573 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2574 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2575 /* CD pin widget for input */
2576 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2577
2578 { }
2579};
2580
2581/*
2582 * 5-stack pin configuration:
2583 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2584 * line-in/side = 0x1a, f-mic = 0x1b
2585 */
2586static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2587 /*
2588 * preset connection lists of input pins
2589 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2590 */
2591 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2592 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2593
2594 /*
2595 * Set pin mode and muting
2596 */
2597 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002598 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2599 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2601 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002602 /* unmute pins for output (no gain on this amp) */
2603 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2605 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2606 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2607
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002609 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2611 /* Mic2 (as headphone out) for HP output */
2612 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614 /* Line In pin widget for input */
2615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2617 /* Line2 (as front mic) pin widget for input and vref at 80% */
2618 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2619 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2620 /* CD pin widget for input */
2621 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622
2623 { }
2624};
2625
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002626/*
2627 * W810 pin configuration:
2628 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2629 */
2630static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 /* hphone/speaker input selector: front DAC */
2632 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2633
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2638 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2639 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640
2641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002642 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 { }
2645};
2646
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002647/*
2648 * Z71V pin configuration:
2649 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2650 */
2651static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002653 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002654 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002655 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002656
Takashi Iwai16ded522005-06-10 19:58:24 +02002657 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002658 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002659 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002660 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002661
2662 { }
2663};
2664
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002665/*
2666 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002667 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2668 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 */
2670static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2671 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2672
Takashi Iwai16ded522005-06-10 19:58:24 +02002673 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002674 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002675 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002677 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002679 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2681
Takashi Iwai16ded522005-06-10 19:58:24 +02002682 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002683 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002684 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002685 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002686 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002688 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002689 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002690 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002691
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002692 { }
2693};
Takashi Iwai16ded522005-06-10 19:58:24 +02002694
Kailang Yangccc656c2006-10-17 12:32:26 +02002695/*
2696 * Uniwill pin configuration:
2697 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2698 * line = 0x1a
2699 */
2700static struct hda_verb alc880_uniwill_init_verbs[] = {
2701 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2702
2703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2705 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2706 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2707 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2708 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2709 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2710 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2711 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2712 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2713 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2716 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2717
2718 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2720 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2722 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2723 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2724 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2725 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2726 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2727
2728 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2729 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2730
2731 { }
2732};
2733
2734/*
2735* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002736* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002737 */
2738static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2739 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2740
2741 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2745 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2746 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2747 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2748 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2750 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2753
2754 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2755 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2756 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2757 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2758 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2759 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2760
2761 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2762 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2763
2764 { }
2765};
2766
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002767static struct hda_verb alc880_beep_init_verbs[] = {
2768 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2769 { }
2770};
2771
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002772/* auto-toggle front mic */
2773static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2774{
2775 unsigned int present;
2776 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002777
2778 present = snd_hda_codec_read(codec, 0x18, 0,
2779 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002780 bits = present ? HDA_AMP_MUTE : 0;
2781 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002782}
2783
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002784static void alc880_uniwill_init_hook(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002785{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002786 struct alc_spec *spec = codec->spec;
2787
2788 spec->autocfg.hp_pins[0] = 0x14;
2789 spec->autocfg.speaker_pins[0] = 0x15;
2790 spec->autocfg.speaker_pins[0] = 0x16;
2791 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002792 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002793}
2794
2795static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2796 unsigned int res)
2797{
2798 /* Looks like the unsol event is incompatible with the standard
2799 * definition. 4bit tag is placed at 28 bit!
2800 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002801 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002802 case ALC880_MIC_EVENT:
2803 alc880_uniwill_mic_automute(codec);
2804 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002805 default:
2806 alc_automute_amp_unsol_event(codec, res);
2807 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002808 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002809}
2810
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002811static void alc880_uniwill_p53_init_hook(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002812{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002813 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002814
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002815 spec->autocfg.hp_pins[0] = 0x14;
2816 spec->autocfg.speaker_pins[0] = 0x15;
2817 alc_automute_amp(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002818}
2819
2820static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2821{
2822 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002823
Kailang Yangccc656c2006-10-17 12:32:26 +02002824 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002825 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2826 present &= HDA_AMP_VOLMASK;
2827 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2828 HDA_AMP_VOLMASK, present);
2829 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2830 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002831}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002832
Kailang Yangccc656c2006-10-17 12:32:26 +02002833static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2834 unsigned int res)
2835{
2836 /* Looks like the unsol event is incompatible with the standard
2837 * definition. 4bit tag is placed at 28 bit!
2838 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002839 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002840 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002841 else
2842 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002843}
2844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845/*
2846 * F1734 pin configuration:
2847 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2848 */
2849static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002850 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002851 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2852 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2853 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2854 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2855
2856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2860
2861 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002863 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2865 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2869 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002870
Takashi Iwai937b4162008-02-11 14:52:36 +01002871 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2872 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2873
Takashi Iwai16ded522005-06-10 19:58:24 +02002874 { }
2875};
2876
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002877/*
2878 * ASUS pin configuration:
2879 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2880 */
2881static struct hda_verb alc880_pin_asus_init_verbs[] = {
2882 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2883 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2884 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2885 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2886
2887 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2888 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2889 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2890 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2891 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2894 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2895
2896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2897 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2899 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2900 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2902 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2903 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2904 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002905
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002906 { }
2907};
2908
2909/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002910#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2911#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02002912#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002913
Kailang Yangdf694da2005-12-05 19:42:22 +01002914/* Clevo m520g init */
2915static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2916 /* headphone output */
2917 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2918 /* line-out */
2919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2920 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921 /* Line-in */
2922 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2923 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 /* CD */
2925 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2926 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2927 /* Mic1 (rear panel) */
2928 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2929 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 /* Mic2 (front panel) */
2931 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2932 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2933 /* headphone */
2934 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2935 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2936 /* change to EAPD mode */
2937 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2938 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2939
2940 { }
2941};
2942
2943static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002944 /* change to EAPD mode */
2945 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2946 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2947
Kailang Yangdf694da2005-12-05 19:42:22 +01002948 /* Headphone output */
2949 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2950 /* Front output*/
2951 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2952 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2953
2954 /* Line In pin widget for input */
2955 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2956 /* CD pin widget for input */
2957 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2958 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2960
2961 /* change to EAPD mode */
2962 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2963 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2964
2965 { }
2966};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967
2968/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002969 * LG m1 express dual
2970 *
2971 * Pin assignment:
2972 * Rear Line-In/Out (blue): 0x14
2973 * Build-in Mic-In: 0x15
2974 * Speaker-out: 0x17
2975 * HP-Out (green): 0x1b
2976 * Mic-In/Out (red): 0x19
2977 * SPDIF-Out: 0x1e
2978 */
2979
2980/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2981static hda_nid_t alc880_lg_dac_nids[3] = {
2982 0x05, 0x02, 0x03
2983};
2984
2985/* seems analog CD is not working */
2986static struct hda_input_mux alc880_lg_capture_source = {
2987 .num_items = 3,
2988 .items = {
2989 { "Mic", 0x1 },
2990 { "Line", 0x5 },
2991 { "Internal Mic", 0x6 },
2992 },
2993};
2994
2995/* 2,4,6 channel modes */
2996static struct hda_verb alc880_lg_ch2_init[] = {
2997 /* set line-in and mic-in to input */
2998 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2999 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3000 { }
3001};
3002
3003static struct hda_verb alc880_lg_ch4_init[] = {
3004 /* set line-in to out and mic-in to input */
3005 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3006 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3007 { }
3008};
3009
3010static struct hda_verb alc880_lg_ch6_init[] = {
3011 /* set line-in and mic-in to output */
3012 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3013 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3014 { }
3015};
3016
3017static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3018 { 2, alc880_lg_ch2_init },
3019 { 4, alc880_lg_ch4_init },
3020 { 6, alc880_lg_ch6_init },
3021};
3022
3023static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003024 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3025 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003026 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3027 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3028 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3029 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3030 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3031 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3032 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3034 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3035 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3036 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3037 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3038 {
3039 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3040 .name = "Channel Mode",
3041 .info = alc_ch_mode_info,
3042 .get = alc_ch_mode_get,
3043 .put = alc_ch_mode_put,
3044 },
3045 { } /* end */
3046};
3047
3048static struct hda_verb alc880_lg_init_verbs[] = {
3049 /* set capture source to mic-in */
3050 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3052 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3053 /* mute all amp mixer inputs */
3054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003057 /* line-in to input */
3058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3059 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3060 /* built-in mic */
3061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063 /* speaker-out */
3064 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3065 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3066 /* mic-in to input */
3067 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3070 /* HP-out */
3071 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3073 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3074 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003075 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003076 { }
3077};
3078
3079/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003080static void alc880_lg_init_hook(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003081{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003082 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003083
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003084 spec->autocfg.hp_pins[0] = 0x1b;
3085 spec->autocfg.speaker_pins[0] = 0x17;
3086 alc_automute_amp(codec);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003087}
3088
3089/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003090 * LG LW20
3091 *
3092 * Pin assignment:
3093 * Speaker-out: 0x14
3094 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003095 * Built-in Mic-In: 0x19
3096 * Line-In: 0x1b
3097 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003098 * SPDIF-Out: 0x1e
3099 */
3100
Takashi Iwaid6815182006-03-23 16:06:23 +01003101static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003102 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003103 .items = {
3104 { "Mic", 0x0 },
3105 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003106 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003107 },
3108};
3109
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003110#define alc880_lg_lw_modes alc880_threestack_modes
3111
Takashi Iwaid6815182006-03-23 16:06:23 +01003112static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003113 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3114 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3115 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3116 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3117 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3118 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3119 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3120 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3121 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3122 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3125 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3126 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003127 {
3128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3129 .name = "Channel Mode",
3130 .info = alc_ch_mode_info,
3131 .get = alc_ch_mode_get,
3132 .put = alc_ch_mode_put,
3133 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003134 { } /* end */
3135};
3136
3137static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003138 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3139 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3140 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3141
Takashi Iwaid6815182006-03-23 16:06:23 +01003142 /* set capture source to mic-in */
3143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3144 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3145 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003147 /* speaker-out */
3148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3150 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003151 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3152 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3153 /* mic-in to input */
3154 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3155 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3156 /* built-in mic */
3157 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3158 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003160 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003161 { }
3162};
3163
3164/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003165static void alc880_lg_lw_init_hook(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003166{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003167 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003168
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003169 spec->autocfg.hp_pins[0] = 0x1b;
3170 spec->autocfg.speaker_pins[0] = 0x14;
3171 alc_automute_amp(codec);
Takashi Iwaid6815182006-03-23 16:06:23 +01003172}
3173
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003174static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3175 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3176 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3178 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3179 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3180 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3181 { } /* end */
3182};
3183
3184static struct hda_input_mux alc880_medion_rim_capture_source = {
3185 .num_items = 2,
3186 .items = {
3187 { "Mic", 0x0 },
3188 { "Internal Mic", 0x1 },
3189 },
3190};
3191
3192static struct hda_verb alc880_medion_rim_init_verbs[] = {
3193 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3194
3195 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3196 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3197
3198 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3199 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3201 /* Mic2 (as headphone out) for HP output */
3202 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3204 /* Internal Speaker */
3205 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3206 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3207
3208 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3209 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3210
3211 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3212 { }
3213};
3214
3215/* toggle speaker-output according to the hp-jack state */
3216static void alc880_medion_rim_automute(struct hda_codec *codec)
3217{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003218 struct alc_spec *spec = codec->spec;
3219 alc_automute_amp(codec);
3220 /* toggle EAPD */
3221 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003222 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3223 else
3224 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3225}
3226
3227static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3228 unsigned int res)
3229{
3230 /* Looks like the unsol event is incompatible with the standard
3231 * definition. 4bit tag is placed at 28 bit!
3232 */
3233 if ((res >> 28) == ALC880_HP_EVENT)
3234 alc880_medion_rim_automute(codec);
3235}
3236
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003237static void alc880_medion_rim_init_hook(struct hda_codec *codec)
3238{
3239 struct alc_spec *spec = codec->spec;
3240
3241 spec->autocfg.hp_pins[0] = 0x14;
3242 spec->autocfg.speaker_pins[0] = 0x1b;
3243 alc880_medion_rim_automute(codec);
3244}
3245
Takashi Iwaicb53c622007-08-10 17:21:45 +02003246#ifdef CONFIG_SND_HDA_POWER_SAVE
3247static struct hda_amp_list alc880_loopbacks[] = {
3248 { 0x0b, HDA_INPUT, 0 },
3249 { 0x0b, HDA_INPUT, 1 },
3250 { 0x0b, HDA_INPUT, 2 },
3251 { 0x0b, HDA_INPUT, 3 },
3252 { 0x0b, HDA_INPUT, 4 },
3253 { } /* end */
3254};
3255
3256static struct hda_amp_list alc880_lg_loopbacks[] = {
3257 { 0x0b, HDA_INPUT, 1 },
3258 { 0x0b, HDA_INPUT, 6 },
3259 { 0x0b, HDA_INPUT, 7 },
3260 { } /* end */
3261};
3262#endif
3263
Takashi Iwaid6815182006-03-23 16:06:23 +01003264/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003265 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003267
Linus Torvalds1da177e2005-04-16 15:20:36 -07003268static int alc_init(struct hda_codec *codec)
3269{
3270 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003271 unsigned int i;
3272
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003273 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003274 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003275
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 for (i = 0; i < spec->num_init_verbs; i++)
3277 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003278
3279 if (spec->init_hook)
3280 spec->init_hook(codec);
3281
Linus Torvalds1da177e2005-04-16 15:20:36 -07003282 return 0;
3283}
3284
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003285static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3286{
3287 struct alc_spec *spec = codec->spec;
3288
3289 if (spec->unsol_event)
3290 spec->unsol_event(codec, res);
3291}
3292
Takashi Iwaicb53c622007-08-10 17:21:45 +02003293#ifdef CONFIG_SND_HDA_POWER_SAVE
3294static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3295{
3296 struct alc_spec *spec = codec->spec;
3297 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3298}
3299#endif
3300
Linus Torvalds1da177e2005-04-16 15:20:36 -07003301/*
3302 * Analog playback callbacks
3303 */
3304static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3305 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003306 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307{
3308 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003309 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3310 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003311}
3312
3313static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3314 struct hda_codec *codec,
3315 unsigned int stream_tag,
3316 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003317 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003318{
3319 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003320 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3321 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003322}
3323
3324static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3325 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003326 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003327{
3328 struct alc_spec *spec = codec->spec;
3329 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3330}
3331
3332/*
3333 * Digital out
3334 */
3335static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3336 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003337 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003338{
3339 struct alc_spec *spec = codec->spec;
3340 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3341}
3342
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003343static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3344 struct hda_codec *codec,
3345 unsigned int stream_tag,
3346 unsigned int format,
3347 struct snd_pcm_substream *substream)
3348{
3349 struct alc_spec *spec = codec->spec;
3350 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3351 stream_tag, format, substream);
3352}
3353
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003354static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3355 struct hda_codec *codec,
3356 struct snd_pcm_substream *substream)
3357{
3358 struct alc_spec *spec = codec->spec;
3359 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3360}
3361
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3363 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003364 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003365{
3366 struct alc_spec *spec = codec->spec;
3367 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3368}
3369
3370/*
3371 * Analog capture
3372 */
Takashi Iwai63300792008-01-24 15:31:36 +01003373static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374 struct hda_codec *codec,
3375 unsigned int stream_tag,
3376 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003377 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003378{
3379 struct alc_spec *spec = codec->spec;
3380
Takashi Iwai63300792008-01-24 15:31:36 +01003381 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003382 stream_tag, 0, format);
3383 return 0;
3384}
3385
Takashi Iwai63300792008-01-24 15:31:36 +01003386static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003387 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003388 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003389{
3390 struct alc_spec *spec = codec->spec;
3391
Takashi Iwai888afa12008-03-18 09:57:50 +01003392 snd_hda_codec_cleanup_stream(codec,
3393 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394 return 0;
3395}
3396
3397
3398/*
3399 */
3400static struct hda_pcm_stream alc880_pcm_analog_playback = {
3401 .substreams = 1,
3402 .channels_min = 2,
3403 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003404 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003405 .ops = {
3406 .open = alc880_playback_pcm_open,
3407 .prepare = alc880_playback_pcm_prepare,
3408 .cleanup = alc880_playback_pcm_cleanup
3409 },
3410};
3411
3412static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003413 .substreams = 1,
3414 .channels_min = 2,
3415 .channels_max = 2,
3416 /* NID is set in alc_build_pcms */
3417};
3418
3419static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3420 .substreams = 1,
3421 .channels_min = 2,
3422 .channels_max = 2,
3423 /* NID is set in alc_build_pcms */
3424};
3425
3426static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3427 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428 .channels_min = 2,
3429 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003431 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003432 .prepare = alc880_alt_capture_pcm_prepare,
3433 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003434 },
3435};
3436
3437static struct hda_pcm_stream alc880_pcm_digital_playback = {
3438 .substreams = 1,
3439 .channels_min = 2,
3440 .channels_max = 2,
3441 /* NID is set in alc_build_pcms */
3442 .ops = {
3443 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003444 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003445 .prepare = alc880_dig_playback_pcm_prepare,
3446 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003447 },
3448};
3449
3450static struct hda_pcm_stream alc880_pcm_digital_capture = {
3451 .substreams = 1,
3452 .channels_min = 2,
3453 .channels_max = 2,
3454 /* NID is set in alc_build_pcms */
3455};
3456
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003457/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003458static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003459 .substreams = 0,
3460 .channels_min = 0,
3461 .channels_max = 0,
3462};
3463
Linus Torvalds1da177e2005-04-16 15:20:36 -07003464static int alc_build_pcms(struct hda_codec *codec)
3465{
3466 struct alc_spec *spec = codec->spec;
3467 struct hda_pcm *info = spec->pcm_rec;
3468 int i;
3469
3470 codec->num_pcms = 1;
3471 codec->pcm_info = info;
3472
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003473 if (spec->no_analog)
3474 goto skip_analog;
3475
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003476 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3477 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003478 info->name = spec->stream_name_analog;
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003479
Takashi Iwai4a471b72005-12-07 13:56:29 +01003480 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003481 if (snd_BUG_ON(!spec->multiout.dac_nids))
3482 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003483 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3484 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3485 }
3486 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003487 if (snd_BUG_ON(!spec->adc_nids))
3488 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003489 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3490 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492
Takashi Iwai4a471b72005-12-07 13:56:29 +01003493 if (spec->channel_mode) {
3494 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3495 for (i = 0; i < spec->num_channel_mode; i++) {
3496 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3497 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3498 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003499 }
3500 }
3501
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003502 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003503 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003504 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003505 snprintf(spec->stream_name_digital,
3506 sizeof(spec->stream_name_digital),
3507 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003508 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003509 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003510 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003511 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003512 if (spec->dig_out_type)
3513 info->pcm_type = spec->dig_out_type;
3514 else
3515 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003516 if (spec->multiout.dig_out_nid &&
3517 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003518 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3519 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3520 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003521 if (spec->dig_in_nid &&
3522 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3524 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3525 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003526 /* FIXME: do we need this for all Realtek codec models? */
3527 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003528 }
3529
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003530 if (spec->no_analog)
3531 return 0;
3532
Takashi Iwaie08a0072006-09-07 17:52:14 +02003533 /* If the use of more than one ADC is requested for the current
3534 * model, configure a second analog capture-only PCM.
3535 */
3536 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003537 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3538 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003539 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003540 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003541 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003542 if (spec->alt_dac_nid) {
3543 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3544 *spec->stream_analog_alt_playback;
3545 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3546 spec->alt_dac_nid;
3547 } else {
3548 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3549 alc_pcm_null_stream;
3550 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3551 }
3552 if (spec->num_adc_nids > 1) {
3553 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3554 *spec->stream_analog_alt_capture;
3555 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3556 spec->adc_nids[1];
3557 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3558 spec->num_adc_nids - 1;
3559 } else {
3560 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3561 alc_pcm_null_stream;
3562 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003563 }
3564 }
3565
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566 return 0;
3567}
3568
Takashi Iwai603c4012008-07-30 15:01:44 +02003569static void alc_free_kctls(struct hda_codec *codec)
3570{
3571 struct alc_spec *spec = codec->spec;
3572
3573 if (spec->kctls.list) {
3574 struct snd_kcontrol_new *kctl = spec->kctls.list;
3575 int i;
3576 for (i = 0; i < spec->kctls.used; i++)
3577 kfree(kctl[i].name);
3578 }
3579 snd_array_free(&spec->kctls);
3580}
3581
Linus Torvalds1da177e2005-04-16 15:20:36 -07003582static void alc_free(struct hda_codec *codec)
3583{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003584 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003586 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003587 return;
3588
Takashi Iwai603c4012008-07-30 15:01:44 +02003589 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003590 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003591 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003592}
3593
Takashi Iwaie044c392008-10-27 16:56:24 +01003594#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003595static int alc_resume(struct hda_codec *codec)
3596{
Takashi Iwaie044c392008-10-27 16:56:24 +01003597 codec->patch_ops.init(codec);
3598 snd_hda_codec_resume_amp(codec);
3599 snd_hda_codec_resume_cache(codec);
3600 return 0;
3601}
Takashi Iwaie044c392008-10-27 16:56:24 +01003602#endif
3603
Linus Torvalds1da177e2005-04-16 15:20:36 -07003604/*
3605 */
3606static struct hda_codec_ops alc_patch_ops = {
3607 .build_controls = alc_build_controls,
3608 .build_pcms = alc_build_pcms,
3609 .init = alc_init,
3610 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003611 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003612#ifdef SND_HDA_NEEDS_RESUME
3613 .resume = alc_resume,
3614#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003615#ifdef CONFIG_SND_HDA_POWER_SAVE
3616 .check_power_status = alc_check_power_status,
3617#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003618};
3619
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003620
3621/*
3622 * Test configuration for debugging
3623 *
3624 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3625 * enum controls.
3626 */
3627#ifdef CONFIG_SND_DEBUG
3628static hda_nid_t alc880_test_dac_nids[4] = {
3629 0x02, 0x03, 0x04, 0x05
3630};
3631
3632static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003633 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003634 .items = {
3635 { "In-1", 0x0 },
3636 { "In-2", 0x1 },
3637 { "In-3", 0x2 },
3638 { "In-4", 0x3 },
3639 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003640 { "Front", 0x5 },
3641 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003642 },
3643};
3644
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003645static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003646 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003647 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003648 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003649 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003650};
3651
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003652static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3653 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003654{
3655 static char *texts[] = {
3656 "N/A", "Line Out", "HP Out",
3657 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3658 };
3659 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3660 uinfo->count = 1;
3661 uinfo->value.enumerated.items = 8;
3662 if (uinfo->value.enumerated.item >= 8)
3663 uinfo->value.enumerated.item = 7;
3664 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3665 return 0;
3666}
3667
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003668static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3669 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003670{
3671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3672 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3673 unsigned int pin_ctl, item = 0;
3674
3675 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3676 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3677 if (pin_ctl & AC_PINCTL_OUT_EN) {
3678 if (pin_ctl & AC_PINCTL_HP_EN)
3679 item = 2;
3680 else
3681 item = 1;
3682 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3683 switch (pin_ctl & AC_PINCTL_VREFEN) {
3684 case AC_PINCTL_VREF_HIZ: item = 3; break;
3685 case AC_PINCTL_VREF_50: item = 4; break;
3686 case AC_PINCTL_VREF_GRD: item = 5; break;
3687 case AC_PINCTL_VREF_80: item = 6; break;
3688 case AC_PINCTL_VREF_100: item = 7; break;
3689 }
3690 }
3691 ucontrol->value.enumerated.item[0] = item;
3692 return 0;
3693}
3694
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003695static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3696 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003697{
3698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3699 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3700 static unsigned int ctls[] = {
3701 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3702 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3703 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3704 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3705 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3706 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3707 };
3708 unsigned int old_ctl, new_ctl;
3709
3710 old_ctl = snd_hda_codec_read(codec, nid, 0,
3711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3712 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3713 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003714 int val;
3715 snd_hda_codec_write_cache(codec, nid, 0,
3716 AC_VERB_SET_PIN_WIDGET_CONTROL,
3717 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003718 val = ucontrol->value.enumerated.item[0] >= 3 ?
3719 HDA_AMP_MUTE : 0;
3720 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3721 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003722 return 1;
3723 }
3724 return 0;
3725}
3726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003727static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3728 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003729{
3730 static char *texts[] = {
3731 "Front", "Surround", "CLFE", "Side"
3732 };
3733 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3734 uinfo->count = 1;
3735 uinfo->value.enumerated.items = 4;
3736 if (uinfo->value.enumerated.item >= 4)
3737 uinfo->value.enumerated.item = 3;
3738 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3739 return 0;
3740}
3741
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003742static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3743 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003744{
3745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3746 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3747 unsigned int sel;
3748
3749 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3750 ucontrol->value.enumerated.item[0] = sel & 3;
3751 return 0;
3752}
3753
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003754static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3755 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003756{
3757 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3758 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3759 unsigned int sel;
3760
3761 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3762 if (ucontrol->value.enumerated.item[0] != sel) {
3763 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003764 snd_hda_codec_write_cache(codec, nid, 0,
3765 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003766 return 1;
3767 }
3768 return 0;
3769}
3770
3771#define PIN_CTL_TEST(xname,nid) { \
3772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3773 .name = xname, \
3774 .info = alc_test_pin_ctl_info, \
3775 .get = alc_test_pin_ctl_get, \
3776 .put = alc_test_pin_ctl_put, \
3777 .private_value = nid \
3778 }
3779
3780#define PIN_SRC_TEST(xname,nid) { \
3781 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3782 .name = xname, \
3783 .info = alc_test_pin_src_info, \
3784 .get = alc_test_pin_src_get, \
3785 .put = alc_test_pin_src_put, \
3786 .private_value = nid \
3787 }
3788
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003789static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003790 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3791 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3792 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3793 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003794 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3795 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3796 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3797 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003798 PIN_CTL_TEST("Front Pin Mode", 0x14),
3799 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3800 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3801 PIN_CTL_TEST("Side Pin Mode", 0x17),
3802 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3803 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3804 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3805 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3806 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3807 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3808 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3809 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3810 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3811 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3812 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3813 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3814 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3815 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3816 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3817 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003820 {
3821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3822 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003823 .info = alc_ch_mode_info,
3824 .get = alc_ch_mode_get,
3825 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003826 },
3827 { } /* end */
3828};
3829
3830static struct hda_verb alc880_test_init_verbs[] = {
3831 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3837 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3839 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003840 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3844 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003845 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3849 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003850 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003851 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3853 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003855 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003856 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3857 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003858 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3859 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3860 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003861 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3864 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3865 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003866 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003867 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003868 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003869 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003870 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003871 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003872 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003873 /* Analog input/passthru */
3874 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3875 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3876 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3877 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003879 { }
3880};
3881#endif
3882
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883/*
3884 */
3885
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003886static const char *alc880_models[ALC880_MODEL_LAST] = {
3887 [ALC880_3ST] = "3stack",
3888 [ALC880_TCL_S700] = "tcl",
3889 [ALC880_3ST_DIG] = "3stack-digout",
3890 [ALC880_CLEVO] = "clevo",
3891 [ALC880_5ST] = "5stack",
3892 [ALC880_5ST_DIG] = "5stack-digout",
3893 [ALC880_W810] = "w810",
3894 [ALC880_Z71V] = "z71v",
3895 [ALC880_6ST] = "6stack",
3896 [ALC880_6ST_DIG] = "6stack-digout",
3897 [ALC880_ASUS] = "asus",
3898 [ALC880_ASUS_W1V] = "asus-w1v",
3899 [ALC880_ASUS_DIG] = "asus-dig",
3900 [ALC880_ASUS_DIG2] = "asus-dig2",
3901 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003902 [ALC880_UNIWILL_P53] = "uniwill-p53",
3903 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003904 [ALC880_F1734] = "F1734",
3905 [ALC880_LG] = "lg",
3906 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003907 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003908#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003909 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003910#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003911 [ALC880_AUTO] = "auto",
3912};
3913
3914static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003915 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003916 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3917 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3918 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3919 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3920 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3921 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3922 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3923 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003924 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3925 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003926 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3927 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3928 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3929 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3930 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3931 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3932 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3933 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3934 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3935 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003936 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003937 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3938 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3939 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003940 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003941 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003942 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3943 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003944 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3945 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003946 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3947 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3948 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3949 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003950 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3951 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003952 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003953 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003954 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003955 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003956 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3957 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003958 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003959 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003960 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003961 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003962 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003963 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003964 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003965 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003966 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003967 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3968 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003969 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003970 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3971 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3972 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3973 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003974 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3975 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003976 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003977 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003978 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3979 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003980 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3981 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3982 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01003983 /* default Intel */
3984 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003985 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3986 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 {}
3988};
3989
Takashi Iwai16ded522005-06-10 19:58:24 +02003990/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003991 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003992 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003993static struct alc_config_preset alc880_presets[] = {
3994 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003995 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003996 .init_verbs = { alc880_volume_init_verbs,
3997 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003998 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003999 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004000 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4001 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004002 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004003 .input_mux = &alc880_capture_source,
4004 },
4005 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004006 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004007 .init_verbs = { alc880_volume_init_verbs,
4008 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004009 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004010 .dac_nids = alc880_dac_nids,
4011 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004012 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4013 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004014 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004015 .input_mux = &alc880_capture_source,
4016 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004017 [ALC880_TCL_S700] = {
4018 .mixers = { alc880_tcl_s700_mixer },
4019 .init_verbs = { alc880_volume_init_verbs,
4020 alc880_pin_tcl_S700_init_verbs,
4021 alc880_gpio2_init_verbs },
4022 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4023 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004024 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4025 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004026 .hp_nid = 0x03,
4027 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4028 .channel_mode = alc880_2_jack_modes,
4029 .input_mux = &alc880_capture_source,
4030 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004031 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004032 .mixers = { alc880_three_stack_mixer,
4033 alc880_five_stack_mixer},
4034 .init_verbs = { alc880_volume_init_verbs,
4035 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004036 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4037 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004038 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4039 .channel_mode = alc880_fivestack_modes,
4040 .input_mux = &alc880_capture_source,
4041 },
4042 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004043 .mixers = { alc880_three_stack_mixer,
4044 alc880_five_stack_mixer },
4045 .init_verbs = { alc880_volume_init_verbs,
4046 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004047 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4048 .dac_nids = alc880_dac_nids,
4049 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004050 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4051 .channel_mode = alc880_fivestack_modes,
4052 .input_mux = &alc880_capture_source,
4053 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004054 [ALC880_6ST] = {
4055 .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 Iwaib6482d42005-06-27 15:32:43 +02004058 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4059 .dac_nids = alc880_6st_dac_nids,
4060 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4061 .channel_mode = alc880_sixstack_modes,
4062 .input_mux = &alc880_6stack_capture_source,
4063 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004064 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004065 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004066 .init_verbs = { alc880_volume_init_verbs,
4067 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004068 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4069 .dac_nids = alc880_6st_dac_nids,
4070 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004071 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4072 .channel_mode = alc880_sixstack_modes,
4073 .input_mux = &alc880_6stack_capture_source,
4074 },
4075 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004076 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004077 .init_verbs = { alc880_volume_init_verbs,
4078 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004079 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004080 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4081 .dac_nids = alc880_w810_dac_nids,
4082 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004083 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4084 .channel_mode = alc880_w810_modes,
4085 .input_mux = &alc880_capture_source,
4086 },
4087 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004088 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004089 .init_verbs = { alc880_volume_init_verbs,
4090 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004091 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4092 .dac_nids = alc880_z71v_dac_nids,
4093 .dig_out_nid = ALC880_DIGOUT_NID,
4094 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004095 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4096 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004097 .input_mux = &alc880_capture_source,
4098 },
4099 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004100 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004101 .init_verbs = { alc880_volume_init_verbs,
4102 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4104 .dac_nids = alc880_f1734_dac_nids,
4105 .hp_nid = 0x02,
4106 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4107 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004108 .input_mux = &alc880_f1734_capture_source,
4109 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004110 .init_hook = alc880_uniwill_p53_init_hook,
Takashi Iwai16ded522005-06-10 19:58:24 +02004111 },
4112 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004113 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004114 .init_verbs = { alc880_volume_init_verbs,
4115 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004116 alc880_gpio1_init_verbs },
4117 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4118 .dac_nids = alc880_asus_dac_nids,
4119 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4120 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004121 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004122 .input_mux = &alc880_capture_source,
4123 },
4124 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004125 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004126 .init_verbs = { alc880_volume_init_verbs,
4127 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004128 alc880_gpio1_init_verbs },
4129 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4130 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004131 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004132 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4133 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004134 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004135 .input_mux = &alc880_capture_source,
4136 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004137 [ALC880_ASUS_DIG2] = {
4138 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004139 .init_verbs = { alc880_volume_init_verbs,
4140 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004141 alc880_gpio2_init_verbs }, /* use GPIO2 */
4142 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4143 .dac_nids = alc880_asus_dac_nids,
4144 .dig_out_nid = ALC880_DIGOUT_NID,
4145 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4146 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004147 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004148 .input_mux = &alc880_capture_source,
4149 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004150 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004151 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004152 .init_verbs = { alc880_volume_init_verbs,
4153 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004154 alc880_gpio1_init_verbs },
4155 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4156 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004157 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004158 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4159 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004160 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004161 .input_mux = &alc880_capture_source,
4162 },
4163 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004164 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004165 .init_verbs = { alc880_volume_init_verbs,
4166 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004167 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4168 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004169 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4171 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004172 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004173 .input_mux = &alc880_capture_source,
4174 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004175 [ALC880_UNIWILL] = {
4176 .mixers = { alc880_uniwill_mixer },
4177 .init_verbs = { alc880_volume_init_verbs,
4178 alc880_uniwill_init_verbs },
4179 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4180 .dac_nids = alc880_asus_dac_nids,
4181 .dig_out_nid = ALC880_DIGOUT_NID,
4182 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4183 .channel_mode = alc880_threestack_modes,
4184 .need_dac_fix = 1,
4185 .input_mux = &alc880_capture_source,
4186 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004187 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004188 },
4189 [ALC880_UNIWILL_P53] = {
4190 .mixers = { alc880_uniwill_p53_mixer },
4191 .init_verbs = { alc880_volume_init_verbs,
4192 alc880_uniwill_p53_init_verbs },
4193 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4194 .dac_nids = alc880_asus_dac_nids,
4195 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004196 .channel_mode = alc880_threestack_modes,
4197 .input_mux = &alc880_capture_source,
4198 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004199 .init_hook = alc880_uniwill_p53_init_hook,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004200 },
4201 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004202 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004203 .init_verbs = { alc880_volume_init_verbs,
4204 alc880_uniwill_p53_init_verbs,
4205 alc880_beep_init_verbs },
4206 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4207 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004208 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004209 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4210 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004211 .input_mux = &alc880_capture_source,
4212 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004213 .init_hook = alc880_uniwill_p53_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004214 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004215 [ALC880_CLEVO] = {
4216 .mixers = { alc880_three_stack_mixer },
4217 .init_verbs = { alc880_volume_init_verbs,
4218 alc880_pin_clevo_init_verbs },
4219 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4220 .dac_nids = alc880_dac_nids,
4221 .hp_nid = 0x03,
4222 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4223 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004224 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004225 .input_mux = &alc880_capture_source,
4226 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004227 [ALC880_LG] = {
4228 .mixers = { alc880_lg_mixer },
4229 .init_verbs = { alc880_volume_init_verbs,
4230 alc880_lg_init_verbs },
4231 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4232 .dac_nids = alc880_lg_dac_nids,
4233 .dig_out_nid = ALC880_DIGOUT_NID,
4234 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4235 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004236 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004237 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004238 .unsol_event = alc_automute_amp_unsol_event,
4239 .init_hook = alc880_lg_init_hook,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004240#ifdef CONFIG_SND_HDA_POWER_SAVE
4241 .loopbacks = alc880_lg_loopbacks,
4242#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004243 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004244 [ALC880_LG_LW] = {
4245 .mixers = { alc880_lg_lw_mixer },
4246 .init_verbs = { alc880_volume_init_verbs,
4247 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004248 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004249 .dac_nids = alc880_dac_nids,
4250 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004251 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4252 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004253 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004254 .unsol_event = alc_automute_amp_unsol_event,
4255 .init_hook = alc880_lg_lw_init_hook,
Takashi Iwaid6815182006-03-23 16:06:23 +01004256 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004257 [ALC880_MEDION_RIM] = {
4258 .mixers = { alc880_medion_rim_mixer },
4259 .init_verbs = { alc880_volume_init_verbs,
4260 alc880_medion_rim_init_verbs,
4261 alc_gpio2_init_verbs },
4262 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4263 .dac_nids = alc880_dac_nids,
4264 .dig_out_nid = ALC880_DIGOUT_NID,
4265 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4266 .channel_mode = alc880_2_jack_modes,
4267 .input_mux = &alc880_medion_rim_capture_source,
4268 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004269 .init_hook = alc880_medion_rim_init_hook,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004270 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004271#ifdef CONFIG_SND_DEBUG
4272 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004273 .mixers = { alc880_test_mixer },
4274 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004275 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4276 .dac_nids = alc880_test_dac_nids,
4277 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004278 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4279 .channel_mode = alc880_test_modes,
4280 .input_mux = &alc880_test_capture_source,
4281 },
4282#endif
4283};
4284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004285/*
4286 * Automatic parse of I/O pins from the BIOS configuration
4287 */
4288
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004289enum {
4290 ALC_CTL_WIDGET_VOL,
4291 ALC_CTL_WIDGET_MUTE,
4292 ALC_CTL_BIND_MUTE,
4293};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004294static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004295 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4296 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004297 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298};
4299
4300/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004301static int add_control(struct alc_spec *spec, int type, const char *name,
4302 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004303{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004304 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004305
Takashi Iwai603c4012008-07-30 15:01:44 +02004306 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4307 knew = snd_array_new(&spec->kctls);
4308 if (!knew)
4309 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004310 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004311 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004312 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004313 return -ENOMEM;
4314 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004315 return 0;
4316}
4317
4318#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4319#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4320#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4321#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
4322#define alc880_is_input_pin(nid) ((nid) >= 0x18)
4323#define alc880_input_pin_idx(nid) ((nid) - 0x18)
4324#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4325#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4326#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4327#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4328#define ALC880_PIN_CD_NID 0x1c
4329
4330/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004331static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4332 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333{
4334 hda_nid_t nid;
4335 int assigned[4];
4336 int i, j;
4337
4338 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004339 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004340
4341 /* check the pins hardwired to audio widget */
4342 for (i = 0; i < cfg->line_outs; i++) {
4343 nid = cfg->line_out_pins[i];
4344 if (alc880_is_fixed_pin(nid)) {
4345 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004346 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004347 assigned[idx] = 1;
4348 }
4349 }
4350 /* left pins can be connect to any audio widget */
4351 for (i = 0; i < cfg->line_outs; i++) {
4352 nid = cfg->line_out_pins[i];
4353 if (alc880_is_fixed_pin(nid))
4354 continue;
4355 /* search for an empty channel */
4356 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004357 if (!assigned[j]) {
4358 spec->multiout.dac_nids[i] =
4359 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004360 assigned[j] = 1;
4361 break;
4362 }
4363 }
4364 }
4365 spec->multiout.num_dacs = cfg->line_outs;
4366 return 0;
4367}
4368
4369/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004370static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4371 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004372{
4373 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004374 static const char *chname[4] = {
4375 "Front", "Surround", NULL /*CLFE*/, "Side"
4376 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004377 hda_nid_t nid;
4378 int i, err;
4379
4380 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004381 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004382 continue;
4383 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4384 if (i == 2) {
4385 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004386 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4387 "Center Playback Volume",
4388 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4389 HDA_OUTPUT));
4390 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004391 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004392 err = add_control(spec, ALC_CTL_WIDGET_VOL,
4393 "LFE Playback Volume",
4394 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4395 HDA_OUTPUT));
4396 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004397 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004398 err = add_control(spec, ALC_CTL_BIND_MUTE,
4399 "Center Playback Switch",
4400 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4401 HDA_INPUT));
4402 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004403 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004404 err = add_control(spec, ALC_CTL_BIND_MUTE,
4405 "LFE Playback Switch",
4406 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4407 HDA_INPUT));
4408 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004409 return err;
4410 } else {
4411 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004412 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4413 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4414 HDA_OUTPUT));
4415 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004416 return err;
4417 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004418 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4419 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4420 HDA_INPUT));
4421 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004422 return err;
4423 }
4424 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425 return 0;
4426}
4427
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004428/* add playback controls for speaker and HP outputs */
4429static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4430 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004431{
4432 hda_nid_t nid;
4433 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004434 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004435
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004436 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004437 return 0;
4438
4439 if (alc880_is_fixed_pin(pin)) {
4440 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004441 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004442 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004443 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004444 else
4445 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004446 /* control HP volume/switch on the output mixer amp */
4447 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004448 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004449 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4450 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4451 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004452 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004453 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004454 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
4455 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4456 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457 return err;
4458 } else if (alc880_is_multi_pin(pin)) {
4459 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004461 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004462 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4463 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4464 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004465 return err;
4466 }
4467 return 0;
4468}
4469
4470/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004471static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4472 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004473 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474{
4475 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01004476 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477
4478 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
4480 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4481 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004482 return err;
4483 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004484 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
4485 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4486 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487 return err;
4488 return 0;
4489}
4490
4491/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01004492static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
4493 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004494{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004495 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004496 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004497
4498 for (i = 0; i < AUTO_PIN_LAST; i++) {
4499 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01004500 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01004501 err = new_analog_input(spec, cfg->input_pins[i],
4502 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01004503 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004504 if (err < 0)
4505 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004506 imux->items[imux->num_items].label =
4507 auto_pin_cfg_labels[i];
4508 imux->items[imux->num_items].index =
4509 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004510 imux->num_items++;
4511 }
4512 }
4513 return 0;
4514}
4515
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004516static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4517 unsigned int pin_type)
4518{
4519 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4520 pin_type);
4521 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004522 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4523 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004524}
4525
Kailang Yangdf694da2005-12-05 19:42:22 +01004526static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4527 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004528 int dac_idx)
4529{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004530 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531 /* need the manual connection? */
4532 if (alc880_is_multi_pin(nid)) {
4533 struct alc_spec *spec = codec->spec;
4534 int idx = alc880_multi_pin_idx(nid);
4535 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4536 AC_VERB_SET_CONNECT_SEL,
4537 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4538 }
4539}
4540
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004541static int get_pin_type(int line_out_type)
4542{
4543 if (line_out_type == AUTO_PIN_HP_OUT)
4544 return PIN_HP;
4545 else
4546 return PIN_OUT;
4547}
4548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549static void alc880_auto_init_multi_out(struct hda_codec *codec)
4550{
4551 struct alc_spec *spec = codec->spec;
4552 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004553
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004554 for (i = 0; i < spec->autocfg.line_outs; i++) {
4555 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004556 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4557 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558 }
4559}
4560
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004561static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004562{
4563 struct alc_spec *spec = codec->spec;
4564 hda_nid_t pin;
4565
Takashi Iwai82bc9552006-03-21 11:24:42 +01004566 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004567 if (pin) /* connect to front */
4568 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004569 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004570 if (pin) /* connect to front */
4571 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4572}
4573
4574static void alc880_auto_init_analog_input(struct hda_codec *codec)
4575{
4576 struct alc_spec *spec = codec->spec;
4577 int i;
4578
4579 for (i = 0; i < AUTO_PIN_LAST; i++) {
4580 hda_nid_t nid = spec->autocfg.input_pins[i];
4581 if (alc880_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004582 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004583 if (nid != ALC880_PIN_CD_NID &&
4584 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585 snd_hda_codec_write(codec, nid, 0,
4586 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 AMP_OUT_MUTE);
4588 }
4589 }
4590}
4591
4592/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004593/* return 1 if successful, 0 if the proper config is not found,
4594 * or a negative error code
4595 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004596static int alc880_parse_auto_config(struct hda_codec *codec)
4597{
4598 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004599 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004600 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004601
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004602 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4603 alc880_ignore);
4604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004606 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004607 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004608
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004609 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4610 if (err < 0)
4611 return err;
4612 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4613 if (err < 0)
4614 return err;
4615 err = alc880_auto_create_extra_out(spec,
4616 spec->autocfg.speaker_pins[0],
4617 "Speaker");
4618 if (err < 0)
4619 return err;
4620 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4621 "Headphone");
4622 if (err < 0)
4623 return err;
4624 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4625 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004626 return err;
4627
4628 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4629
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004630 /* check multiple SPDIF-out (for recent codecs) */
4631 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4632 hda_nid_t dig_nid;
4633 err = snd_hda_get_connections(codec,
4634 spec->autocfg.dig_out_pins[i],
4635 &dig_nid, 1);
4636 if (err < 0)
4637 continue;
4638 if (!i)
4639 spec->multiout.dig_out_nid = dig_nid;
4640 else {
4641 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
4642 spec->slave_dig_outs[i - 1] = dig_nid;
4643 if (i == ARRAY_SIZE(spec->slave_dig_outs) - 1)
4644 break;
4645 }
4646 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004647 if (spec->autocfg.dig_in_pin)
4648 spec->dig_in_nid = ALC880_DIGIN_NID;
4649
Takashi Iwai603c4012008-07-30 15:01:44 +02004650 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004651 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652
Takashi Iwaid88897e2008-10-31 15:01:37 +01004653 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004655 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004656 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004657
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004658 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
4659
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660 return 1;
4661}
4662
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004663/* additional initialization for auto-configuration model */
4664static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004666 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004667 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004668 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004670 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004671 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004672}
4673
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004674static void set_capture_mixer(struct alc_spec *spec)
4675{
Takashi Iwaia23b6882009-03-23 15:21:36 +01004676 static struct snd_kcontrol_new *caps[2][3] = {
4677 { alc_capture_mixer_nosrc1,
4678 alc_capture_mixer_nosrc2,
4679 alc_capture_mixer_nosrc3 },
4680 { alc_capture_mixer1,
4681 alc_capture_mixer2,
4682 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004683 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004684 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
4685 int mux;
Takashi Iwai6c819492009-08-10 18:47:44 +02004686 if (spec->input_mux && spec->input_mux->num_items > 1 &&
4687 !spec->auto_mic)
Takashi Iwaia23b6882009-03-23 15:21:36 +01004688 mux = 1;
4689 else
4690 mux = 0;
4691 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4692 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004693}
4694
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004695#define set_beep_amp(spec, nid, idx, dir) \
4696 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
4697
4698/*
4699 * OK, here we have finally the patch for ALC880
4700 */
4701
Linus Torvalds1da177e2005-04-16 15:20:36 -07004702static int patch_alc880(struct hda_codec *codec)
4703{
4704 struct alc_spec *spec;
4705 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004707
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004708 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004709 if (spec == NULL)
4710 return -ENOMEM;
4711
4712 codec->spec = spec;
4713
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004714 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4715 alc880_models,
4716 alc880_cfg_tbl);
4717 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02004718 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4719 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004721 }
4722
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723 if (board_config == ALC880_AUTO) {
4724 /* automatic parse from the BIOS config */
4725 err = alc880_parse_auto_config(codec);
4726 if (err < 0) {
4727 alc_free(codec);
4728 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004729 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004730 printk(KERN_INFO
4731 "hda_codec: Cannot set up configuration "
4732 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004733 board_config = ALC880_3ST;
4734 }
4735 }
4736
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004737 err = snd_hda_attach_beep_device(codec, 0x1);
4738 if (err < 0) {
4739 alc_free(codec);
4740 return err;
4741 }
4742
Kailang Yangdf694da2005-12-05 19:42:22 +01004743 if (board_config != ALC880_AUTO)
4744 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004745
Linus Torvalds1da177e2005-04-16 15:20:36 -07004746 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4747 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004748 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004749
Linus Torvalds1da177e2005-04-16 15:20:36 -07004750 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4751 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4752
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004753 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004754 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004755 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004756 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02004757 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004758 if (wcap != AC_WID_AUD_IN) {
4759 spec->adc_nids = alc880_adc_nids_alt;
4760 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004761 } else {
4762 spec->adc_nids = alc880_adc_nids;
4763 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764 }
4765 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004766 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004767 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004768
Takashi Iwai2134ea42008-01-10 16:53:55 +01004769 spec->vmaster_nid = 0x0c;
4770
Linus Torvalds1da177e2005-04-16 15:20:36 -07004771 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004772 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004773 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004774#ifdef CONFIG_SND_HDA_POWER_SAVE
4775 if (!spec->loopback.amplist)
4776 spec->loopback.amplist = alc880_loopbacks;
4777#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01004778 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004779
4780 return 0;
4781}
4782
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783
Linus Torvalds1da177e2005-04-16 15:20:36 -07004784/*
4785 * ALC260 support
4786 */
4787
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004788static hda_nid_t alc260_dac_nids[1] = {
4789 /* front */
4790 0x02,
4791};
4792
4793static hda_nid_t alc260_adc_nids[1] = {
4794 /* ADC0 */
4795 0x04,
4796};
4797
Kailang Yangdf694da2005-12-05 19:42:22 +01004798static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799 /* ADC1 */
4800 0x05,
4801};
4802
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004803/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4804 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4805 */
4806static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004807 /* ADC0, ADC1 */
4808 0x04, 0x05
4809};
4810
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004811#define ALC260_DIGOUT_NID 0x03
4812#define ALC260_DIGIN_NID 0x06
4813
4814static struct hda_input_mux alc260_capture_source = {
4815 .num_items = 4,
4816 .items = {
4817 { "Mic", 0x0 },
4818 { "Front Mic", 0x1 },
4819 { "Line", 0x2 },
4820 { "CD", 0x4 },
4821 },
4822};
4823
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004824/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004825 * headphone jack and the internal CD lines since these are the only pins at
4826 * which audio can appear. For flexibility, also allow the option of
4827 * recording the mixer output on the second ADC (ADC0 doesn't have a
4828 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004829 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004830static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4831 {
4832 .num_items = 3,
4833 .items = {
4834 { "Mic/Line", 0x0 },
4835 { "CD", 0x4 },
4836 { "Headphone", 0x2 },
4837 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004838 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004839 {
4840 .num_items = 4,
4841 .items = {
4842 { "Mic/Line", 0x0 },
4843 { "CD", 0x4 },
4844 { "Headphone", 0x2 },
4845 { "Mixer", 0x5 },
4846 },
4847 },
4848
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004849};
4850
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004851/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4852 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004853 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004854static struct hda_input_mux alc260_acer_capture_sources[2] = {
4855 {
4856 .num_items = 4,
4857 .items = {
4858 { "Mic", 0x0 },
4859 { "Line", 0x2 },
4860 { "CD", 0x4 },
4861 { "Headphone", 0x5 },
4862 },
4863 },
4864 {
4865 .num_items = 5,
4866 .items = {
4867 { "Mic", 0x0 },
4868 { "Line", 0x2 },
4869 { "CD", 0x4 },
4870 { "Headphone", 0x6 },
4871 { "Mixer", 0x5 },
4872 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004873 },
4874};
Michael Schwingencc959482009-02-22 18:58:45 +01004875
4876/* Maxdata Favorit 100XS */
4877static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
4878 {
4879 .num_items = 2,
4880 .items = {
4881 { "Line/Mic", 0x0 },
4882 { "CD", 0x4 },
4883 },
4884 },
4885 {
4886 .num_items = 3,
4887 .items = {
4888 { "Line/Mic", 0x0 },
4889 { "CD", 0x4 },
4890 { "Mixer", 0x5 },
4891 },
4892 },
4893};
4894
Linus Torvalds1da177e2005-04-16 15:20:36 -07004895/*
4896 * This is just place-holder, so there's something for alc_build_pcms to look
4897 * at when it calculates the maximum number of channels. ALC260 has no mixer
4898 * element which allows changing the channel mode, so the verb list is
4899 * never used.
4900 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004901static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004902 { 2, NULL },
4903};
4904
Kailang Yangdf694da2005-12-05 19:42:22 +01004905
4906/* Mixer combinations
4907 *
4908 * basic: base_output + input + pc_beep + capture
4909 * HP: base_output + input + capture_alt
4910 * HP_3013: hp_3013 + input + capture
4911 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004912 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004913 */
4914
4915static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004916 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004917 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4919 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4920 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4921 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4922 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004923};
Kailang Yangdf694da2005-12-05 19:42:22 +01004924
4925static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004926 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4927 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4928 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4929 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4931 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4932 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4933 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004934 { } /* end */
4935};
4936
Takashi Iwaibec15c32008-01-28 18:16:30 +01004937/* update HP, line and mono out pins according to the master switch */
4938static void alc260_hp_master_update(struct hda_codec *codec,
4939 hda_nid_t hp, hda_nid_t line,
4940 hda_nid_t mono)
4941{
4942 struct alc_spec *spec = codec->spec;
4943 unsigned int val = spec->master_sw ? PIN_HP : 0;
4944 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004945 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004946 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004947 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004948 val);
4949 /* mono (speaker) depending on the HP jack sense */
4950 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004951 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004952 val);
4953}
4954
4955static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4956 struct snd_ctl_elem_value *ucontrol)
4957{
4958 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4959 struct alc_spec *spec = codec->spec;
4960 *ucontrol->value.integer.value = spec->master_sw;
4961 return 0;
4962}
4963
4964static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4965 struct snd_ctl_elem_value *ucontrol)
4966{
4967 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4968 struct alc_spec *spec = codec->spec;
4969 int val = !!*ucontrol->value.integer.value;
4970 hda_nid_t hp, line, mono;
4971
4972 if (val == spec->master_sw)
4973 return 0;
4974 spec->master_sw = val;
4975 hp = (kcontrol->private_value >> 16) & 0xff;
4976 line = (kcontrol->private_value >> 8) & 0xff;
4977 mono = kcontrol->private_value & 0xff;
4978 alc260_hp_master_update(codec, hp, line, mono);
4979 return 1;
4980}
4981
4982static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4983 {
4984 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4985 .name = "Master Playback Switch",
4986 .info = snd_ctl_boolean_mono_info,
4987 .get = alc260_hp_master_sw_get,
4988 .put = alc260_hp_master_sw_put,
4989 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4990 },
4991 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4992 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4993 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4994 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4995 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4996 HDA_OUTPUT),
4997 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4998 { } /* end */
4999};
5000
5001static struct hda_verb alc260_hp_unsol_verbs[] = {
5002 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5003 {},
5004};
5005
5006static void alc260_hp_automute(struct hda_codec *codec)
5007{
5008 struct alc_spec *spec = codec->spec;
5009 unsigned int present;
5010
5011 present = snd_hda_codec_read(codec, 0x10, 0,
5012 AC_VERB_GET_PIN_SENSE, 0);
5013 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
5014 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5015}
5016
5017static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5018{
5019 if ((res >> 26) == ALC880_HP_EVENT)
5020 alc260_hp_automute(codec);
5021}
5022
Kailang Yangdf694da2005-12-05 19:42:22 +01005023static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005024 {
5025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5026 .name = "Master Playback Switch",
5027 .info = snd_ctl_boolean_mono_info,
5028 .get = alc260_hp_master_sw_get,
5029 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005030 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005031 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005032 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5033 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5034 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5035 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5036 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5037 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005038 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5039 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005040 { } /* end */
5041};
5042
Kailang Yang3f878302008-08-26 13:02:23 +02005043static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5044 .ops = &snd_hda_bind_vol,
5045 .values = {
5046 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5047 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5048 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5049 0
5050 },
5051};
5052
5053static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5054 .ops = &snd_hda_bind_sw,
5055 .values = {
5056 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5057 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5058 0
5059 },
5060};
5061
5062static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5063 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5064 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5065 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5067 { } /* end */
5068};
5069
Takashi Iwaibec15c32008-01-28 18:16:30 +01005070static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5072 {},
5073};
5074
5075static void alc260_hp_3013_automute(struct hda_codec *codec)
5076{
5077 struct alc_spec *spec = codec->spec;
5078 unsigned int present;
5079
5080 present = snd_hda_codec_read(codec, 0x15, 0,
5081 AC_VERB_GET_PIN_SENSE, 0);
5082 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005083 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005084}
5085
5086static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5087 unsigned int res)
5088{
5089 if ((res >> 26) == ALC880_HP_EVENT)
5090 alc260_hp_3013_automute(codec);
5091}
5092
Kailang Yang3f878302008-08-26 13:02:23 +02005093static void alc260_hp_3012_automute(struct hda_codec *codec)
5094{
5095 unsigned int present, bits;
5096
5097 present = snd_hda_codec_read(codec, 0x10, 0,
5098 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
5099
5100 bits = present ? 0 : PIN_OUT;
5101 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5102 bits);
5103 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5104 bits);
5105 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5106 bits);
5107}
5108
5109static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5110 unsigned int res)
5111{
5112 if ((res >> 26) == ALC880_HP_EVENT)
5113 alc260_hp_3012_automute(codec);
5114}
5115
5116/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005117 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5118 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005119static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005120 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005121 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005122 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005123 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5124 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5125 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5126 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005127 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005128 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5129 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005130 { } /* end */
5131};
5132
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005133/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5134 * versions of the ALC260 don't act on requests to enable mic bias from NID
5135 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5136 * datasheet doesn't mention this restriction. At this stage it's not clear
5137 * whether this behaviour is intentional or is a hardware bug in chip
5138 * revisions available in early 2006. Therefore for now allow the
5139 * "Headphone Jack Mode" control to span all choices, but if it turns out
5140 * that the lack of mic bias for this NID is intentional we could change the
5141 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5142 *
5143 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5144 * don't appear to make the mic bias available from the "line" jack, even
5145 * though the NID used for this jack (0x14) can supply it. The theory is
5146 * that perhaps Acer have included blocking capacitors between the ALC260
5147 * and the output jack. If this turns out to be the case for all such
5148 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5149 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005150 *
5151 * The C20x Tablet series have a mono internal speaker which is controlled
5152 * via the chip's Mono sum widget and pin complex, so include the necessary
5153 * controls for such models. On models without a "mono speaker" the control
5154 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005155 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005156static struct snd_kcontrol_new alc260_acer_mixer[] = {
5157 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5158 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005159 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005160 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005161 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005162 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005163 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005164 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5165 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5167 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5168 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5169 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5170 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5171 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005172 { } /* end */
5173};
5174
Michael Schwingencc959482009-02-22 18:58:45 +01005175/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5176 */
5177static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5178 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5179 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5180 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5181 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5182 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5183 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5184 { } /* end */
5185};
5186
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005187/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5188 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5189 */
5190static struct snd_kcontrol_new alc260_will_mixer[] = {
5191 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5192 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5193 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5194 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5195 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5196 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5197 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5198 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5199 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5200 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005201 { } /* end */
5202};
5203
5204/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5205 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5206 */
5207static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5208 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5209 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5211 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5212 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5213 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5214 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5215 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5216 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5217 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5218 { } /* end */
5219};
5220
Kailang Yangdf694da2005-12-05 19:42:22 +01005221/*
5222 * initialization verbs
5223 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005224static struct hda_verb alc260_init_verbs[] = {
5225 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005227 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005228 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005229 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005230 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005231 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005232 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005233 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005235 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005236 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005237 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005238 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005239 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005240 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005241 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005242 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5243 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005244 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005245 /* set connection select to line in (default select for this ADC) */
5246 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005247 /* mute capture amp left and right */
5248 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5249 /* set connection select to line in (default select for this ADC) */
5250 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005251 /* set vol=0 Line-Out mixer amp left and right */
5252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5253 /* unmute pin widget amp left and right (no gain on this amp) */
5254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5255 /* set vol=0 HP mixer amp left and right */
5256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5257 /* unmute pin widget amp left and right (no gain on this amp) */
5258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5259 /* set vol=0 Mono mixer amp left and right */
5260 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5261 /* unmute pin widget amp left and right (no gain on this amp) */
5262 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5263 /* unmute LINE-2 out pin */
5264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005265 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5266 * Line In 2 = 0x03
5267 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005268 /* mute analog inputs */
5269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5272 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5273 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005274 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005275 /* mute Front out path */
5276 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5277 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5278 /* mute Headphone out path */
5279 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5280 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5281 /* mute Mono out path */
5282 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5283 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005284 { }
5285};
5286
Takashi Iwai474167d2006-05-17 17:17:43 +02005287#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005288static struct hda_verb alc260_hp_init_verbs[] = {
5289 /* Headphone and output */
5290 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5291 /* mono output */
5292 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5293 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5294 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5295 /* Mic2 (front panel) pin widget for input and vref at 80% */
5296 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5297 /* Line In pin widget for input */
5298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5299 /* Line-2 pin widget for output */
5300 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5301 /* CD pin widget for input */
5302 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5303 /* unmute amp left and right */
5304 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5305 /* set connection select to line in (default select for this ADC) */
5306 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5307 /* unmute Line-Out mixer amp left and right (volume = 0) */
5308 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5309 /* mute pin widget amp left and right (no gain on this amp) */
5310 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5311 /* unmute HP mixer amp left and right (volume = 0) */
5312 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5313 /* mute pin widget amp left and right (no gain on this amp) */
5314 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005315 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5316 * Line In 2 = 0x03
5317 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005318 /* mute analog inputs */
5319 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5321 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5322 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5323 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005324 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5325 /* Unmute Front out path */
5326 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5327 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5328 /* Unmute Headphone out path */
5329 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5330 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5331 /* Unmute Mono out path */
5332 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5333 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5334 { }
5335};
Takashi Iwai474167d2006-05-17 17:17:43 +02005336#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005337
5338static struct hda_verb alc260_hp_3013_init_verbs[] = {
5339 /* Line out and output */
5340 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5341 /* mono output */
5342 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5343 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5344 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5345 /* Mic2 (front panel) pin widget for input and vref at 80% */
5346 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5347 /* Line In pin widget for input */
5348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5349 /* Headphone pin widget for output */
5350 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5351 /* CD pin widget for input */
5352 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5353 /* unmute amp left and right */
5354 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5355 /* set connection select to line in (default select for this ADC) */
5356 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5357 /* unmute Line-Out mixer amp left and right (volume = 0) */
5358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5359 /* mute pin widget amp left and right (no gain on this amp) */
5360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5361 /* unmute HP mixer amp left and right (volume = 0) */
5362 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5363 /* mute pin widget amp left and right (no gain on this amp) */
5364 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005365 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5366 * Line In 2 = 0x03
5367 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005368 /* mute analog inputs */
5369 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5370 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5371 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005374 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5375 /* Unmute Front out path */
5376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5378 /* Unmute Headphone out path */
5379 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5380 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5381 /* Unmute Mono out path */
5382 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5383 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5384 { }
5385};
5386
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005387/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005388 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5389 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005390 */
5391static struct hda_verb alc260_fujitsu_init_verbs[] = {
5392 /* Disable all GPIOs */
5393 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5394 /* Internal speaker is connected to headphone pin */
5395 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5396 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5397 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005398 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5399 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5400 /* Ensure all other unused pins are disabled and muted. */
5401 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5402 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005403 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005404 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005405 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005406 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5407 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5408 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005409
Jonathan Woithef7ace402006-02-28 11:46:14 +01005410 /* Disable digital (SPDIF) pins */
5411 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5412 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005413
Kailang Yangea1fb292008-08-26 12:58:38 +02005414 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005415 * when acting as an output.
5416 */
5417 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5418
5419 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005420 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5423 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5426 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005429
Jonathan Woithef7ace402006-02-28 11:46:14 +01005430 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5431 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5432 /* Unmute Line1 pin widget output buffer since it starts as an output.
5433 * If the pin mode is changed by the user the pin mode control will
5434 * take care of enabling the pin's input/output buffers as needed.
5435 * Therefore there's no need to enable the input buffer at this
5436 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005437 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005438 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005439 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005440 * mixer ctrl)
5441 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005442 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005443
Jonathan Woithef7ace402006-02-28 11:46:14 +01005444 /* Mute capture amp left and right */
5445 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005446 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005447 * in (on mic1 pin)
5448 */
5449 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005450
Jonathan Woithef7ace402006-02-28 11:46:14 +01005451 /* Do the same for the second ADC: mute capture input amp and
5452 * set ADC connection to line in (on mic1 pin)
5453 */
5454 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5455 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005456
Jonathan Woithef7ace402006-02-28 11:46:14 +01005457 /* Mute all inputs to mixer widget (even unconnected ones) */
5458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5459 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005466
5467 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005468};
5469
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005470/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5471 * similar laptops (adapted from Fujitsu init verbs).
5472 */
5473static struct hda_verb alc260_acer_init_verbs[] = {
5474 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5475 * the headphone jack. Turn this on and rely on the standard mute
5476 * methods whenever the user wants to turn these outputs off.
5477 */
5478 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5479 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5480 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5481 /* Internal speaker/Headphone jack is connected to Line-out pin */
5482 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5483 /* Internal microphone/Mic jack is connected to Mic1 pin */
5484 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5485 /* Line In jack is connected to Line1 pin */
5486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005487 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5488 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005489 /* Ensure all other unused pins are disabled and muted. */
5490 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5491 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005492 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5493 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5496 /* Disable digital (SPDIF) pins */
5497 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5498 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5499
Kailang Yangea1fb292008-08-26 12:58:38 +02005500 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005501 * bus when acting as outputs.
5502 */
5503 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5504 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5505
5506 /* Start with output sum widgets muted and their output gains at min */
5507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5513 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5514 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5515 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5516
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005517 /* Unmute Line-out pin widget amp left and right
5518 * (no equiv mixer ctrl)
5519 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005521 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5522 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005523 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5524 * inputs. If the pin mode is changed by the user the pin mode control
5525 * will take care of enabling the pin's input/output buffers as needed.
5526 * Therefore there's no need to enable the input buffer at this
5527 * stage.
5528 */
5529 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5531
5532 /* Mute capture amp left and right */
5533 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5534 /* Set ADC connection select to match default mixer setting - mic
5535 * (on mic1 pin)
5536 */
5537 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5538
5539 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005540 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005541 */
5542 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005543 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005544
5545 /* Mute all inputs to mixer widget (even unconnected ones) */
5546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5551 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5554
5555 { }
5556};
5557
Michael Schwingencc959482009-02-22 18:58:45 +01005558/* Initialisation sequence for Maxdata Favorit 100XS
5559 * (adapted from Acer init verbs).
5560 */
5561static struct hda_verb alc260_favorit100_init_verbs[] = {
5562 /* GPIO 0 enables the output jack.
5563 * Turn this on and rely on the standard mute
5564 * methods whenever the user wants to turn these outputs off.
5565 */
5566 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5567 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5568 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5569 /* Line/Mic input jack is connected to Mic1 pin */
5570 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5571 /* Ensure all other unused pins are disabled and muted. */
5572 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5573 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5574 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5575 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5576 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5577 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5579 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5582 /* Disable digital (SPDIF) pins */
5583 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5584 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5585
5586 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5587 * bus when acting as outputs.
5588 */
5589 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5590 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5591
5592 /* Start with output sum widgets muted and their output gains at min */
5593 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5597 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5599 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5600 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5601 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5602
5603 /* Unmute Line-out pin widget amp left and right
5604 * (no equiv mixer ctrl)
5605 */
5606 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5607 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5608 * inputs. If the pin mode is changed by the user the pin mode control
5609 * will take care of enabling the pin's input/output buffers as needed.
5610 * Therefore there's no need to enable the input buffer at this
5611 * stage.
5612 */
5613 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5614
5615 /* Mute capture amp left and right */
5616 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5617 /* Set ADC connection select to match default mixer setting - mic
5618 * (on mic1 pin)
5619 */
5620 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5621
5622 /* Do similar with the second ADC: mute capture input amp and
5623 * set ADC connection to mic to match ALSA's default state.
5624 */
5625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5626 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5627
5628 /* Mute all inputs to mixer widget (even unconnected ones) */
5629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5630 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5631 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5632 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5633 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5636 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5637
5638 { }
5639};
5640
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005641static struct hda_verb alc260_will_verbs[] = {
5642 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5643 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5644 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5645 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5646 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5647 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5648 {}
5649};
5650
5651static struct hda_verb alc260_replacer_672v_verbs[] = {
5652 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5653 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5654 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5655
5656 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5657 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5658 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5659
5660 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5661 {}
5662};
5663
5664/* toggle speaker-output according to the hp-jack state */
5665static void alc260_replacer_672v_automute(struct hda_codec *codec)
5666{
5667 unsigned int present;
5668
5669 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
5670 present = snd_hda_codec_read(codec, 0x0f, 0,
5671 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5672 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005673 snd_hda_codec_write_cache(codec, 0x01, 0,
5674 AC_VERB_SET_GPIO_DATA, 1);
5675 snd_hda_codec_write_cache(codec, 0x0f, 0,
5676 AC_VERB_SET_PIN_WIDGET_CONTROL,
5677 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005678 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005679 snd_hda_codec_write_cache(codec, 0x01, 0,
5680 AC_VERB_SET_GPIO_DATA, 0);
5681 snd_hda_codec_write_cache(codec, 0x0f, 0,
5682 AC_VERB_SET_PIN_WIDGET_CONTROL,
5683 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005684 }
5685}
5686
5687static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5688 unsigned int res)
5689{
5690 if ((res >> 26) == ALC880_HP_EVENT)
5691 alc260_replacer_672v_automute(codec);
5692}
5693
Kailang Yang3f878302008-08-26 13:02:23 +02005694static struct hda_verb alc260_hp_dc7600_verbs[] = {
5695 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5697 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5698 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5699 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5700 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5701 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5702 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5703 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5704 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5705 {}
5706};
5707
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005708/* Test configuration for debugging, modelled after the ALC880 test
5709 * configuration.
5710 */
5711#ifdef CONFIG_SND_DEBUG
5712static hda_nid_t alc260_test_dac_nids[1] = {
5713 0x02,
5714};
5715static hda_nid_t alc260_test_adc_nids[2] = {
5716 0x04, 0x05,
5717};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005718/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005719 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005720 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005721 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005722static struct hda_input_mux alc260_test_capture_sources[2] = {
5723 {
5724 .num_items = 7,
5725 .items = {
5726 { "MIC1 pin", 0x0 },
5727 { "MIC2 pin", 0x1 },
5728 { "LINE1 pin", 0x2 },
5729 { "LINE2 pin", 0x3 },
5730 { "CD pin", 0x4 },
5731 { "LINE-OUT pin", 0x5 },
5732 { "HP-OUT pin", 0x6 },
5733 },
5734 },
5735 {
5736 .num_items = 8,
5737 .items = {
5738 { "MIC1 pin", 0x0 },
5739 { "MIC2 pin", 0x1 },
5740 { "LINE1 pin", 0x2 },
5741 { "LINE2 pin", 0x3 },
5742 { "CD pin", 0x4 },
5743 { "Mixer", 0x5 },
5744 { "LINE-OUT pin", 0x6 },
5745 { "HP-OUT pin", 0x7 },
5746 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005747 },
5748};
5749static struct snd_kcontrol_new alc260_test_mixer[] = {
5750 /* Output driver widgets */
5751 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5752 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5753 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5754 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5755 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5756 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5757
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005758 /* Modes for retasking pin widgets
5759 * Note: the ALC260 doesn't seem to act on requests to enable mic
5760 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5761 * mention this restriction. At this stage it's not clear whether
5762 * this behaviour is intentional or is a hardware bug in chip
5763 * revisions available at least up until early 2006. Therefore for
5764 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5765 * choices, but if it turns out that the lack of mic bias for these
5766 * NIDs is intentional we could change their modes from
5767 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5768 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005769 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5770 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5771 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5772 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5773 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5774 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5775
5776 /* Loopback mixer controls */
5777 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5778 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5779 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5780 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5781 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5782 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5783 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5784 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5785 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5786 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005787 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5788 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5789 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5790 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005791
5792 /* Controls for GPIO pins, assuming they are configured as outputs */
5793 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5794 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5795 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5796 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5797
Jonathan Woithe92621f12006-02-28 11:47:47 +01005798 /* Switches to allow the digital IO pins to be enabled. The datasheet
5799 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005800 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005801 */
5802 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5803 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5804
Jonathan Woithef8225f62008-01-08 12:16:54 +01005805 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5806 * this output to turn on an external amplifier.
5807 */
5808 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5809 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5810
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005811 { } /* end */
5812};
5813static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005814 /* Enable all GPIOs as outputs with an initial value of 0 */
5815 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5816 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5817 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5818
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005819 /* Enable retasking pins as output, initially without power amp */
5820 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5821 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5824 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5825 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5826
Jonathan Woithe92621f12006-02-28 11:47:47 +01005827 /* Disable digital (SPDIF) pins initially, but users can enable
5828 * them via a mixer switch. In the case of SPDIF-out, this initverb
5829 * payload also sets the generation to 0, output to be in "consumer"
5830 * PCM format, copyright asserted, no pre-emphasis and no validity
5831 * control.
5832 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005833 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5834 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5835
Kailang Yangea1fb292008-08-26 12:58:38 +02005836 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005837 * OUT1 sum bus when acting as an output.
5838 */
5839 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5840 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5841 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5842 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5843
5844 /* Start with output sum widgets muted and their output gains at min */
5845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5846 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5847 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5849 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5851 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5852 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5853 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5854
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005855 /* Unmute retasking pin widget output buffers since the default
5856 * state appears to be output. As the pin mode is changed by the
5857 * user the pin mode control will take care of enabling the pin's
5858 * input/output buffers as needed.
5859 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005860 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5861 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5862 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5863 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5864 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5865 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5866 /* Also unmute the mono-out pin widget */
5867 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5868
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005869 /* Mute capture amp left and right */
5870 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005871 /* Set ADC connection select to match default mixer setting (mic1
5872 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005873 */
5874 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5875
5876 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005877 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005878 */
5879 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5880 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5881
5882 /* Mute all inputs to mixer widget (even unconnected ones) */
5883 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5884 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5885 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5886 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5888 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5889 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5890 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5891
5892 { }
5893};
5894#endif
5895
Takashi Iwai63300792008-01-24 15:31:36 +01005896#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5897#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005898
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005899#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5900#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5901
Kailang Yangdf694da2005-12-05 19:42:22 +01005902/*
5903 * for BIOS auto-configuration
5904 */
5905
5906static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005907 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005908{
5909 hda_nid_t nid_vol;
5910 unsigned long vol_val, sw_val;
5911 char name[32];
5912 int err;
5913
5914 if (nid >= 0x0f && nid < 0x11) {
5915 nid_vol = nid - 0x7;
5916 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5917 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5918 } else if (nid == 0x11) {
5919 nid_vol = nid - 0x7;
5920 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5921 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5922 } else if (nid >= 0x12 && nid <= 0x15) {
5923 nid_vol = 0x08;
5924 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5925 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5926 } else
5927 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005928
Takashi Iwai863b4512008-10-21 17:01:47 +02005929 if (!(*vol_bits & (1 << nid_vol))) {
5930 /* first control for the volume widget */
5931 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5932 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5933 if (err < 0)
5934 return err;
5935 *vol_bits |= (1 << nid_vol);
5936 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005937 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005938 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5939 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005940 return err;
5941 return 1;
5942}
5943
5944/* add playback controls from the parsed DAC table */
5945static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5946 const struct auto_pin_cfg *cfg)
5947{
5948 hda_nid_t nid;
5949 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005950 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005951
5952 spec->multiout.num_dacs = 1;
5953 spec->multiout.dac_nids = spec->private_dac_nids;
5954 spec->multiout.dac_nids[0] = 0x02;
5955
5956 nid = cfg->line_out_pins[0];
5957 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005958 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005959 if (err < 0)
5960 return err;
5961 }
5962
Takashi Iwai82bc9552006-03-21 11:24:42 +01005963 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005964 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005965 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005966 if (err < 0)
5967 return err;
5968 }
5969
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005970 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005971 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005972 err = alc260_add_playback_controls(spec, nid, "Headphone",
5973 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005974 if (err < 0)
5975 return err;
5976 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005977 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005978}
5979
5980/* create playback/capture controls for input pins */
5981static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5982 const struct auto_pin_cfg *cfg)
5983{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005984 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005985 int i, err, idx;
5986
5987 for (i = 0; i < AUTO_PIN_LAST; i++) {
5988 if (cfg->input_pins[i] >= 0x12) {
5989 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005990 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005991 auto_pin_cfg_labels[i], idx,
5992 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005993 if (err < 0)
5994 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005995 imux->items[imux->num_items].label =
5996 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005997 imux->items[imux->num_items].index = idx;
5998 imux->num_items++;
5999 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006000 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01006001 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01006002 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006003 auto_pin_cfg_labels[i], idx,
6004 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01006005 if (err < 0)
6006 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006007 imux->items[imux->num_items].label =
6008 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01006009 imux->items[imux->num_items].index = idx;
6010 imux->num_items++;
6011 }
6012 }
6013 return 0;
6014}
6015
6016static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6017 hda_nid_t nid, int pin_type,
6018 int sel_idx)
6019{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006020 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006021 /* need the manual connection? */
6022 if (nid >= 0x12) {
6023 int idx = nid - 0x12;
6024 snd_hda_codec_write(codec, idx + 0x0b, 0,
6025 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006026 }
6027}
6028
6029static void alc260_auto_init_multi_out(struct hda_codec *codec)
6030{
6031 struct alc_spec *spec = codec->spec;
6032 hda_nid_t nid;
6033
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006034 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006035 if (nid) {
6036 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6037 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6038 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006039
Takashi Iwai82bc9552006-03-21 11:24:42 +01006040 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006041 if (nid)
6042 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6043
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006044 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006045 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006046 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006047}
Kailang Yangdf694da2005-12-05 19:42:22 +01006048
6049#define ALC260_PIN_CD_NID 0x16
6050static void alc260_auto_init_analog_input(struct hda_codec *codec)
6051{
6052 struct alc_spec *spec = codec->spec;
6053 int i;
6054
6055 for (i = 0; i < AUTO_PIN_LAST; i++) {
6056 hda_nid_t nid = spec->autocfg.input_pins[i];
6057 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006058 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006059 if (nid != ALC260_PIN_CD_NID &&
6060 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006061 snd_hda_codec_write(codec, nid, 0,
6062 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006063 AMP_OUT_MUTE);
6064 }
6065 }
6066}
6067
6068/*
6069 * generic initialization of ADC, input mixers and output mixers
6070 */
6071static struct hda_verb alc260_volume_init_verbs[] = {
6072 /*
6073 * Unmute ADC0-1 and set the default input to mic-in
6074 */
6075 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6076 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6077 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6078 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006079
Kailang Yangdf694da2005-12-05 19:42:22 +01006080 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6081 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006082 * Note: PASD motherboards uses the Line In 2 as the input for
6083 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006084 */
6085 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006086 /* mute analog inputs */
6087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6088 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6089 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6091 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006092
6093 /*
6094 * Set up output mixers (0x08 - 0x0a)
6095 */
6096 /* set vol=0 to output mixers */
6097 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6099 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6100 /* set up input amps for analog loopback */
6101 /* Amp Indices: DAC = 0, mixer = 1 */
6102 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6103 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6105 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6106 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6107 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006108
Kailang Yangdf694da2005-12-05 19:42:22 +01006109 { }
6110};
6111
6112static int alc260_parse_auto_config(struct hda_codec *codec)
6113{
6114 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006115 int err;
6116 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6117
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006118 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6119 alc260_ignore);
6120 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006121 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006122 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6123 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006124 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006125 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006126 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006127 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
6128 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006129 return err;
6130
6131 spec->multiout.max_channels = 2;
6132
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006133 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006134 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006135 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006136 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006137
Takashi Iwaid88897e2008-10-31 15:01:37 +01006138 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006139
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006140 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006141 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006142
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006143 alc_ssid_check(codec, 0x10, 0x15, 0x0f);
6144
Kailang Yangdf694da2005-12-05 19:42:22 +01006145 return 1;
6146}
6147
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006148/* additional initialization for auto-configuration model */
6149static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006150{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006151 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006152 alc260_auto_init_multi_out(codec);
6153 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006154 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006155 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006156}
6157
Takashi Iwaicb53c622007-08-10 17:21:45 +02006158#ifdef CONFIG_SND_HDA_POWER_SAVE
6159static struct hda_amp_list alc260_loopbacks[] = {
6160 { 0x07, HDA_INPUT, 0 },
6161 { 0x07, HDA_INPUT, 1 },
6162 { 0x07, HDA_INPUT, 2 },
6163 { 0x07, HDA_INPUT, 3 },
6164 { 0x07, HDA_INPUT, 4 },
6165 { } /* end */
6166};
6167#endif
6168
Kailang Yangdf694da2005-12-05 19:42:22 +01006169/*
6170 * ALC260 configurations
6171 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006172static const char *alc260_models[ALC260_MODEL_LAST] = {
6173 [ALC260_BASIC] = "basic",
6174 [ALC260_HP] = "hp",
6175 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006176 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006177 [ALC260_FUJITSU_S702X] = "fujitsu",
6178 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006179 [ALC260_WILL] = "will",
6180 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006181 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006182#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006183 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006184#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006185 [ALC260_AUTO] = "auto",
6186};
6187
6188static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006189 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006190 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006191 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006192 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01006193 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006194 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006195 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006196 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006197 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6198 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6199 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6200 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6201 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6202 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6203 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6204 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6205 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006206 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006207 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006208 {}
6209};
6210
Kailang Yangdf694da2005-12-05 19:42:22 +01006211static struct alc_config_preset alc260_presets[] = {
6212 [ALC260_BASIC] = {
6213 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006214 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006215 .init_verbs = { alc260_init_verbs },
6216 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6217 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006218 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01006219 .adc_nids = alc260_adc_nids,
6220 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6221 .channel_mode = alc260_modes,
6222 .input_mux = &alc260_capture_source,
6223 },
6224 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006225 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006226 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006227 .init_verbs = { alc260_init_verbs,
6228 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006229 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6230 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006231 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6232 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006233 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6234 .channel_mode = alc260_modes,
6235 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006236 .unsol_event = alc260_hp_unsol_event,
6237 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 },
Kailang Yang3f878302008-08-26 13:02:23 +02006239 [ALC260_HP_DC7600] = {
6240 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006241 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006242 .init_verbs = { alc260_init_verbs,
6243 alc260_hp_dc7600_verbs },
6244 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6245 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006246 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6247 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006248 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6249 .channel_mode = alc260_modes,
6250 .input_mux = &alc260_capture_source,
6251 .unsol_event = alc260_hp_3012_unsol_event,
6252 .init_hook = alc260_hp_3012_automute,
6253 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006254 [ALC260_HP_3013] = {
6255 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006256 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006257 .init_verbs = { alc260_hp_3013_init_verbs,
6258 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006259 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6260 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006261 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6262 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6264 .channel_mode = alc260_modes,
6265 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006266 .unsol_event = alc260_hp_3013_unsol_event,
6267 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006268 },
6269 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006270 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006271 .init_verbs = { alc260_fujitsu_init_verbs },
6272 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6273 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006274 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6275 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006276 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6277 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006278 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6279 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006280 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006281 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006282 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006283 .init_verbs = { alc260_acer_init_verbs },
6284 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6285 .dac_nids = alc260_dac_nids,
6286 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6287 .adc_nids = alc260_dual_adc_nids,
6288 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6289 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006290 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6291 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006292 },
Michael Schwingencc959482009-02-22 18:58:45 +01006293 [ALC260_FAVORIT100] = {
6294 .mixers = { alc260_favorit100_mixer },
6295 .init_verbs = { alc260_favorit100_init_verbs },
6296 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6297 .dac_nids = alc260_dac_nids,
6298 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6299 .adc_nids = alc260_dual_adc_nids,
6300 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6301 .channel_mode = alc260_modes,
6302 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6303 .input_mux = alc260_favorit100_capture_sources,
6304 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006305 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006306 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006307 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6308 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6309 .dac_nids = alc260_dac_nids,
6310 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6311 .adc_nids = alc260_adc_nids,
6312 .dig_out_nid = ALC260_DIGOUT_NID,
6313 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6314 .channel_mode = alc260_modes,
6315 .input_mux = &alc260_capture_source,
6316 },
6317 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006318 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006319 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6320 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6321 .dac_nids = alc260_dac_nids,
6322 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6323 .adc_nids = alc260_adc_nids,
6324 .dig_out_nid = ALC260_DIGOUT_NID,
6325 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6326 .channel_mode = alc260_modes,
6327 .input_mux = &alc260_capture_source,
6328 .unsol_event = alc260_replacer_672v_unsol_event,
6329 .init_hook = alc260_replacer_672v_automute,
6330 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006331#ifdef CONFIG_SND_DEBUG
6332 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006333 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006334 .init_verbs = { alc260_test_init_verbs },
6335 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6336 .dac_nids = alc260_test_dac_nids,
6337 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6338 .adc_nids = alc260_test_adc_nids,
6339 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6340 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006341 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6342 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006343 },
6344#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006345};
6346
Linus Torvalds1da177e2005-04-16 15:20:36 -07006347static int patch_alc260(struct hda_codec *codec)
6348{
6349 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006350 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006351
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006352 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006353 if (spec == NULL)
6354 return -ENOMEM;
6355
6356 codec->spec = spec;
6357
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006358 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6359 alc260_models,
6360 alc260_cfg_tbl);
6361 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006362 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006363 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006364 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006365 }
6366
Kailang Yangdf694da2005-12-05 19:42:22 +01006367 if (board_config == ALC260_AUTO) {
6368 /* automatic parse from the BIOS config */
6369 err = alc260_parse_auto_config(codec);
6370 if (err < 0) {
6371 alc_free(codec);
6372 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006373 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006374 printk(KERN_INFO
6375 "hda_codec: Cannot set up configuration "
6376 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006377 board_config = ALC260_BASIC;
6378 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006379 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006380
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006381 err = snd_hda_attach_beep_device(codec, 0x1);
6382 if (err < 0) {
6383 alc_free(codec);
6384 return err;
6385 }
6386
Kailang Yangdf694da2005-12-05 19:42:22 +01006387 if (board_config != ALC260_AUTO)
6388 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006389
Linus Torvalds1da177e2005-04-16 15:20:36 -07006390 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6391 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6392
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006393 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6394 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6395
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006396 if (!spec->adc_nids && spec->input_mux) {
6397 /* check whether NID 0x04 is valid */
6398 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006399 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006400 /* get type */
6401 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6402 spec->adc_nids = alc260_adc_nids_alt;
6403 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6404 } else {
6405 spec->adc_nids = alc260_adc_nids;
6406 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6407 }
6408 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006409 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006410 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006411
Takashi Iwai2134ea42008-01-10 16:53:55 +01006412 spec->vmaster_nid = 0x08;
6413
Linus Torvalds1da177e2005-04-16 15:20:36 -07006414 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006415 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006416 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006417#ifdef CONFIG_SND_HDA_POWER_SAVE
6418 if (!spec->loopback.amplist)
6419 spec->loopback.amplist = alc260_loopbacks;
6420#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01006421 codec->proc_widget_hook = print_realtek_coef;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006422
6423 return 0;
6424}
6425
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006426
Linus Torvalds1da177e2005-04-16 15:20:36 -07006427/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006428 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006429 *
6430 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6431 * configuration. Each pin widget can choose any input DACs and a mixer.
6432 * Each ADC is connected from a mixer of all inputs. This makes possible
6433 * 6-channel independent captures.
6434 *
6435 * In addition, an independent DAC for the multi-playback (not used in this
6436 * driver yet).
6437 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006438#define ALC882_DIGOUT_NID 0x06
6439#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006440#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6441#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6442#define ALC1200_DIGOUT_NID 0x10
6443
Linus Torvalds1da177e2005-04-16 15:20:36 -07006444
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006445static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006446 { 8, NULL }
6447};
6448
Takashi Iwai4953550a2009-06-30 15:28:30 +02006449/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006450static hda_nid_t alc882_dac_nids[4] = {
6451 /* front, rear, clfe, rear_surr */
6452 0x02, 0x03, 0x04, 0x05
6453};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006454#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006455
Takashi Iwai4953550a2009-06-30 15:28:30 +02006456/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006457#define alc882_adc_nids alc880_adc_nids
6458#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006459#define alc883_adc_nids alc882_adc_nids_alt
6460static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6461static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6462#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006463
Takashi Iwaie1406342008-02-11 18:32:32 +01006464static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6465static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006466#define alc883_capsrc_nids alc882_capsrc_nids_alt
6467static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6468#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006469
Linus Torvalds1da177e2005-04-16 15:20:36 -07006470/* input MUX */
6471/* FIXME: should be a matrix-type input source selection */
6472
6473static struct hda_input_mux alc882_capture_source = {
6474 .num_items = 4,
6475 .items = {
6476 { "Mic", 0x0 },
6477 { "Front Mic", 0x1 },
6478 { "Line", 0x2 },
6479 { "CD", 0x4 },
6480 },
6481};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006482
Takashi Iwai4953550a2009-06-30 15:28:30 +02006483#define alc883_capture_source alc882_capture_source
6484
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006485static struct hda_input_mux alc889_capture_source = {
6486 .num_items = 3,
6487 .items = {
6488 { "Front Mic", 0x0 },
6489 { "Mic", 0x3 },
6490 { "Line", 0x2 },
6491 },
6492};
6493
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006494static struct hda_input_mux mb5_capture_source = {
6495 .num_items = 3,
6496 .items = {
6497 { "Mic", 0x1 },
6498 { "Line", 0x2 },
6499 { "CD", 0x4 },
6500 },
6501};
6502
Takashi Iwai4953550a2009-06-30 15:28:30 +02006503static struct hda_input_mux alc883_3stack_6ch_intel = {
6504 .num_items = 4,
6505 .items = {
6506 { "Mic", 0x1 },
6507 { "Front Mic", 0x0 },
6508 { "Line", 0x2 },
6509 { "CD", 0x4 },
6510 },
6511};
6512
6513static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6514 .num_items = 2,
6515 .items = {
6516 { "Mic", 0x1 },
6517 { "Line", 0x2 },
6518 },
6519};
6520
6521static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6522 .num_items = 4,
6523 .items = {
6524 { "Mic", 0x0 },
6525 { "iMic", 0x1 },
6526 { "Line", 0x2 },
6527 { "CD", 0x4 },
6528 },
6529};
6530
6531static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6532 .num_items = 2,
6533 .items = {
6534 { "Mic", 0x0 },
6535 { "Int Mic", 0x1 },
6536 },
6537};
6538
6539static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6540 .num_items = 3,
6541 .items = {
6542 { "Mic", 0x0 },
6543 { "Front Mic", 0x1 },
6544 { "Line", 0x4 },
6545 },
6546};
6547
6548static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6549 .num_items = 2,
6550 .items = {
6551 { "Mic", 0x0 },
6552 { "Line", 0x2 },
6553 },
6554};
6555
6556static struct hda_input_mux alc889A_mb31_capture_source = {
6557 .num_items = 2,
6558 .items = {
6559 { "Mic", 0x0 },
6560 /* Front Mic (0x01) unused */
6561 { "Line", 0x2 },
6562 /* Line 2 (0x03) unused */
6563 /* CD (0x04) unsused? */
6564 },
6565};
6566
6567/*
6568 * 2ch mode
6569 */
6570static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6571 { 2, NULL }
6572};
6573
Kailang Yangdf694da2005-12-05 19:42:22 +01006574/*
Kailang Yang272a5272007-05-14 11:00:38 +02006575 * 2ch mode
6576 */
6577static struct hda_verb alc882_3ST_ch2_init[] = {
6578 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6579 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6580 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6581 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6582 { } /* end */
6583};
6584
6585/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006586 * 4ch mode
6587 */
6588static struct hda_verb alc882_3ST_ch4_init[] = {
6589 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6590 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6591 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6592 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6593 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6594 { } /* end */
6595};
6596
6597/*
Kailang Yang272a5272007-05-14 11:00:38 +02006598 * 6ch mode
6599 */
6600static struct hda_verb alc882_3ST_ch6_init[] = {
6601 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6602 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6603 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6604 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6605 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6606 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6607 { } /* end */
6608};
6609
Takashi Iwai4953550a2009-06-30 15:28:30 +02006610static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006611 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006612 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006613 { 6, alc882_3ST_ch6_init },
6614};
6615
Takashi Iwai4953550a2009-06-30 15:28:30 +02006616#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6617
Kailang Yang272a5272007-05-14 11:00:38 +02006618/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006619 * 6ch mode
6620 */
6621static struct hda_verb alc882_sixstack_ch6_init[] = {
6622 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6623 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6624 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6625 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6626 { } /* end */
6627};
6628
6629/*
6630 * 8ch mode
6631 */
6632static struct hda_verb alc882_sixstack_ch8_init[] = {
6633 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6634 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6635 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6636 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6637 { } /* end */
6638};
6639
6640static struct hda_channel_mode alc882_sixstack_modes[2] = {
6641 { 6, alc882_sixstack_ch6_init },
6642 { 8, alc882_sixstack_ch8_init },
6643};
6644
Takashi Iwai87350ad2007-08-16 18:19:38 +02006645/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006646 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006647 */
6648
6649/*
6650 * 2ch mode
6651 */
6652static struct hda_verb alc885_mbp_ch2_init[] = {
6653 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6654 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6655 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6656 { } /* end */
6657};
6658
6659/*
6660 * 6ch mode
6661 */
6662static struct hda_verb alc885_mbp_ch6_init[] = {
6663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6665 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6666 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6667 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6668 { } /* end */
6669};
6670
6671static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
6672 { 2, alc885_mbp_ch2_init },
6673 { 6, alc885_mbp_ch6_init },
6674};
6675
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006676/*
6677 * 2ch
6678 * Speakers/Woofer/HP = Front
6679 * LineIn = Input
6680 */
6681static struct hda_verb alc885_mb5_ch2_init[] = {
6682 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6683 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6684 { } /* end */
6685};
6686
6687/*
6688 * 6ch mode
6689 * Speakers/HP = Front
6690 * Woofer = LFE
6691 * LineIn = Surround
6692 */
6693static struct hda_verb alc885_mb5_ch6_init[] = {
6694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6697 { } /* end */
6698};
6699
6700static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
6701 { 2, alc885_mb5_ch2_init },
6702 { 6, alc885_mb5_ch6_init },
6703};
Takashi Iwai87350ad2007-08-16 18:19:38 +02006704
Takashi Iwai4953550a2009-06-30 15:28:30 +02006705
6706/*
6707 * 2ch mode
6708 */
6709static struct hda_verb alc883_4ST_ch2_init[] = {
6710 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6711 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6712 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6713 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6714 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6715 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6716 { } /* end */
6717};
6718
6719/*
6720 * 4ch mode
6721 */
6722static struct hda_verb alc883_4ST_ch4_init[] = {
6723 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6724 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6725 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6726 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6727 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6728 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6729 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6730 { } /* end */
6731};
6732
6733/*
6734 * 6ch mode
6735 */
6736static struct hda_verb alc883_4ST_ch6_init[] = {
6737 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6738 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6739 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6740 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6741 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6742 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6743 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6744 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6745 { } /* end */
6746};
6747
6748/*
6749 * 8ch mode
6750 */
6751static struct hda_verb alc883_4ST_ch8_init[] = {
6752 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6753 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6754 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6755 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6756 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6757 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6758 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6759 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6760 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6761 { } /* end */
6762};
6763
6764static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
6765 { 2, alc883_4ST_ch2_init },
6766 { 4, alc883_4ST_ch4_init },
6767 { 6, alc883_4ST_ch6_init },
6768 { 8, alc883_4ST_ch8_init },
6769};
6770
6771
6772/*
6773 * 2ch mode
6774 */
6775static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6776 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6777 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6779 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6780 { } /* end */
6781};
6782
6783/*
6784 * 4ch mode
6785 */
6786static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6787 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6788 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6789 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6790 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6791 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6792 { } /* end */
6793};
6794
6795/*
6796 * 6ch mode
6797 */
6798static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6799 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6800 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6801 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6802 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6803 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6804 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6805 { } /* end */
6806};
6807
6808static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6809 { 2, alc883_3ST_ch2_intel_init },
6810 { 4, alc883_3ST_ch4_intel_init },
6811 { 6, alc883_3ST_ch6_intel_init },
6812};
6813
6814/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006815 * 2ch mode
6816 */
6817static struct hda_verb alc889_ch2_intel_init[] = {
6818 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6819 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
6820 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
6821 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
6822 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6823 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6824 { } /* end */
6825};
6826
6827/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006828 * 6ch mode
6829 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006830static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006831 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6832 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6833 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6834 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6835 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006836 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6837 { } /* end */
6838};
6839
6840/*
6841 * 8ch mode
6842 */
6843static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006844 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
6845 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
6846 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
6847 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
6848 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006851 { } /* end */
6852};
6853
Wu Fengguangdd7714c2009-07-30 14:36:35 +08006854static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
6855 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006856 { 6, alc889_ch6_intel_init },
6857 { 8, alc889_ch8_intel_init },
6858};
6859
6860/*
6861 * 6ch mode
6862 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006863static struct hda_verb alc883_sixstack_ch6_init[] = {
6864 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6865 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6866 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6867 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6868 { } /* end */
6869};
6870
6871/*
6872 * 8ch mode
6873 */
6874static struct hda_verb alc883_sixstack_ch8_init[] = {
6875 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6876 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6877 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6878 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6879 { } /* end */
6880};
6881
6882static struct hda_channel_mode alc883_sixstack_modes[2] = {
6883 { 6, alc883_sixstack_ch6_init },
6884 { 8, alc883_sixstack_ch8_init },
6885};
6886
6887
Linus Torvalds1da177e2005-04-16 15:20:36 -07006888/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6889 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6890 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006891static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02006892 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006894 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006895 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006896 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6897 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006898 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6899 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02006900 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006901 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6903 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6904 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6906 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006908 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6910 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006911 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07006913 { } /* end */
6914};
6915
Takashi Iwai87350ad2007-08-16 18:19:38 +02006916static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01006917 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6918 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6919 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
6920 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6921 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6922 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006923 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
6924 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01006925 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02006926 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
6927 { } /* end */
6928};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006929
6930static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006931 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6932 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
6933 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6934 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
6935 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6936 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
6937 HDA_CODEC_VOLUME("HP Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
6938 HDA_BIND_MUTE ("HP Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006939 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6940 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6941 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
6942 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
6943 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
6944 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
6945 { } /* end */
6946};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006947
Kailang Yangbdd148a2007-05-08 15:19:08 +02006948static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
6949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6950 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6951 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6952 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6953 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6954 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6955 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6957 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02006958 { } /* end */
6959};
6960
Kailang Yang272a5272007-05-14 11:00:38 +02006961static struct snd_kcontrol_new alc882_targa_mixer[] = {
6962 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6963 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6964 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6965 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6966 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006972 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6973 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006974 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006975 { } /* end */
6976};
6977
6978/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
6979 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
6980 */
6981static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
6982 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6983 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
6984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6985 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
6986 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6987 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6988 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6989 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6990 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
6991 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
6992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02006994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02006995 { } /* end */
6996};
6997
Takashi Iwai914759b2007-09-06 14:52:04 +02006998static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
6999 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7000 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7002 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7003 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7004 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7005 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7007 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7008 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007009 { } /* end */
7010};
7011
Kailang Yangdf694da2005-12-05 19:42:22 +01007012static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7013 {
7014 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7015 .name = "Channel Mode",
7016 .info = alc_ch_mode_info,
7017 .get = alc_ch_mode_get,
7018 .put = alc_ch_mode_put,
7019 },
7020 { } /* end */
7021};
7022
Takashi Iwai4953550a2009-06-30 15:28:30 +02007023static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007024 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007028 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007032 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007036 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007037 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7039 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007040
Takashi Iwaicb638122009-07-03 10:56:10 +02007041 /* mute analog input loopbacks */
7042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7047
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007048 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007051 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007052 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007053 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007056 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007057 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007058 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007059 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007060 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007061 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007062 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007063 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007064 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007066 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7067 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007068 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007069 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7070 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007071 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007072 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7073 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7075 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7076 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007077 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007079
7080 /* FIXME: use matrix-type input source selection */
7081 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007082 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7086 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007087 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007092 /* ADC2: mute amp left and right */
7093 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007094 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007095 /* ADC3: mute amp left and right */
7096 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007097 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007098
7099 { }
7100};
7101
Takashi Iwai4953550a2009-06-30 15:28:30 +02007102static struct hda_verb alc882_adc1_init_verbs[] = {
7103 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7108 /* ADC1: mute amp left and right */
7109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7110 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7111 { }
7112};
7113
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007114static struct hda_verb alc882_eapd_verbs[] = {
7115 /* change to EAPD mode */
7116 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007117 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007118 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007119};
7120
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007121static struct hda_verb alc889_eapd_verbs[] = {
7122 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7123 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7124 { }
7125};
7126
Wu Fengguang6732bd02009-07-30 09:19:14 +02007127static struct hda_verb alc_hp15_unsol_verbs[] = {
7128 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7129 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7130 {}
7131};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007132
7133static struct hda_verb alc885_init_verbs[] = {
7134 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7135 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7138 /* Rear mixer */
7139 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7142 /* CLFE mixer */
7143 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7146 /* Side mixer */
7147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7148 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7149 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7150
7151 /* mute analog input loopbacks */
7152 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7153 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7155
7156 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7160 /* Front Pin: output 0 (0x0c) */
7161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7162 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7163 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7164 /* Rear Pin: output 1 (0x0d) */
7165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7166 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7167 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7168 /* CLFE Pin: output 2 (0x0e) */
7169 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7170 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7171 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7172 /* Side Pin: output 3 (0x0f) */
7173 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7174 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7175 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7176 /* Mic (rear) pin: input vref at 80% */
7177 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7178 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7179 /* Front Mic pin: input vref at 80% */
7180 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7182 /* Line In pin: input */
7183 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7184 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7185
7186 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7187 /* Input mixer1 */
7188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7190 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7191 /* Input mixer2 */
7192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7195 /* Input mixer3 */
7196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7199 /* ADC2: mute amp left and right */
7200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7201 /* ADC3: mute amp left and right */
7202 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7203
7204 { }
7205};
7206
7207static struct hda_verb alc885_init_input_verbs[] = {
7208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7211 { }
7212};
7213
7214
7215/* Unmute Selector 24h and set the default input to front mic */
7216static struct hda_verb alc889_init_input_verbs[] = {
7217 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7218 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7219 { }
7220};
7221
7222
Takashi Iwai4953550a2009-06-30 15:28:30 +02007223#define alc883_init_verbs alc882_base_init_verbs
7224
Tobin Davis9102cd12006-12-15 10:02:12 +01007225/* Mac Pro test */
7226static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7228 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7229 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007232 /* FIXME: this looks suspicious...
Tobin Davis9102cd12006-12-15 10:02:12 +01007233 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
7234 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007235 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007236 { } /* end */
7237};
7238
7239static struct hda_verb alc882_macpro_init_verbs[] = {
7240 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7242 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7243 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7244 /* Front Pin: output 0 (0x0c) */
7245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7246 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7248 /* Front Mic pin: input vref at 80% */
7249 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7250 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7251 /* Speaker: output */
7252 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7253 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7254 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7255 /* Headphone output (output 0 - 0x0c) */
7256 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7257 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7258 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7259
7260 /* FIXME: use matrix-type input source selection */
7261 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7262 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7263 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7264 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7265 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7267 /* Input mixer2 */
7268 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7269 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7270 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7271 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7272 /* Input mixer3 */
7273 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7274 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7275 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7276 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7277 /* ADC1: mute amp left and right */
7278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7279 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7280 /* ADC2: mute amp left and right */
7281 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7282 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7283 /* ADC3: mute amp left and right */
7284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7285 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7286
7287 { }
7288};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007289
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007290/* Macbook 5,1 */
7291static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007292 /* DACs */
7293 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7294 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7295 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7296 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007297 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7300 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007301 /* Surround mixer */
7302 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7303 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7304 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7305 /* LFE mixer */
7306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7307 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7309 /* HP mixer */
7310 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7313 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007316 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7317 /* LFE Pin (0x0e) */
7318 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7319 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7320 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7321 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007322 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007324 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007325 /* Front Mic pin: input vref at 80% */
7326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7328 /* Line In pin */
7329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7331
7332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7334 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7335 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7336 { }
7337};
7338
Takashi Iwai87350ad2007-08-16 18:19:38 +02007339/* Macbook Pro rev3 */
7340static struct hda_verb alc885_mbp3_init_verbs[] = {
7341 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7345 /* Rear mixer */
7346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7347 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7348 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7349 /* Front Pin: output 0 (0x0c) */
7350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7352 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7353 /* HP Pin: output 0 (0x0d) */
7354 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7355 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7356 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7357 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7358 /* Mic (rear) pin: input vref at 80% */
7359 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7360 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7361 /* Front Mic pin: input vref at 80% */
7362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7364 /* Line In pin: use output 1 when in LineOut mode */
7365 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7366 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7367 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7368
7369 /* FIXME: use matrix-type input source selection */
7370 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7371 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7374 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7376 /* Input mixer2 */
7377 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7378 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7379 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7380 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7381 /* Input mixer3 */
7382 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7383 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7384 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7385 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7386 /* ADC1: mute amp left and right */
7387 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7389 /* ADC2: mute amp left and right */
7390 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7392 /* ADC3: mute amp left and right */
7393 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7394 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7395
7396 { }
7397};
7398
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007399/* iMac 24 mixer. */
7400static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7401 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7402 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7403 { } /* end */
7404};
7405
7406/* iMac 24 init verbs. */
7407static struct hda_verb alc885_imac24_init_verbs[] = {
7408 /* Internal speakers: output 0 (0x0c) */
7409 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7410 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7411 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7412 /* Internal speakers: output 0 (0x0c) */
7413 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7414 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7415 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7416 /* Headphone: output 0 (0x0c) */
7417 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7418 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7419 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7421 /* Front Mic: input vref at 80% */
7422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7423 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7424 { }
7425};
7426
7427/* Toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007428static void alc885_imac24_automute_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007429{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007430 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007431
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007432 spec->autocfg.hp_pins[0] = 0x14;
7433 spec->autocfg.speaker_pins[0] = 0x18;
7434 spec->autocfg.speaker_pins[1] = 0x1a;
7435 alc_automute_amp(codec);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007436}
7437
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007438static void alc885_mbp3_init_hook(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007439{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007440 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007441
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007442 spec->autocfg.hp_pins[0] = 0x15;
7443 spec->autocfg.speaker_pins[0] = 0x14;
7444 alc_automute_amp(codec);
Takashi Iwai87350ad2007-08-16 18:19:38 +02007445}
7446
7447
Kailang Yang272a5272007-05-14 11:00:38 +02007448static struct hda_verb alc882_targa_verbs[] = {
7449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7450 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7451
7452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7453 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007454
Kailang Yang272a5272007-05-14 11:00:38 +02007455 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7456 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7457 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7458
7459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007460 { } /* end */
7461};
7462
7463/* toggle speaker-output according to the hp-jack state */
7464static void alc882_targa_automute(struct hda_codec *codec)
7465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007466 struct alc_spec *spec = codec->spec;
7467 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007468 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007469 spec->jack_present ? 1 : 3);
7470}
7471
7472static void alc882_targa_init_hook(struct hda_codec *codec)
7473{
7474 struct alc_spec *spec = codec->spec;
7475
7476 spec->autocfg.hp_pins[0] = 0x14;
7477 spec->autocfg.speaker_pins[0] = 0x1b;
7478 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007479}
7480
7481static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7482{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007483 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007484 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007485}
7486
7487static struct hda_verb alc882_asus_a7j_verbs[] = {
7488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7490
7491 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7493 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007494
Kailang Yang272a5272007-05-14 11:00:38 +02007495 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7496 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7497 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7498
7499 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7500 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7501 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7502 { } /* end */
7503};
7504
Takashi Iwai914759b2007-09-06 14:52:04 +02007505static struct hda_verb alc882_asus_a7m_verbs[] = {
7506 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7507 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7508
7509 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7511 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007512
Takashi Iwai914759b2007-09-06 14:52:04 +02007513 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7514 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7515 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7516
7517 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7518 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7519 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7520 { } /* end */
7521};
7522
Tobin Davis9102cd12006-12-15 10:02:12 +01007523static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
7524{
7525 unsigned int gpiostate, gpiomask, gpiodir;
7526
7527 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
7528 AC_VERB_GET_GPIO_DATA, 0);
7529
7530 if (!muted)
7531 gpiostate |= (1 << pin);
7532 else
7533 gpiostate &= ~(1 << pin);
7534
7535 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
7536 AC_VERB_GET_GPIO_MASK, 0);
7537 gpiomask |= (1 << pin);
7538
7539 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
7540 AC_VERB_GET_GPIO_DIRECTION, 0);
7541 gpiodir |= (1 << pin);
7542
7543
7544 snd_hda_codec_write(codec, codec->afg, 0,
7545 AC_VERB_SET_GPIO_MASK, gpiomask);
7546 snd_hda_codec_write(codec, codec->afg, 0,
7547 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
7548
7549 msleep(1);
7550
7551 snd_hda_codec_write(codec, codec->afg, 0,
7552 AC_VERB_SET_GPIO_DATA, gpiostate);
7553}
7554
Takashi Iwai7debbe52007-08-16 15:01:03 +02007555/* set up GPIO at initialization */
7556static void alc885_macpro_init_hook(struct hda_codec *codec)
7557{
7558 alc882_gpio_mute(codec, 0, 0);
7559 alc882_gpio_mute(codec, 1, 0);
7560}
7561
7562/* set up GPIO and update auto-muting at initialization */
7563static void alc885_imac24_init_hook(struct hda_codec *codec)
7564{
7565 alc885_macpro_init_hook(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007566 alc885_imac24_automute_init_hook(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02007567}
7568
Kailang Yangdf694da2005-12-05 19:42:22 +01007569/*
7570 * generic initialization of ADC, input mixers and output mixers
7571 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007572static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01007573 /*
7574 * Unmute ADC0-2 and set the default input to mic-in
7575 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007576 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7577 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7578 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7579 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7580
Takashi Iwaicb53c622007-08-10 17:21:45 +02007581 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01007582 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007583 * Note: PASD motherboards uses the Line In 2 as the input for
7584 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007585 */
7586 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007587 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7588 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7589 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7590 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7591 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007592
7593 /*
7594 * Set up output mixers (0x0c - 0x0f)
7595 */
7596 /* set vol=0 to output mixers */
7597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7600 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7601 /* set up input amps for analog loopback */
7602 /* Amp Indices: DAC = 0, mixer = 1 */
7603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7611 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7612 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7613
7614 /* FIXME: use matrix-type input source selection */
7615 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01007616 /* Input mixer2 */
7617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7618 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7619 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7620 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7621 /* Input mixer3 */
7622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
7623 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
7624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
7625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
7626
7627 { }
7628};
7629
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007630/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
7631static struct hda_verb alc889A_mb31_ch2_init[] = {
7632 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7633 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7634 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7635 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7636 { } /* end */
7637};
7638
7639/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
7640static struct hda_verb alc889A_mb31_ch4_init[] = {
7641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
7642 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7643 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7644 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7645 { } /* end */
7646};
7647
7648/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
7649static struct hda_verb alc889A_mb31_ch5_init[] = {
7650 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
7651 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
7652 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
7653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
7654 { } /* end */
7655};
7656
7657/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
7658static struct hda_verb alc889A_mb31_ch6_init[] = {
7659 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
7660 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
7661 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
7662 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
7663 { } /* end */
7664};
7665
7666static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
7667 { 2, alc889A_mb31_ch2_init },
7668 { 4, alc889A_mb31_ch4_init },
7669 { 5, alc889A_mb31_ch5_init },
7670 { 6, alc889A_mb31_ch6_init },
7671};
7672
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007673static struct hda_verb alc883_medion_eapd_verbs[] = {
7674 /* eanable EAPD on medion laptop */
7675 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7676 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7677 { }
7678};
7679
Takashi Iwai4953550a2009-06-30 15:28:30 +02007680#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007681
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007682static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7683 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7684 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7685 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7686 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7687 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7688 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7691 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7694 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7695 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007696 { } /* end */
7697};
7698
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007699static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007700 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7701 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7702 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7703 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7705 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7707 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7708 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7709 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007710 { } /* end */
7711};
7712
Jiang zhefb97dc62008-03-06 11:07:11 +01007713static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7714 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7715 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7716 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7717 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7719 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7721 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7723 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007724 { } /* end */
7725};
7726
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007727static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7728 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7729 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7730 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7731 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7732 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7733 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7734 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007736 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007737 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7738 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007739 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007740 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007741 { } /* end */
7742};
7743
7744static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7745 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7746 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7748 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7749 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7750 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7751 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7752 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7753 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007759 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7761 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007762 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007763 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007764 { } /* end */
7765};
7766
Jiang zhe17bba1b2008-06-04 12:11:07 +02007767static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7771 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7772 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7773 HDA_OUTPUT),
7774 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7775 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7776 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7778 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7779 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7780 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7781 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7782 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7784 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7785 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7786 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7787 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007788 { } /* end */
7789};
7790
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007791static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
7792 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7793 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7795 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7796 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7797 HDA_OUTPUT),
7798 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7799 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7800 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7802 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
7803 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7804 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7805 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7806 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
7808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7810 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7811 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7812 { } /* end */
7813};
7814
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007815static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007816 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007817 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007818 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007819 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007820 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7821 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007822 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7823 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007824 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007830 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7832 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007833 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007834 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007835 { } /* end */
7836};
7837
Sasha Alexandrc2592492009-06-16 14:52:54 -04007838static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007839 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7840 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7841 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7842 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7843 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7844 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7845 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7846 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7847 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007853 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007855 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007856};
Kailang Yangccc656c2006-10-17 12:32:26 +02007857
Sasha Alexandrc2592492009-06-16 14:52:54 -04007858static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02007859 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7862 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007867 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7868 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7869 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007870 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007871};
Kailang Yangccc656c2006-10-17 12:32:26 +02007872
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007873static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7875 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007876 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7877 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007878 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007882 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007883};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007884
Kailang Yang272a5272007-05-14 11:00:38 +02007885static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7886 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7887 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7888 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7889 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7890 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7892 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7893 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7894 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007895 { } /* end */
7896};
7897
7898static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7899 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7900 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7901 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7902 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7903 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7906 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7907 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007908 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007909};
Kailang Yang272a5272007-05-14 11:00:38 +02007910
Tobin Davis2880a862007-08-07 11:50:26 +02007911static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007914 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007915 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7916 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7918 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007920 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007921};
Tobin Davis2880a862007-08-07 11:50:26 +02007922
Tony Vroond2fd4b02009-06-21 00:40:10 +01007923static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
7924 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7925 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7926 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7927 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01007928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01007930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7932 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7934 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7935 { } /* end */
7936};
7937
Kailang Yange2757d52008-08-26 13:17:46 +02007938static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
7939 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7940 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7941 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
7942 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7943 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7944 0x0d, 1, 0x0, HDA_OUTPUT),
7945 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7946 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7947 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7948 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7949 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007950 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7951 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7956 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7959 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007960 { } /* end */
7961};
7962
Torben Schulzeb4c41d2009-05-18 15:02:35 +02007963static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
7964 /* Output mixers */
7965 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7966 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7967 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7968 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7969 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
7970 HDA_OUTPUT),
7971 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
7972 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
7973 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
7974 /* Output switches */
7975 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
7976 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
7977 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
7978 /* Boost mixers */
7979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7980 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
7981 /* Input mixers */
7982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7986 { } /* end */
7987};
7988
Guido Günther3e1647c2009-06-05 00:47:26 +02007989static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
7990 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7991 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7994 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7996 { } /* end */
7997};
7998
Kailang Yange2757d52008-08-26 13:17:46 +02007999static struct hda_bind_ctls alc883_bind_cap_vol = {
8000 .ops = &snd_hda_bind_vol,
8001 .values = {
8002 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8003 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8004 0
8005 },
8006};
8007
8008static struct hda_bind_ctls alc883_bind_cap_switch = {
8009 .ops = &snd_hda_bind_sw,
8010 .values = {
8011 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8012 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8013 0
8014 },
8015};
8016
8017static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8018 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8019 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8020 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8021 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8022 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008026 { } /* end */
8027};
8028
8029static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008030 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8031 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8032 {
8033 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8034 /* .name = "Capture Source", */
8035 .name = "Input Source",
8036 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008037 .info = alc_mux_enum_info,
8038 .get = alc_mux_enum_get,
8039 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008040 },
8041 { } /* end */
8042};
8043
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008044static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8045 {
8046 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8047 .name = "Channel Mode",
8048 .info = alc_ch_mode_info,
8049 .get = alc_ch_mode_get,
8050 .put = alc_ch_mode_put,
8051 },
8052 { } /* end */
8053};
8054
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008055/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008056static void alc883_mitac_init_hook(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008057{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008058 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008059
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008060 spec->autocfg.hp_pins[0] = 0x15;
8061 spec->autocfg.speaker_pins[0] = 0x14;
8062 spec->autocfg.speaker_pins[1] = 0x17;
8063 alc_automute_amp(codec);
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008064}
8065
8066/* auto-toggle front mic */
8067/*
8068static void alc883_mitac_mic_automute(struct hda_codec *codec)
8069{
8070 unsigned int present;
8071 unsigned char bits;
8072
8073 present = snd_hda_codec_read(codec, 0x18, 0,
8074 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8075 bits = present ? HDA_AMP_MUTE : 0;
8076 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8077}
8078*/
8079
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008080static struct hda_verb alc883_mitac_verbs[] = {
8081 /* HP */
8082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8084 /* Subwoofer */
8085 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8086 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8087
8088 /* enable unsolicited event */
8089 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8090 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8091
8092 { } /* end */
8093};
8094
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008095static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008096 /* HP */
8097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8099 /* Int speaker */
8100 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8102
8103 /* enable unsolicited event */
8104 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008105 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008106
8107 { } /* end */
8108};
8109
Jiang zhefb97dc62008-03-06 11:07:11 +01008110static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8111 /* HP */
8112 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8113 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8114 /* Subwoofer */
8115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8117
8118 /* enable unsolicited event */
8119 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8120
8121 { } /* end */
8122};
8123
Sasha Alexandrc2592492009-06-16 14:52:54 -04008124static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8127
8128 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8129 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008130
David Heidelberger64a8be72009-06-08 16:15:18 +02008131/* Connect Line-Out side jack (SPDIF) to Side */
8132 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8134 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8135/* Connect Mic jack to CLFE */
8136 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8138 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8139/* Connect Line-in jack to Surround */
8140 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8141 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8142 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8143/* Connect HP out jack to Front */
8144 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8145 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8146 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008147
8148 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008149
8150 { } /* end */
8151};
8152
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008153static struct hda_verb alc883_lenovo_101e_verbs[] = {
8154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8155 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8156 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8157 { } /* end */
8158};
8159
Kailang Yang272a5272007-05-14 11:00:38 +02008160static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8161 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8162 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8163 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8164 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8165 { } /* end */
8166};
8167
8168static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8171 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8172 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8173 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8174 { } /* end */
8175};
8176
Kailang Yang189609a2007-08-20 11:31:23 +02008177static struct hda_verb alc883_haier_w66_verbs[] = {
8178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8180
8181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8182
8183 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8184 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8185 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8186 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8187 { } /* end */
8188};
8189
Kailang Yange2757d52008-08-26 13:17:46 +02008190static struct hda_verb alc888_lenovo_sky_verbs[] = {
8191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8192 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8195 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8196 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8197 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8198 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8199 { } /* end */
8200};
8201
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008202static struct hda_verb alc888_6st_dell_verbs[] = {
8203 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8204 { }
8205};
8206
Guido Günther3e1647c2009-06-05 00:47:26 +02008207static struct hda_verb alc883_vaiott_verbs[] = {
8208 /* HP */
8209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8210 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8211
8212 /* enable unsolicited event */
8213 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8214
8215 { } /* end */
8216};
8217
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008218static void alc888_3st_hp_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008219{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008220 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008221
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008222 spec->autocfg.hp_pins[0] = 0x1b;
8223 spec->autocfg.speaker_pins[0] = 0x14;
8224 spec->autocfg.speaker_pins[1] = 0x16;
8225 spec->autocfg.speaker_pins[2] = 0x18;
8226 alc_automute_amp(codec);
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008227}
8228
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008229static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008230 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008231 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8232 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008233 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008234 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008235};
8236
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008237/*
8238 * 2ch mode
8239 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008240static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008241 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8242 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8243 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8244 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008245 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008246};
8247
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008248/*
8249 * 4ch mode
8250 */
8251static struct hda_verb alc888_3st_hp_4ch_init[] = {
8252 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8253 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8254 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8255 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8256 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8257 { } /* end */
8258};
8259
8260/*
8261 * 6ch mode
8262 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008263static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008264 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8265 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008266 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008267 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8268 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008269 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8270 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008271};
8272
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008273static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008274 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008275 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008276 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008277};
8278
Kailang Yang272a5272007-05-14 11:00:38 +02008279/* toggle front-jack and RCA according to the hp-jack state */
8280static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8281{
8282 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008283
Kailang Yang272a5272007-05-14 11:00:38 +02008284 present = snd_hda_codec_read(codec, 0x1b, 0,
8285 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008286 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8287 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8288 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8289 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008290}
8291
8292/* toggle RCA according to the front-jack state */
8293static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8294{
8295 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008296
Kailang Yang272a5272007-05-14 11:00:38 +02008297 present = snd_hda_codec_read(codec, 0x14, 0,
8298 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008299 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8300 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008301}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008302
Kailang Yang272a5272007-05-14 11:00:38 +02008303static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8304 unsigned int res)
8305{
8306 if ((res >> 26) == ALC880_HP_EVENT)
8307 alc888_lenovo_ms7195_front_automute(codec);
8308 if ((res >> 26) == ALC880_FRONT_EVENT)
8309 alc888_lenovo_ms7195_rca_automute(codec);
8310}
8311
8312static struct hda_verb alc883_medion_md2_verbs[] = {
8313 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8314 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8315
8316 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8317
8318 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8319 { } /* end */
8320};
8321
8322/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008323static void alc883_medion_md2_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008324{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008325 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008326
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008327 spec->autocfg.hp_pins[0] = 0x14;
8328 spec->autocfg.speaker_pins[0] = 0x15;
8329 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008330}
8331
Kailang Yangccc656c2006-10-17 12:32:26 +02008332/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008333#define alc883_targa_init_hook alc882_targa_init_hook
8334#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008335
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008336static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8337{
8338 unsigned int present;
8339
8340 present = snd_hda_codec_read(codec, 0x18, 0,
8341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8342 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8343 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8344}
8345
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008346static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008347{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008348 struct alc_spec *spec = codec->spec;
8349
8350 spec->autocfg.hp_pins[0] = 0x15;
8351 spec->autocfg.speaker_pins[0] = 0x14;
8352 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008353 alc883_clevo_m720_mic_automute(codec);
8354}
8355
8356static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008357 unsigned int res)
8358{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008359 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008360 case ALC880_MIC_EVENT:
8361 alc883_clevo_m720_mic_automute(codec);
8362 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008363 default:
8364 alc_automute_amp_unsol_event(codec, res);
8365 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008366 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008367}
8368
Jiang zhefb97dc62008-03-06 11:07:11 +01008369/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008370static void alc883_2ch_fujitsu_pi2515_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008371{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008372 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008373
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008374 spec->autocfg.hp_pins[0] = 0x14;
8375 spec->autocfg.speaker_pins[0] = 0x15;
8376 alc_automute_amp(codec);
Jiang zhefb97dc62008-03-06 11:07:11 +01008377}
8378
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008379static void alc883_haier_w66_init_hook(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008380{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008381 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008382
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008383 spec->autocfg.hp_pins[0] = 0x1b;
8384 spec->autocfg.speaker_pins[0] = 0x14;
8385 alc_automute_amp(codec);
Kailang Yang189609a2007-08-20 11:31:23 +02008386}
8387
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008388static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8389{
8390 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008391 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008392
David Heidelberger64a8be72009-06-08 16:15:18 +02008393 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
8394 & AC_PINSENSE_PRESENCE;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008395 bits = present ? HDA_AMP_MUTE : 0;
8396 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8397 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008398}
8399
8400static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8401{
8402 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008403 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008404
8405 present = snd_hda_codec_read(codec, 0x1b, 0,
8406 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02008407 bits = present ? HDA_AMP_MUTE : 0;
8408 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8409 HDA_AMP_MUTE, bits);
8410 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8411 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008412}
8413
8414static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8415 unsigned int res)
8416{
8417 if ((res >> 26) == ALC880_HP_EVENT)
8418 alc883_lenovo_101e_all_automute(codec);
8419 if ((res >> 26) == ALC880_FRONT_EVENT)
8420 alc883_lenovo_101e_ispeaker_automute(codec);
8421}
8422
Takashi Iwai676a9b52007-08-16 15:23:35 +02008423/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008424static void alc883_acer_aspire_init_hook(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008426 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008427
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008428 spec->autocfg.hp_pins[0] = 0x14;
8429 spec->autocfg.speaker_pins[0] = 0x15;
8430 spec->autocfg.speaker_pins[1] = 0x16;
8431 alc_automute_amp(codec);
Takashi Iwai676a9b52007-08-16 15:23:35 +02008432}
8433
Kailang Yangd1a991a2007-08-15 16:21:59 +02008434static struct hda_verb alc883_acer_eapd_verbs[] = {
8435 /* HP Pin: output 0 (0x0c) */
8436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8437 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8438 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8439 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008440 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8441 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008442 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008443 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8444 /* eanable EAPD on medion laptop */
8445 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8446 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008447 /* enable unsolicited event */
8448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008449 { }
8450};
8451
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008452static void alc888_6st_dell_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008453{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008454 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008455
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008456 spec->autocfg.hp_pins[0] = 0x1b;
8457 spec->autocfg.speaker_pins[0] = 0x14;
8458 spec->autocfg.speaker_pins[1] = 0x15;
8459 spec->autocfg.speaker_pins[2] = 0x16;
8460 spec->autocfg.speaker_pins[3] = 0x17;
8461 alc_automute_amp(codec);
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008462}
8463
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008464static void alc888_lenovo_sky_init_hook(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008465{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008466 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008467
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008468 spec->autocfg.hp_pins[0] = 0x1b;
8469 spec->autocfg.speaker_pins[0] = 0x14;
8470 spec->autocfg.speaker_pins[1] = 0x15;
8471 spec->autocfg.speaker_pins[2] = 0x16;
8472 spec->autocfg.speaker_pins[3] = 0x17;
8473 spec->autocfg.speaker_pins[4] = 0x1a;
8474 alc_automute_amp(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008475}
8476
Guido Günther3e1647c2009-06-05 00:47:26 +02008477static void alc883_vaiott_init_hook(struct hda_codec *codec)
8478{
8479 struct alc_spec *spec = codec->spec;
8480
8481 spec->autocfg.hp_pins[0] = 0x15;
8482 spec->autocfg.speaker_pins[0] = 0x14;
8483 spec->autocfg.speaker_pins[1] = 0x17;
8484 alc_automute_amp(codec);
8485}
8486
Kailang Yange2757d52008-08-26 13:17:46 +02008487static struct hda_verb alc888_asus_m90v_verbs[] = {
8488 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8491 /* enable unsolicited event */
8492 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8493 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8494 { } /* end */
8495};
8496
8497static void alc883_nb_mic_automute(struct hda_codec *codec)
8498{
8499 unsigned int present;
8500
8501 present = snd_hda_codec_read(codec, 0x18, 0,
8502 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8503 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8504 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8505 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8506 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8507}
8508
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008509static void alc883_M90V_init_hook(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008510{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008511 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008512
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008513 spec->autocfg.hp_pins[0] = 0x1b;
8514 spec->autocfg.speaker_pins[0] = 0x14;
8515 spec->autocfg.speaker_pins[1] = 0x15;
8516 spec->autocfg.speaker_pins[2] = 0x16;
8517 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008518}
8519
8520static void alc883_mode2_unsol_event(struct hda_codec *codec,
8521 unsigned int res)
8522{
8523 switch (res >> 26) {
Kailang Yange2757d52008-08-26 13:17:46 +02008524 case ALC880_MIC_EVENT:
8525 alc883_nb_mic_automute(codec);
8526 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008527 default:
8528 alc_sku_unsol_event(codec, res);
8529 break;
Kailang Yange2757d52008-08-26 13:17:46 +02008530 }
8531}
8532
8533static void alc883_mode2_inithook(struct hda_codec *codec)
8534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 alc883_M90V_init_hook(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008536 alc883_nb_mic_automute(codec);
8537}
8538
8539static struct hda_verb alc888_asus_eee1601_verbs[] = {
8540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8541 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8542 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8545 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8546 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8547 /* enable unsolicited event */
8548 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8549 { } /* end */
8550};
8551
Kailang Yange2757d52008-08-26 13:17:46 +02008552static void alc883_eee1601_inithook(struct hda_codec *codec)
8553{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008554 struct alc_spec *spec = codec->spec;
8555
8556 spec->autocfg.hp_pins[0] = 0x14;
8557 spec->autocfg.speaker_pins[0] = 0x1b;
8558 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02008559}
8560
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008561static struct hda_verb alc889A_mb31_verbs[] = {
8562 /* Init rear pin (used as headphone output) */
8563 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
8564 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
8565 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8566 /* Init line pin (used as output in 4ch and 6ch mode) */
8567 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
8568 /* Init line 2 pin (used as headphone out by default) */
8569 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
8570 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
8571 { } /* end */
8572};
8573
8574/* Mute speakers according to the headphone jack state */
8575static void alc889A_mb31_automute(struct hda_codec *codec)
8576{
8577 unsigned int present;
8578
8579 /* Mute only in 2ch or 4ch mode */
8580 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
8581 == 0x00) {
8582 present = snd_hda_codec_read(codec, 0x15, 0,
8583 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
8584 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8585 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8586 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8587 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8588 }
8589}
8590
8591static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
8592{
8593 if ((res >> 26) == ALC880_HP_EVENT)
8594 alc889A_mb31_automute(codec);
8595}
8596
Takashi Iwai4953550a2009-06-30 15:28:30 +02008597
Takashi Iwaicb53c622007-08-10 17:21:45 +02008598#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02008599#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02008600#endif
8601
Sasha Alexandrdef319f2009-06-16 16:00:15 -04008602/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008603#define alc882_pcm_analog_playback alc880_pcm_analog_playback
8604#define alc882_pcm_analog_capture alc880_pcm_analog_capture
8605#define alc882_pcm_digital_playback alc880_pcm_digital_playback
8606#define alc882_pcm_digital_capture alc880_pcm_digital_capture
8607
8608static hda_nid_t alc883_slave_dig_outs[] = {
8609 ALC1200_DIGOUT_NID, 0,
8610};
8611
8612static hda_nid_t alc1200_slave_dig_outs[] = {
8613 ALC883_DIGOUT_NID, 0,
8614};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008615
8616/*
8617 * configuration and preset
8618 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008619static const char *alc882_models[ALC882_MODEL_LAST] = {
8620 [ALC882_3ST_DIG] = "3stack-dig",
8621 [ALC882_6ST_DIG] = "6stack-dig",
8622 [ALC882_ARIMA] = "arima",
8623 [ALC882_W2JC] = "w2jc",
8624 [ALC882_TARGA] = "targa",
8625 [ALC882_ASUS_A7J] = "asus-a7j",
8626 [ALC882_ASUS_A7M] = "asus-a7m",
8627 [ALC885_MACPRO] = "macpro",
8628 [ALC885_MB5] = "mb5",
8629 [ALC885_MBP3] = "mbp3",
8630 [ALC885_IMAC24] = "imac24",
8631 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008632 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8633 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008634 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008635 [ALC883_TARGA_DIG] = "targa-dig",
8636 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02008637 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008638 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008639 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008640 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02008641 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02008642 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008643 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008644 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008645 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008646 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008647 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8648 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008649 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008650 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008651 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008652 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008653 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008654 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008655 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008656 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008657 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008658 [ALC889A_INTEL] = "intel-alc889a",
8659 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008660 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008661 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02008662 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02008663 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008664};
8665
Takashi Iwai4953550a2009-06-30 15:28:30 +02008666static struct snd_pci_quirk alc882_cfg_tbl[] = {
8667 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
8668
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008669 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008670 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01008671 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008672 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8673 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008674 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008675 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8676 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008677 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
8678 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02008679 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
8680 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02008681 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
8682 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008683 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
8684 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008685 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02008686 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01008687 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01008688 ALC888_ACER_ASPIRE_6530G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02008689 /* default Acer -- disabled as it causes more problems.
8690 * model=auto should work fine now
8691 */
8692 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008693
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008694 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008695
Tobin Davisfebe3372007-06-12 11:27:46 +02008696 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008697 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8698 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008699 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008700 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03008701 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008702
8703 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
8704 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
8705 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008706 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008707 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
8708 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
8709 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008710 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008711 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008712 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008713 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008714
8715 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02008716 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008717 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008718 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008719 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8720 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008721 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008722 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008723 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
8724
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008725 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8726 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8727 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008728 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Jiang zhe4383fae2008-04-14 12:58:57 +02008729 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008730 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008731 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008732 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008733 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8734 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8735 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8736 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8737 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8738 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008739 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008740 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8741 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8742 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02008743 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008744 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8745 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008746 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008747 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008748 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008749 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008750 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04008751 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008752 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07008753 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008754
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008755 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008756 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8757 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008758 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008759 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008760 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008761 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008762 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01008763 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02008764 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008765 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008766 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008767 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008768 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8769 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008770 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008771 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008772 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008773 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008774 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008775
Jiang zhe17bba1b2008-06-04 12:11:07 +02008776 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8777 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008778 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008779 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
8780 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
8781 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008782 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02008783
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008784 {}
8785};
8786
Takashi Iwai4953550a2009-06-30 15:28:30 +02008787/* codec SSID table for Intel Mac */
8788static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
8789 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
8790 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
8791 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
8792 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
8793 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
8794 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
8795 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
8796 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
8797 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
8798 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
8799 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
8800 /* FIXME: HP jack sense seems not working for MBP 5,1, so apparently
8801 * no perfect solution yet
8802 */
8803 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
8804 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008805};
8806
Takashi Iwai4953550a2009-06-30 15:28:30 +02008807static struct alc_config_preset alc882_presets[] = {
8808 [ALC882_3ST_DIG] = {
8809 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008810 .init_verbs = { alc882_base_init_verbs,
8811 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008812 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8813 .dac_nids = alc882_dac_nids,
8814 .dig_out_nid = ALC882_DIGOUT_NID,
8815 .dig_in_nid = ALC882_DIGIN_NID,
8816 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8817 .channel_mode = alc882_ch_modes,
8818 .need_dac_fix = 1,
8819 .input_mux = &alc882_capture_source,
8820 },
8821 [ALC882_6ST_DIG] = {
8822 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008823 .init_verbs = { alc882_base_init_verbs,
8824 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008825 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8826 .dac_nids = alc882_dac_nids,
8827 .dig_out_nid = ALC882_DIGOUT_NID,
8828 .dig_in_nid = ALC882_DIGIN_NID,
8829 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8830 .channel_mode = alc882_sixstack_modes,
8831 .input_mux = &alc882_capture_source,
8832 },
8833 [ALC882_ARIMA] = {
8834 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008835 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8836 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008837 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8838 .dac_nids = alc882_dac_nids,
8839 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
8840 .channel_mode = alc882_sixstack_modes,
8841 .input_mux = &alc882_capture_source,
8842 },
8843 [ALC882_W2JC] = {
8844 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008845 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8846 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02008847 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8848 .dac_nids = alc882_dac_nids,
8849 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8850 .channel_mode = alc880_threestack_modes,
8851 .need_dac_fix = 1,
8852 .input_mux = &alc882_capture_source,
8853 .dig_out_nid = ALC882_DIGOUT_NID,
8854 },
8855 [ALC885_MBP3] = {
8856 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
8857 .init_verbs = { alc885_mbp3_init_verbs,
8858 alc880_gpio1_init_verbs },
8859 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8860 .dac_nids = alc882_dac_nids,
8861 .channel_mode = alc885_mbp_6ch_modes,
8862 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
8863 .input_mux = &alc882_capture_source,
8864 .dig_out_nid = ALC882_DIGOUT_NID,
8865 .dig_in_nid = ALC882_DIGIN_NID,
8866 .unsol_event = alc_automute_amp_unsol_event,
8867 .init_hook = alc885_mbp3_init_hook,
8868 },
8869 [ALC885_MB5] = {
8870 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
8871 .init_verbs = { alc885_mb5_init_verbs,
8872 alc880_gpio1_init_verbs },
8873 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8874 .dac_nids = alc882_dac_nids,
8875 .channel_mode = alc885_mb5_6ch_modes,
8876 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
8877 .input_mux = &mb5_capture_source,
8878 .dig_out_nid = ALC882_DIGOUT_NID,
8879 .dig_in_nid = ALC882_DIGIN_NID,
8880 },
8881 [ALC885_MACPRO] = {
8882 .mixers = { alc882_macpro_mixer },
8883 .init_verbs = { alc882_macpro_init_verbs },
8884 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8885 .dac_nids = alc882_dac_nids,
8886 .dig_out_nid = ALC882_DIGOUT_NID,
8887 .dig_in_nid = ALC882_DIGIN_NID,
8888 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8889 .channel_mode = alc882_ch_modes,
8890 .input_mux = &alc882_capture_source,
8891 .init_hook = alc885_macpro_init_hook,
8892 },
8893 [ALC885_IMAC24] = {
8894 .mixers = { alc885_imac24_mixer },
8895 .init_verbs = { alc885_imac24_init_verbs },
8896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8897 .dac_nids = alc882_dac_nids,
8898 .dig_out_nid = ALC882_DIGOUT_NID,
8899 .dig_in_nid = ALC882_DIGIN_NID,
8900 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
8901 .channel_mode = alc882_ch_modes,
8902 .input_mux = &alc882_capture_source,
8903 .unsol_event = alc_automute_amp_unsol_event,
8904 .init_hook = alc885_imac24_init_hook,
8905 },
8906 [ALC882_TARGA] = {
8907 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008908 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02008909 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008910 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8911 .dac_nids = alc882_dac_nids,
8912 .dig_out_nid = ALC882_DIGOUT_NID,
8913 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8914 .adc_nids = alc882_adc_nids,
8915 .capsrc_nids = alc882_capsrc_nids,
8916 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8917 .channel_mode = alc882_3ST_6ch_modes,
8918 .need_dac_fix = 1,
8919 .input_mux = &alc882_capture_source,
8920 .unsol_event = alc882_targa_unsol_event,
8921 .init_hook = alc882_targa_init_hook,
8922 },
8923 [ALC882_ASUS_A7J] = {
8924 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008925 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8926 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02008927 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8928 .dac_nids = alc882_dac_nids,
8929 .dig_out_nid = ALC882_DIGOUT_NID,
8930 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
8931 .adc_nids = alc882_adc_nids,
8932 .capsrc_nids = alc882_capsrc_nids,
8933 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
8934 .channel_mode = alc882_3ST_6ch_modes,
8935 .need_dac_fix = 1,
8936 .input_mux = &alc882_capture_source,
8937 },
8938 [ALC882_ASUS_A7M] = {
8939 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02008940 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
8941 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02008942 alc882_asus_a7m_verbs },
8943 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
8944 .dac_nids = alc882_dac_nids,
8945 .dig_out_nid = ALC882_DIGOUT_NID,
8946 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
8947 .channel_mode = alc880_threestack_modes,
8948 .need_dac_fix = 1,
8949 .input_mux = &alc882_capture_source,
8950 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008951 [ALC883_3ST_2ch_DIG] = {
8952 .mixers = { alc883_3ST_2ch_mixer },
8953 .init_verbs = { alc883_init_verbs },
8954 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8955 .dac_nids = alc883_dac_nids,
8956 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008957 .dig_in_nid = ALC883_DIGIN_NID,
8958 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8959 .channel_mode = alc883_3ST_2ch_modes,
8960 .input_mux = &alc883_capture_source,
8961 },
8962 [ALC883_3ST_6ch_DIG] = {
8963 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8964 .init_verbs = { alc883_init_verbs },
8965 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8966 .dac_nids = alc883_dac_nids,
8967 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008968 .dig_in_nid = ALC883_DIGIN_NID,
8969 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8970 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008971 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008972 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008973 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008974 [ALC883_3ST_6ch] = {
8975 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8976 .init_verbs = { alc883_init_verbs },
8977 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8978 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008979 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8980 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008981 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008982 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008983 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008984 [ALC883_3ST_6ch_INTEL] = {
8985 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8986 .init_verbs = { alc883_init_verbs },
8987 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8988 .dac_nids = alc883_dac_nids,
8989 .dig_out_nid = ALC883_DIGOUT_NID,
8990 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08008991 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02008992 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8993 .channel_mode = alc883_3ST_6ch_intel_modes,
8994 .need_dac_fix = 1,
8995 .input_mux = &alc883_3stack_6ch_intel,
8996 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008997 [ALC889A_INTEL] = {
8998 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02008999 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9000 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009001 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9002 .dac_nids = alc883_dac_nids,
9003 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9004 .adc_nids = alc889_adc_nids,
9005 .dig_out_nid = ALC883_DIGOUT_NID,
9006 .dig_in_nid = ALC883_DIGIN_NID,
9007 .slave_dig_outs = alc883_slave_dig_outs,
9008 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9009 .channel_mode = alc889_8ch_intel_modes,
9010 .capsrc_nids = alc889_capsrc_nids,
9011 .input_mux = &alc889_capture_source,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009012 .init_hook = alc889_automute_init,
9013 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009014 .need_dac_fix = 1,
9015 },
9016 [ALC889_INTEL] = {
9017 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9018 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009019 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9021 .dac_nids = alc883_dac_nids,
9022 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9023 .adc_nids = alc889_adc_nids,
9024 .dig_out_nid = ALC883_DIGOUT_NID,
9025 .dig_in_nid = ALC883_DIGIN_NID,
9026 .slave_dig_outs = alc883_slave_dig_outs,
9027 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9028 .channel_mode = alc889_8ch_intel_modes,
9029 .capsrc_nids = alc889_capsrc_nids,
9030 .input_mux = &alc889_capture_source,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009031 .init_hook = alc889_intel_init_hook,
9032 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009033 .need_dac_fix = 1,
9034 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009035 [ALC883_6ST_DIG] = {
9036 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9037 .init_verbs = { alc883_init_verbs },
9038 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9039 .dac_nids = alc883_dac_nids,
9040 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009041 .dig_in_nid = ALC883_DIGIN_NID,
9042 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9043 .channel_mode = alc883_sixstack_modes,
9044 .input_mux = &alc883_capture_source,
9045 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009046 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009047 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009048 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9049 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009050 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9051 .dac_nids = alc883_dac_nids,
9052 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009053 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9054 .channel_mode = alc883_3ST_6ch_modes,
9055 .need_dac_fix = 1,
9056 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009057 .unsol_event = alc883_targa_unsol_event,
9058 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009059 },
9060 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009061 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009062 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9063 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009064 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9065 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009066 .adc_nids = alc883_adc_nids_alt,
9067 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02009068 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9070 .channel_mode = alc883_3ST_2ch_modes,
9071 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009072 .unsol_event = alc883_targa_unsol_event,
9073 .init_hook = alc883_targa_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02009074 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009075 [ALC883_TARGA_8ch_DIG] = {
9076 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9077 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009078 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009079 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9080 .dac_nids = alc883_dac_nids,
9081 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9082 .adc_nids = alc883_adc_nids_rev,
9083 .capsrc_nids = alc883_capsrc_nids_rev,
9084 .dig_out_nid = ALC883_DIGOUT_NID,
9085 .dig_in_nid = ALC883_DIGIN_NID,
9086 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9087 .channel_mode = alc883_4ST_8ch_modes,
9088 .need_dac_fix = 1,
9089 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009090 .unsol_event = alc883_targa_unsol_event,
9091 .init_hook = alc883_targa_init_hook,
David Heidelberger64a8be72009-06-08 16:15:18 +02009092 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009093 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009094 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009095 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9096 * and the headphone jack. Turn this on and rely on the
9097 * standard mute methods whenever the user wants to turn
9098 * these outputs off.
9099 */
9100 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9102 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009103 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9104 .channel_mode = alc883_3ST_2ch_modes,
9105 .input_mux = &alc883_capture_source,
9106 },
Tobin Davis2880a862007-08-07 11:50:26 +02009107 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009108 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009109 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009110 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9111 .dac_nids = alc883_dac_nids,
9112 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009113 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9114 .channel_mode = alc883_3ST_2ch_modes,
9115 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009116 .unsol_event = alc_automute_amp_unsol_event,
9117 .init_hook = alc883_acer_aspire_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009118 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009119 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009120 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009121 alc883_chmode_mixer },
9122 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9123 alc888_acer_aspire_4930g_verbs },
9124 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9125 .dac_nids = alc883_dac_nids,
9126 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9127 .adc_nids = alc883_adc_nids_rev,
9128 .capsrc_nids = alc883_capsrc_nids_rev,
9129 .dig_out_nid = ALC883_DIGOUT_NID,
9130 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9131 .channel_mode = alc883_3ST_6ch_modes,
9132 .need_dac_fix = 1,
9133 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009134 ARRAY_SIZE(alc888_2_capture_sources),
9135 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009136 .unsol_event = alc_automute_amp_unsol_event,
9137 .init_hook = alc888_acer_aspire_4930g_init_hook,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009138 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009139 [ALC888_ACER_ASPIRE_6530G] = {
9140 .mixers = { alc888_acer_aspire_6530_mixer },
9141 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9142 alc888_acer_aspire_6530g_verbs },
9143 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9144 .dac_nids = alc883_dac_nids,
9145 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9146 .adc_nids = alc883_adc_nids_rev,
9147 .capsrc_nids = alc883_capsrc_nids_rev,
9148 .dig_out_nid = ALC883_DIGOUT_NID,
9149 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9150 .channel_mode = alc883_3ST_2ch_modes,
9151 .num_mux_defs =
9152 ARRAY_SIZE(alc888_2_capture_sources),
9153 .input_mux = alc888_acer_aspire_6530_sources,
9154 .unsol_event = alc_automute_amp_unsol_event,
Emilio López320d5922009-06-25 08:18:44 +02009155 .init_hook = alc888_acer_aspire_6530g_init_hook,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009156 },
Hector Martin3b315d72009-06-02 10:54:19 +02009157 [ALC888_ACER_ASPIRE_8930G] = {
9158 .mixers = { alc888_base_mixer,
9159 alc883_chmode_mixer },
9160 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin018df412009-06-04 00:13:40 +02009161 alc889_acer_aspire_8930g_verbs },
Hector Martin3b315d72009-06-02 10:54:19 +02009162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9163 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009164 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9165 .adc_nids = alc889_adc_nids,
9166 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009167 .dig_out_nid = ALC883_DIGOUT_NID,
9168 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9169 .channel_mode = alc883_3ST_6ch_modes,
9170 .need_dac_fix = 1,
9171 .const_channel_count = 6,
9172 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009173 ARRAY_SIZE(alc889_capture_sources),
9174 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009175 .unsol_event = alc_automute_amp_unsol_event,
Hector Martin018df412009-06-04 00:13:40 +02009176 .init_hook = alc889_acer_aspire_8930g_init_hook,
Hector Martin3b315d72009-06-02 10:54:19 +02009177 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009178 [ALC883_MEDION] = {
9179 .mixers = { alc883_fivestack_mixer,
9180 alc883_chmode_mixer },
9181 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009182 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009183 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9184 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009185 .adc_nids = alc883_adc_nids_alt,
9186 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02009187 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9188 .channel_mode = alc883_sixstack_modes,
9189 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009190 },
Kailang Yang272a5272007-05-14 11:00:38 +02009191 [ALC883_MEDION_MD2] = {
9192 .mixers = { alc883_medion_md2_mixer},
9193 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9194 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9195 .dac_nids = alc883_dac_nids,
9196 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009197 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9198 .channel_mode = alc883_3ST_2ch_modes,
9199 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009200 .unsol_event = alc_automute_amp_unsol_event,
9201 .init_hook = alc883_medion_md2_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +02009202 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009203 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009204 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009205 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9206 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9207 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009208 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9209 .channel_mode = alc883_3ST_2ch_modes,
9210 .input_mux = &alc883_capture_source,
9211 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009212 [ALC883_CLEVO_M720] = {
9213 .mixers = { alc883_clevo_m720_mixer },
9214 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009215 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9216 .dac_nids = alc883_dac_nids,
9217 .dig_out_nid = ALC883_DIGOUT_NID,
9218 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9219 .channel_mode = alc883_3ST_2ch_modes,
9220 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009221 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009222 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009223 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009224 [ALC883_LENOVO_101E_2ch] = {
9225 .mixers = { alc883_lenovo_101e_2ch_mixer},
9226 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9227 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9228 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009229 .adc_nids = alc883_adc_nids_alt,
9230 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009231 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9232 .channel_mode = alc883_3ST_2ch_modes,
9233 .input_mux = &alc883_lenovo_101e_capture_source,
9234 .unsol_event = alc883_lenovo_101e_unsol_event,
9235 .init_hook = alc883_lenovo_101e_all_automute,
9236 },
Kailang Yang272a5272007-05-14 11:00:38 +02009237 [ALC883_LENOVO_NB0763] = {
9238 .mixers = { alc883_lenovo_nb0763_mixer },
9239 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9241 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009242 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9243 .channel_mode = alc883_3ST_2ch_modes,
9244 .need_dac_fix = 1,
9245 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009246 .unsol_event = alc_automute_amp_unsol_event,
9247 .init_hook = alc883_medion_md2_init_hook,
Kailang Yang272a5272007-05-14 11:00:38 +02009248 },
9249 [ALC888_LENOVO_MS7195_DIG] = {
9250 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9251 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9252 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9253 .dac_nids = alc883_dac_nids,
9254 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009255 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9256 .channel_mode = alc883_3ST_6ch_modes,
9257 .need_dac_fix = 1,
9258 .input_mux = &alc883_capture_source,
9259 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9260 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009261 },
9262 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009263 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009264 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9265 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9266 .dac_nids = alc883_dac_nids,
9267 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009268 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9269 .channel_mode = alc883_3ST_2ch_modes,
9270 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009271 .unsol_event = alc_automute_amp_unsol_event,
9272 .init_hook = alc883_haier_w66_init_hook,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009273 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009274 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009275 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009276 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009277 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9278 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009279 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9280 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009281 .need_dac_fix = 1,
9282 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009283 .unsol_event = alc_automute_amp_unsol_event,
9284 .init_hook = alc888_3st_hp_init_hook,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009285 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009286 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009287 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009288 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9290 .dac_nids = alc883_dac_nids,
9291 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009292 .dig_in_nid = ALC883_DIGIN_NID,
9293 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9294 .channel_mode = alc883_sixstack_modes,
9295 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009296 .unsol_event = alc_automute_amp_unsol_event,
9297 .init_hook = alc888_6st_dell_init_hook,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009298 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009299 [ALC883_MITAC] = {
9300 .mixers = { alc883_mitac_mixer },
9301 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9303 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009304 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9305 .channel_mode = alc883_3ST_2ch_modes,
9306 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009307 .unsol_event = alc_automute_amp_unsol_event,
9308 .init_hook = alc883_mitac_init_hook,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009309 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009310 [ALC883_FUJITSU_PI2515] = {
9311 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9312 .init_verbs = { alc883_init_verbs,
9313 alc883_2ch_fujitsu_pi2515_verbs},
9314 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9315 .dac_nids = alc883_dac_nids,
9316 .dig_out_nid = ALC883_DIGOUT_NID,
9317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9318 .channel_mode = alc883_3ST_2ch_modes,
9319 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009320 .unsol_event = alc_automute_amp_unsol_event,
9321 .init_hook = alc883_2ch_fujitsu_pi2515_init_hook,
Jiang zhefb97dc62008-03-06 11:07:11 +01009322 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009323 [ALC888_FUJITSU_XA3530] = {
9324 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9325 .init_verbs = { alc883_init_verbs,
9326 alc888_fujitsu_xa3530_verbs },
9327 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9328 .dac_nids = alc883_dac_nids,
9329 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9330 .adc_nids = alc883_adc_nids_rev,
9331 .capsrc_nids = alc883_capsrc_nids_rev,
9332 .dig_out_nid = ALC883_DIGOUT_NID,
9333 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9334 .channel_mode = alc888_4ST_8ch_intel_modes,
9335 .num_mux_defs =
9336 ARRAY_SIZE(alc888_2_capture_sources),
9337 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009338 .unsol_event = alc_automute_amp_unsol_event,
9339 .init_hook = alc888_fujitsu_xa3530_init_hook,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009340 },
Kailang Yange2757d52008-08-26 13:17:46 +02009341 [ALC888_LENOVO_SKY] = {
9342 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9343 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9344 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9345 .dac_nids = alc883_dac_nids,
9346 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009347 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9348 .channel_mode = alc883_sixstack_modes,
9349 .need_dac_fix = 1,
9350 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009351 .unsol_event = alc_automute_amp_unsol_event,
9352 .init_hook = alc888_lenovo_sky_init_hook,
Kailang Yange2757d52008-08-26 13:17:46 +02009353 },
9354 [ALC888_ASUS_M90V] = {
9355 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9356 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9357 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9358 .dac_nids = alc883_dac_nids,
9359 .dig_out_nid = ALC883_DIGOUT_NID,
9360 .dig_in_nid = ALC883_DIGIN_NID,
9361 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9362 .channel_mode = alc883_3ST_6ch_modes,
9363 .need_dac_fix = 1,
9364 .input_mux = &alc883_fujitsu_pi2515_capture_source,
9365 .unsol_event = alc883_mode2_unsol_event,
9366 .init_hook = alc883_mode2_inithook,
9367 },
9368 [ALC888_ASUS_EEE1601] = {
9369 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009370 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009371 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9372 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9373 .dac_nids = alc883_dac_nids,
9374 .dig_out_nid = ALC883_DIGOUT_NID,
9375 .dig_in_nid = ALC883_DIGIN_NID,
9376 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9377 .channel_mode = alc883_3ST_2ch_modes,
9378 .need_dac_fix = 1,
9379 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009380 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009381 .init_hook = alc883_eee1601_inithook,
9382 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009383 [ALC1200_ASUS_P5Q] = {
9384 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9385 .init_verbs = { alc883_init_verbs },
9386 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9387 .dac_nids = alc883_dac_nids,
9388 .dig_out_nid = ALC1200_DIGOUT_NID,
9389 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009390 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009391 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9392 .channel_mode = alc883_sixstack_modes,
9393 .input_mux = &alc883_capture_source,
9394 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009395 [ALC889A_MB31] = {
9396 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9397 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9398 alc880_gpio1_init_verbs },
9399 .adc_nids = alc883_adc_nids,
9400 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
9401 .dac_nids = alc883_dac_nids,
9402 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9403 .channel_mode = alc889A_mb31_6ch_modes,
9404 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9405 .input_mux = &alc889A_mb31_capture_source,
9406 .dig_out_nid = ALC883_DIGOUT_NID,
9407 .unsol_event = alc889A_mb31_unsol_event,
9408 .init_hook = alc889A_mb31_automute,
9409 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009410 [ALC883_SONY_VAIO_TT] = {
9411 .mixers = { alc883_vaiott_mixer },
9412 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9414 .dac_nids = alc883_dac_nids,
9415 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9416 .channel_mode = alc883_3ST_2ch_modes,
9417 .input_mux = &alc883_capture_source,
9418 .unsol_event = alc_automute_amp_unsol_event,
9419 .init_hook = alc883_vaiott_init_hook,
9420 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009421};
9422
9423
9424/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02009425 * Pin config fixes
9426 */
9427enum {
9428 PINFIX_ABIT_AW9D_MAX
9429};
9430
9431static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
9432 { 0x15, 0x01080104 }, /* side */
9433 { 0x16, 0x01011012 }, /* rear */
9434 { 0x17, 0x01016011 }, /* clfe */
9435 { }
9436};
9437
9438static const struct alc_pincfg *alc882_pin_fixes[] = {
9439 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
9440};
9441
9442static struct snd_pci_quirk alc882_pinfix_tbl[] = {
9443 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
9444 {}
9445};
9446
9447/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009448 * BIOS auto configuration
9449 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009450static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009451 hda_nid_t nid, int pin_type,
9452 int dac_idx)
9453{
9454 /* set as output */
9455 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009456 int idx;
9457
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009458 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009459 if (spec->multiout.dac_nids[dac_idx] == 0x25)
9460 idx = 4;
9461 else
9462 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009463 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
9464
9465}
9466
Takashi Iwai4953550a2009-06-30 15:28:30 +02009467static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009468{
9469 struct alc_spec *spec = codec->spec;
9470 int i;
9471
9472 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009473 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009474 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009475 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009476 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009477 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009478 }
9479}
9480
Takashi Iwai4953550a2009-06-30 15:28:30 +02009481static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009482{
9483 struct alc_spec *spec = codec->spec;
9484 hda_nid_t pin;
9485
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009486 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009487 if (pin) /* connect to front */
9488 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009489 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009490 pin = spec->autocfg.speaker_pins[0];
9491 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009492 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009493}
9494
Takashi Iwai4953550a2009-06-30 15:28:30 +02009495static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009496{
9497 struct alc_spec *spec = codec->spec;
9498 int i;
9499
9500 for (i = 0; i < AUTO_PIN_LAST; i++) {
9501 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502 if (!nid)
9503 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +02009504 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009505 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
9506 snd_hda_codec_write(codec, nid, 0,
9507 AC_VERB_SET_AMP_GAIN_MUTE,
9508 AMP_OUT_MUTE);
9509 }
9510}
9511
9512static void alc882_auto_init_input_src(struct hda_codec *codec)
9513{
9514 struct alc_spec *spec = codec->spec;
9515 int c;
9516
9517 for (c = 0; c < spec->num_adc_nids; c++) {
9518 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
9519 hda_nid_t nid = spec->capsrc_nids[c];
9520 unsigned int mux_idx;
9521 const struct hda_input_mux *imux;
9522 int conns, mute, idx, item;
9523
9524 conns = snd_hda_get_connections(codec, nid, conn_list,
9525 ARRAY_SIZE(conn_list));
9526 if (conns < 0)
9527 continue;
9528 mux_idx = c >= spec->num_mux_defs ? 0 : c;
9529 imux = &spec->input_mux[mux_idx];
9530 for (idx = 0; idx < conns; idx++) {
9531 /* if the current connection is the selected one,
9532 * unmute it as default - otherwise mute it
9533 */
9534 mute = AMP_IN_MUTE(idx);
9535 for (item = 0; item < imux->num_items; item++) {
9536 if (imux->items[item].index == idx) {
9537 if (spec->cur_mux[c] == item)
9538 mute = AMP_IN_UNMUTE(idx);
9539 break;
9540 }
9541 }
9542 /* check if we have a selector or mixer
9543 * we could check for the widget type instead, but
9544 * just check for Amp-In presence (in case of mixer
9545 * without amp-in there is something wrong, this
9546 * function shouldn't be used or capsrc nid is wrong)
9547 */
9548 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009549 snd_hda_codec_write(codec, nid, 0,
9550 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009551 mute);
9552 else if (mute != AMP_IN_MUTE(idx))
9553 snd_hda_codec_write(codec, nid, 0,
9554 AC_VERB_SET_CONNECT_SEL,
9555 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009556 }
9557 }
9558}
9559
Takashi Iwai4953550a2009-06-30 15:28:30 +02009560/* add mic boosts if needed */
9561static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009562{
9563 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009564 int err;
9565 hda_nid_t nid;
9566
9567 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
9568 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9569 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9570 "Mic Boost",
9571 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9572 if (err < 0)
9573 return err;
9574 }
9575 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
9576 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
9577 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9578 "Front Mic Boost",
9579 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
9580 if (err < 0)
9581 return err;
9582 }
9583 return 0;
9584}
9585
9586/* almost identical with ALC880 parser... */
9587static int alc882_parse_auto_config(struct hda_codec *codec)
9588{
9589 struct alc_spec *spec = codec->spec;
9590 struct auto_pin_cfg *autocfg = &spec->autocfg;
9591 unsigned int wcap;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009592 int i;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009593 int err = alc880_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009594
9595 if (err < 0)
9596 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009597 else if (!err)
9598 return 0; /* no config found */
9599
9600 err = alc_auto_add_mic_boost(codec);
9601 if (err < 0)
9602 return err;
9603
9604 /* hack - override the init verbs */
9605 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009606 /* if ADC 0x07 is available, initialize it, too */
9607 wcap = get_wcaps(codec, 0x07);
Takashi Iwaia22d5432009-07-27 12:54:26 +02009608 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009609 if (wcap == AC_WID_AUD_IN)
9610 add_verb(spec, alc882_adc1_init_verbs);
Takashi Iwai776e1842007-08-29 15:07:11 +02009611
Takashi Iwai4953550a2009-06-30 15:28:30 +02009612 /* digital-mic input pin is excluded in alc880_auto_create..()
9613 * because it's under 0x18
9614 */
9615 if (autocfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9616 autocfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9617 struct hda_input_mux *imux = &spec->private_imux[0];
9618 for (i = 1; i < 3; i++)
9619 memcpy(&spec->private_imux[i],
9620 &spec->private_imux[0],
9621 sizeof(spec->private_imux[0]));
9622 imux->items[imux->num_items].label = "Int DMic";
9623 imux->items[imux->num_items].index = 0x0b;
9624 imux->num_items++;
9625 spec->num_mux_defs = 3;
9626 spec->input_mux = spec->private_imux;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009627 }
9628
Takashi Iwai776e1842007-08-29 15:07:11 +02009629 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009630}
9631
9632/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009633static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009634{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009635 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009636 alc882_auto_init_multi_out(codec);
9637 alc882_auto_init_hp_out(codec);
9638 alc882_auto_init_analog_input(codec);
9639 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009640 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009641 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009642}
9643
Takashi Iwai4953550a2009-06-30 15:28:30 +02009644static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009645{
9646 struct alc_spec *spec;
9647 int err, board_config;
9648
9649 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9650 if (spec == NULL)
9651 return -ENOMEM;
9652
9653 codec->spec = spec;
9654
Takashi Iwai4953550a2009-06-30 15:28:30 +02009655 switch (codec->vendor_id) {
9656 case 0x10ec0882:
9657 case 0x10ec0885:
9658 break;
9659 default:
9660 /* ALC883 and variants */
9661 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9662 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009663 }
9664
Takashi Iwai4953550a2009-06-30 15:28:30 +02009665 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
9666 alc882_models,
9667 alc882_cfg_tbl);
9668
9669 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
9670 board_config = snd_hda_check_board_codec_sid_config(codec,
9671 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
9672
9673 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02009674 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009675 codec->chip_name);
9676 board_config = ALC882_AUTO;
9677 }
9678
9679 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
9680
9681 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009682 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009684 if (err < 0) {
9685 alc_free(codec);
9686 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009687 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009688 printk(KERN_INFO
9689 "hda_codec: Cannot set up configuration "
9690 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +02009691 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009692 }
9693 }
9694
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009695 err = snd_hda_attach_beep_device(codec, 0x1);
9696 if (err < 0) {
9697 alc_free(codec);
9698 return err;
9699 }
9700
Takashi Iwai4953550a2009-06-30 15:28:30 +02009701 if (board_config != ALC882_AUTO)
9702 setup_preset(spec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009703
Takashi Iwai4953550a2009-06-30 15:28:30 +02009704 spec->stream_analog_playback = &alc882_pcm_analog_playback;
9705 spec->stream_analog_capture = &alc882_pcm_analog_capture;
9706 /* FIXME: setup DAC5 */
9707 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
9708 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
9709
9710 spec->stream_digital_playback = &alc882_pcm_digital_playback;
9711 spec->stream_digital_capture = &alc882_pcm_digital_capture;
9712
9713 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02009714 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009715
9716 if (!spec->adc_nids && spec->input_mux) {
9717 int i;
9718 spec->num_adc_nids = 0;
9719 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
9720 hda_nid_t cap;
9721 hda_nid_t nid = alc882_adc_nids[i];
9722 unsigned int wcap = get_wcaps(codec, nid);
9723 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02009724 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +02009725 if (wcap != AC_WID_AUD_IN)
9726 continue;
9727 spec->private_adc_nids[spec->num_adc_nids] = nid;
9728 err = snd_hda_get_connections(codec, nid, &cap, 1);
9729 if (err < 0)
9730 continue;
9731 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
9732 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009733 }
Takashi Iwai4953550a2009-06-30 15:28:30 +02009734 spec->adc_nids = spec->private_adc_nids;
9735 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +02009736 }
9737
Takashi Iwai4953550a2009-06-30 15:28:30 +02009738 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009739 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009740
Takashi Iwai2134ea42008-01-10 16:53:55 +01009741 spec->vmaster_nid = 0x0c;
9742
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009743 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +02009744 if (board_config == ALC882_AUTO)
9745 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009746#ifdef CONFIG_SND_HDA_POWER_SAVE
9747 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +02009748 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +02009749#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009750 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009751
9752 return 0;
9753}
9754
Takashi Iwai4953550a2009-06-30 15:28:30 +02009755
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009756/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009757 * ALC262 support
9758 */
9759
9760#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9761#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9762
9763#define alc262_dac_nids alc260_dac_nids
9764#define alc262_adc_nids alc882_adc_nids
9765#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009766#define alc262_capsrc_nids alc882_capsrc_nids
9767#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009768
9769#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009770#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009771
Kailang Yang4e555fe2008-08-26 13:05:55 +02009772static hda_nid_t alc262_dmic_adc_nids[1] = {
9773 /* ADC0 */
9774 0x09
9775};
9776
9777static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9778
Kailang Yangdf694da2005-12-05 19:42:22 +01009779static struct snd_kcontrol_new alc262_base_mixer[] = {
9780 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9781 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9782 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9783 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9784 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9785 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9786 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9787 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009788 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009789 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9790 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009791 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009792 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9793 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9794 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9795 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009796 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009797};
9798
Takashi Iwaice875f02008-01-28 18:17:43 +01009799/* update HP, line and mono-out pins according to the master switch */
9800static void alc262_hp_master_update(struct hda_codec *codec)
9801{
9802 struct alc_spec *spec = codec->spec;
9803 int val = spec->master_sw;
9804
9805 /* HP & line-out */
9806 snd_hda_codec_write_cache(codec, 0x1b, 0,
9807 AC_VERB_SET_PIN_WIDGET_CONTROL,
9808 val ? PIN_HP : 0);
9809 snd_hda_codec_write_cache(codec, 0x15, 0,
9810 AC_VERB_SET_PIN_WIDGET_CONTROL,
9811 val ? PIN_HP : 0);
9812 /* mono (speaker) depending on the HP jack sense */
9813 val = val && !spec->jack_present;
9814 snd_hda_codec_write_cache(codec, 0x16, 0,
9815 AC_VERB_SET_PIN_WIDGET_CONTROL,
9816 val ? PIN_OUT : 0);
9817}
9818
9819static void alc262_hp_bpc_automute(struct hda_codec *codec)
9820{
9821 struct alc_spec *spec = codec->spec;
9822 unsigned int presence;
9823 presence = snd_hda_codec_read(codec, 0x1b, 0,
9824 AC_VERB_GET_PIN_SENSE, 0);
9825 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9826 alc262_hp_master_update(codec);
9827}
9828
9829static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9830{
9831 if ((res >> 26) != ALC880_HP_EVENT)
9832 return;
9833 alc262_hp_bpc_automute(codec);
9834}
9835
9836static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9837{
9838 struct alc_spec *spec = codec->spec;
9839 unsigned int presence;
9840 presence = snd_hda_codec_read(codec, 0x15, 0,
9841 AC_VERB_GET_PIN_SENSE, 0);
9842 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9843 alc262_hp_master_update(codec);
9844}
9845
9846static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9847 unsigned int res)
9848{
9849 if ((res >> 26) != ALC880_HP_EVENT)
9850 return;
9851 alc262_hp_wildwest_automute(codec);
9852}
9853
Takashi Iwaib72519b2009-05-08 14:31:55 +02009854#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +01009855
9856static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9857 struct snd_ctl_elem_value *ucontrol)
9858{
9859 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9860 struct alc_spec *spec = codec->spec;
9861 int val = !!*ucontrol->value.integer.value;
9862
9863 if (val == spec->master_sw)
9864 return 0;
9865 spec->master_sw = val;
9866 alc262_hp_master_update(codec);
9867 return 1;
9868}
9869
Takashi Iwaib72519b2009-05-08 14:31:55 +02009870#define ALC262_HP_MASTER_SWITCH \
9871 { \
9872 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
9873 .name = "Master Playback Switch", \
9874 .info = snd_ctl_boolean_mono_info, \
9875 .get = alc262_hp_master_sw_get, \
9876 .put = alc262_hp_master_sw_put, \
9877 }
9878
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009879static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009880 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009881 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9882 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9883 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009884 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9885 HDA_OUTPUT),
9886 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9887 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009891 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9892 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009893 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9896 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9897 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009898 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9899 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9900 { } /* end */
9901};
9902
Kailang Yangcd7509a2007-01-26 18:33:17 +01009903static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +02009904 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +01009905 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9906 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009909 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9910 HDA_OUTPUT),
9911 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9912 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009913 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9914 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009915 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009916 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9917 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9918 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9919 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009920 { } /* end */
9921};
9922
9923static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9924 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9925 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009926 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009927 { } /* end */
9928};
9929
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009930/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009931static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009932{
9933 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009934
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009935 spec->autocfg.hp_pins[0] = 0x15;
9936 spec->autocfg.speaker_pins[0] = 0x0c; /* HACK: not actually a pin */
9937 alc_automute_amp(codec);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009938}
9939
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009940static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009941 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9942 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009943 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9945 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9946 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9948 { } /* end */
9949};
9950
9951static struct hda_verb alc262_hp_t5735_verbs[] = {
9952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9954
9955 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9956 { }
9957};
9958
Kailang Yang8c427222008-01-10 13:03:59 +01009959static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009960 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009962 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9963 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009964 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9965 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9966 { } /* end */
9967};
9968
9969static struct hda_verb alc262_hp_rp5700_verbs[] = {
9970 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9971 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9974 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9975 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9977 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9979 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9980 {}
9981};
9982
9983static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9984 .num_items = 1,
9985 .items = {
9986 { "Line", 0x1 },
9987 },
9988};
9989
Takashi Iwai42171c12009-05-08 14:11:43 +02009990/* bind hp and internal speaker mute (with plug check) as master switch */
9991static void alc262_hippo_master_update(struct hda_codec *codec)
9992{
9993 struct alc_spec *spec = codec->spec;
9994 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
9995 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
9996 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
9997 unsigned int mute;
9998
9999 /* HP */
10000 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10001 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10002 HDA_AMP_MUTE, mute);
10003 /* mute internal speaker per jack sense */
10004 if (spec->jack_present)
10005 mute = HDA_AMP_MUTE;
10006 if (line_nid)
10007 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10008 HDA_AMP_MUTE, mute);
10009 if (speaker_nid && speaker_nid != line_nid)
10010 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10011 HDA_AMP_MUTE, mute);
10012}
10013
10014#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10015
10016static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10017 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010018{
10019 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010020 struct alc_spec *spec = codec->spec;
10021 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010022
Takashi Iwai42171c12009-05-08 14:11:43 +020010023 if (val == spec->master_sw)
10024 return 0;
10025 spec->master_sw = val;
10026 alc262_hippo_master_update(codec);
10027 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010028}
Takashi Iwai5b319542007-07-26 11:49:22 +020010029
Takashi Iwai42171c12009-05-08 14:11:43 +020010030#define ALC262_HIPPO_MASTER_SWITCH \
10031 { \
10032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10033 .name = "Master Playback Switch", \
10034 .info = snd_ctl_boolean_mono_info, \
10035 .get = alc262_hippo_master_sw_get, \
10036 .put = alc262_hippo_master_sw_put, \
10037 }
10038
10039static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10040 ALC262_HIPPO_MASTER_SWITCH,
10041 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10042 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10043 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10044 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10045 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10046 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10047 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10048 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10049 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10050 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10051 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10053 { } /* end */
10054};
10055
10056static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10057 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10058 ALC262_HIPPO_MASTER_SWITCH,
10059 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10060 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10061 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10062 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10063 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10064 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10065 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10066 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10067 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10068 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10069 { } /* end */
10070};
10071
10072/* mute/unmute internal speaker according to the hp jack and mute state */
10073static void alc262_hippo_automute(struct hda_codec *codec)
10074{
10075 struct alc_spec *spec = codec->spec;
10076 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10077 unsigned int present;
10078
10079 /* need to execute and sync at first */
10080 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
10081 present = snd_hda_codec_read(codec, hp_nid, 0,
10082 AC_VERB_GET_PIN_SENSE, 0);
10083 spec->jack_present = (present & 0x80000000) != 0;
10084 alc262_hippo_master_update(codec);
10085}
10086
10087static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10088{
10089 if ((res >> 26) != ALC880_HP_EVENT)
10090 return;
10091 alc262_hippo_automute(codec);
10092}
10093
10094static void alc262_hippo_init_hook(struct hda_codec *codec)
10095{
10096 struct alc_spec *spec = codec->spec;
10097
10098 spec->autocfg.hp_pins[0] = 0x15;
10099 spec->autocfg.speaker_pins[0] = 0x14;
10100 alc262_hippo_automute(codec);
10101}
10102
10103static void alc262_hippo1_init_hook(struct hda_codec *codec)
10104{
10105 struct alc_spec *spec = codec->spec;
10106
10107 spec->autocfg.hp_pins[0] = 0x1b;
10108 spec->autocfg.speaker_pins[0] = 0x14;
10109 alc262_hippo_automute(codec);
10110}
10111
10112
Kailang Yang272a5272007-05-14 11:00:38 +020010113static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010114 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010115 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10118 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10119 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10120 { } /* end */
10121};
10122
Kailang Yang83c34212007-07-05 11:43:05 +020010123static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010124 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10125 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10129 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10130 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10131 { } /* end */
10132};
Kailang Yang272a5272007-05-14 11:00:38 +020010133
Tony Vroonba340e82009-02-02 19:01:30 +000010134static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10135 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10136 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10137 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10138 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10139 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10140 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10147 { } /* end */
10148};
10149
10150static struct hda_verb alc262_tyan_verbs[] = {
10151 /* Headphone automute */
10152 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10153 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10155
10156 /* P11 AUX_IN, white 4-pin connector */
10157 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10158 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10159 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10160 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10161
10162 {}
10163};
10164
10165/* unsolicited event for HP jack sensing */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010166static void alc262_tyan_init_hook(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010167{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010168 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010169
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010170 spec->autocfg.hp_pins[0] = 0x1b;
10171 spec->autocfg.speaker_pins[0] = 0x15;
10172 alc_automute_amp(codec);
Tony Vroonba340e82009-02-02 19:01:30 +000010173}
10174
Tony Vroonba340e82009-02-02 19:01:30 +000010175
Kailang Yangdf694da2005-12-05 19:42:22 +010010176#define alc262_capture_mixer alc882_capture_mixer
10177#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10178
10179/*
10180 * generic initialization of ADC, input mixers and output mixers
10181 */
10182static struct hda_verb alc262_init_verbs[] = {
10183 /*
10184 * Unmute ADC0-2 and set the default input to mic-in
10185 */
10186 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10188 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10189 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10190 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10192
Takashi Iwaicb53c622007-08-10 17:21:45 +020010193 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010194 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010195 * Note: PASD motherboards uses the Line In 2 as the input for
10196 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010197 */
10198 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010199 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10200 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10201 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010204
10205 /*
10206 * Set up output mixers (0x0c - 0x0e)
10207 */
10208 /* set vol=0 to output mixers */
10209 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10210 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10212 /* set up input amps for analog loopback */
10213 /* Amp Indices: DAC = 0, mixer = 1 */
10214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10215 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10220
10221 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10222 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10223 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10224 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10226 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10227
10228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10230 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010233
Kailang Yangdf694da2005-12-05 19:42:22 +010010234 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10235 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010236
Kailang Yangdf694da2005-12-05 19:42:22 +010010237 /* FIXME: use matrix-type input source selection */
10238 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10239 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10244 /* Input mixer2 */
10245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10248 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10249 /* Input mixer3 */
10250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010254
10255 { }
10256};
10257
Kailang Yang4e555fe2008-08-26 13:05:55 +020010258static struct hda_verb alc262_eapd_verbs[] = {
10259 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10260 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10261 { }
10262};
10263
Kailang Yangccc656c2006-10-17 12:32:26 +020010264static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10265 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10266 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10267 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10268
10269 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10271 {}
10272};
10273
Kailang Yang272a5272007-05-14 11:00:38 +020010274static struct hda_verb alc262_sony_unsol_verbs[] = {
10275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10276 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10278
10279 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10280 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010281 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010282};
10283
Kailang Yang4e555fe2008-08-26 13:05:55 +020010284static struct hda_input_mux alc262_dmic_capture_source = {
10285 .num_items = 2,
10286 .items = {
10287 { "Int DMic", 0x9 },
10288 { "Mic", 0x0 },
10289 },
10290};
10291
10292static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10293 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10294 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010298 { } /* end */
10299};
10300
10301static struct hda_verb alc262_toshiba_s06_verbs[] = {
10302 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10303 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10304 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10305 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10306 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10307 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10308 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10309 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10310 {}
10311};
10312
10313static void alc262_dmic_automute(struct hda_codec *codec)
10314{
10315 unsigned int present;
10316
10317 present = snd_hda_codec_read(codec, 0x18, 0,
10318 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10319 snd_hda_codec_write(codec, 0x22, 0,
10320 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
10321}
10322
Kailang Yang4e555fe2008-08-26 13:05:55 +020010323
10324/* unsolicited event for HP jack sensing */
10325static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
10326 unsigned int res)
10327{
Kailang Yang4e555fe2008-08-26 13:05:55 +020010328 if ((res >> 26) == ALC880_MIC_EVENT)
10329 alc262_dmic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010330 else
10331 alc_sku_unsol_event(codec, res);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010332}
10333
10334static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
10335{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010336 struct alc_spec *spec = codec->spec;
10337
10338 spec->autocfg.hp_pins[0] = 0x15;
10339 spec->autocfg.speaker_pins[0] = 0x14;
10340 alc_automute_pin(codec);
Kailang Yang4e555fe2008-08-26 13:05:55 +020010341 alc262_dmic_automute(codec);
10342}
10343
Takashi Iwai834be882006-03-01 14:16:17 +010010344/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010345 * nec model
10346 * 0x15 = headphone
10347 * 0x16 = internal speaker
10348 * 0x18 = external mic
10349 */
10350
10351static struct snd_kcontrol_new alc262_nec_mixer[] = {
10352 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10353 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10354
10355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10357 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10358
10359 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10361 { } /* end */
10362};
10363
10364static struct hda_verb alc262_nec_verbs[] = {
10365 /* Unmute Speaker */
10366 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10367
10368 /* Headphone */
10369 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10371
10372 /* External mic to headphone */
10373 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10374 /* External mic to speaker */
10375 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10376 {}
10377};
10378
10379/*
Takashi Iwai834be882006-03-01 14:16:17 +010010380 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010381 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10382 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010383 */
10384
10385#define ALC_HP_EVENT 0x37
10386
10387static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10388 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10389 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010390 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10391 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010392 {}
10393};
10394
Jiang zhe0e31daf2008-03-20 12:12:39 +010010395static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10396 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10397 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10398 {}
10399};
10400
Takashi Iwai834be882006-03-01 14:16:17 +010010401static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010402 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010010403 .items = {
10404 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010405 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010010406 { "CD", 0x4 },
10407 },
10408};
10409
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010410static struct hda_input_mux alc262_HP_capture_source = {
10411 .num_items = 5,
10412 .items = {
10413 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020010414 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010415 { "Line", 0x2 },
10416 { "CD", 0x4 },
10417 { "AUX IN", 0x6 },
10418 },
10419};
10420
zhejiangaccbe492007-08-31 12:36:05 +020010421static struct hda_input_mux alc262_HP_D7000_capture_source = {
10422 .num_items = 4,
10423 .items = {
10424 { "Mic", 0x0 },
10425 { "Front Mic", 0x2 },
10426 { "Line", 0x1 },
10427 { "CD", 0x4 },
10428 },
10429};
10430
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010431/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010010432static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
10433{
10434 struct alc_spec *spec = codec->spec;
10435 unsigned int mute;
10436
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010437 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010438 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +010010439 /* need to execute and sync at first */
10440 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010441 /* check laptop HP jack */
10442 present = snd_hda_codec_read(codec, 0x14, 0,
10443 AC_VERB_GET_PIN_SENSE, 0);
10444 /* need to execute and sync at first */
10445 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10446 /* check docking HP jack */
10447 present |= snd_hda_codec_read(codec, 0x1b, 0,
10448 AC_VERB_GET_PIN_SENSE, 0);
10449 if (present & AC_PINSENSE_PRESENCE)
10450 spec->jack_present = 1;
10451 else
10452 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +010010453 spec->sense_updated = 1;
10454 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010455 /* unmute internal speaker only if both HPs are unplugged and
10456 * master switch is on
10457 */
10458 if (spec->jack_present)
10459 mute = HDA_AMP_MUTE;
10460 else
Takashi Iwai834be882006-03-01 14:16:17 +010010461 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010462 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10463 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010010464}
10465
10466/* unsolicited event for HP jack sensing */
10467static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
10468 unsigned int res)
10469{
10470 if ((res >> 26) != ALC_HP_EVENT)
10471 return;
10472 alc262_fujitsu_automute(codec, 1);
10473}
10474
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010475static void alc262_fujitsu_init_hook(struct hda_codec *codec)
10476{
10477 alc262_fujitsu_automute(codec, 1);
10478}
10479
Takashi Iwai834be882006-03-01 14:16:17 +010010480/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010481static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10482 .ops = &snd_hda_bind_vol,
10483 .values = {
10484 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10485 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10486 0
10487 },
10488};
Takashi Iwai834be882006-03-01 14:16:17 +010010489
Jiang zhe0e31daf2008-03-20 12:12:39 +010010490/* mute/unmute internal speaker according to the hp jack and mute state */
10491static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10492{
10493 struct alc_spec *spec = codec->spec;
10494 unsigned int mute;
10495
10496 if (force || !spec->sense_updated) {
10497 unsigned int present_int_hp;
10498 /* need to execute and sync at first */
10499 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10500 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10501 AC_VERB_GET_PIN_SENSE, 0);
10502 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10503 spec->sense_updated = 1;
10504 }
10505 if (spec->jack_present) {
10506 /* mute internal speaker */
10507 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10508 HDA_AMP_MUTE, HDA_AMP_MUTE);
10509 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10510 HDA_AMP_MUTE, HDA_AMP_MUTE);
10511 } else {
10512 /* unmute internal speaker if necessary */
10513 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10514 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10515 HDA_AMP_MUTE, mute);
10516 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10517 HDA_AMP_MUTE, mute);
10518 }
10519}
10520
10521/* unsolicited event for HP jack sensing */
10522static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10523 unsigned int res)
10524{
10525 if ((res >> 26) != ALC_HP_EVENT)
10526 return;
10527 alc262_lenovo_3000_automute(codec, 1);
10528}
10529
Takashi Iwai8de56b72009-07-24 16:51:47 +020010530static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
10531 int dir, int idx, long *valp)
10532{
10533 int i, change = 0;
10534
10535 for (i = 0; i < 2; i++, valp++)
10536 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
10537 HDA_AMP_MUTE,
10538 *valp ? 0 : HDA_AMP_MUTE);
10539 return change;
10540}
10541
Takashi Iwai834be882006-03-01 14:16:17 +010010542/* bind hp and internal speaker mute (with plug check) */
10543static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10544 struct snd_ctl_elem_value *ucontrol)
10545{
10546 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10547 long *valp = ucontrol->value.integer.value;
10548 int change;
10549
Takashi Iwai8de56b72009-07-24 16:51:47 +020010550 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
10551 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010552 if (change)
10553 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010554 return change;
10555}
10556
10557static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010558 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010559 {
10560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10561 .name = "Master Playback Switch",
10562 .info = snd_hda_mixer_amp_switch_info,
10563 .get = snd_hda_mixer_amp_switch_get,
10564 .put = alc262_fujitsu_master_sw_put,
10565 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10566 },
10567 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10568 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10569 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010572 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10573 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10574 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010575 { } /* end */
10576};
10577
Jiang zhe0e31daf2008-03-20 12:12:39 +010010578/* bind hp and internal speaker mute (with plug check) */
10579static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10580 struct snd_ctl_elem_value *ucontrol)
10581{
10582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10583 long *valp = ucontrol->value.integer.value;
10584 int change;
10585
Takashi Iwai8de56b72009-07-24 16:51:47 +020010586 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010010587 if (change)
10588 alc262_lenovo_3000_automute(codec, 0);
10589 return change;
10590}
10591
10592static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10593 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10594 {
10595 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10596 .name = "Master Playback Switch",
10597 .info = snd_hda_mixer_amp_switch_info,
10598 .get = snd_hda_mixer_amp_switch_get,
10599 .put = alc262_lenovo_3000_master_sw_put,
10600 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10601 },
10602 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10603 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10604 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10606 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10607 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10608 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10609 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10610 { } /* end */
10611};
10612
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010613static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10614 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020010615 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10619 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10620 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10621 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10622 { } /* end */
10623};
10624
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010625/* additional init verbs for Benq laptops */
10626static struct hda_verb alc262_EAPD_verbs[] = {
10627 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10628 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10629 {}
10630};
10631
Kailang Yang83c34212007-07-05 11:43:05 +020010632static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10633 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10634 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10635
10636 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10637 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10638 {}
10639};
10640
Tobin Davisf651b502007-10-26 12:40:47 +020010641/* Samsung Q1 Ultra Vista model setup */
10642static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010643 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10644 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010645 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10647 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010648 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010649 { } /* end */
10650};
10651
10652static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010653 /* output mixer */
10654 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10657 /* speaker */
10658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10660 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10661 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10662 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10665 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10666 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10667 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10668 /* internal mic */
10669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10671 /* ADC, choose mic */
10672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10673 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10674 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10675 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10676 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10677 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10678 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10679 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10680 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10681 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010682 {}
10683};
10684
Tobin Davisf651b502007-10-26 12:40:47 +020010685/* mute/unmute internal speaker according to the hp jack and mute state */
10686static void alc262_ultra_automute(struct hda_codec *codec)
10687{
10688 struct alc_spec *spec = codec->spec;
10689 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010690
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010691 mute = 0;
10692 /* auto-mute only when HP is used as HP */
10693 if (!spec->cur_mux[0]) {
10694 unsigned int present;
10695 /* need to execute and sync at first */
10696 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10697 present = snd_hda_codec_read(codec, 0x15, 0,
10698 AC_VERB_GET_PIN_SENSE, 0);
10699 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10700 if (spec->jack_present)
10701 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010702 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010703 /* mute/unmute internal speaker */
10704 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10705 HDA_AMP_MUTE, mute);
10706 /* mute/unmute HP */
10707 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10708 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010709}
10710
10711/* unsolicited event for HP jack sensing */
10712static void alc262_ultra_unsol_event(struct hda_codec *codec,
10713 unsigned int res)
10714{
10715 if ((res >> 26) != ALC880_HP_EVENT)
10716 return;
10717 alc262_ultra_automute(codec);
10718}
10719
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010720static struct hda_input_mux alc262_ultra_capture_source = {
10721 .num_items = 2,
10722 .items = {
10723 { "Mic", 0x1 },
10724 { "Headphone", 0x7 },
10725 },
10726};
10727
10728static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10729 struct snd_ctl_elem_value *ucontrol)
10730{
10731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10732 struct alc_spec *spec = codec->spec;
10733 int ret;
10734
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010735 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010736 if (!ret)
10737 return 0;
10738 /* reprogram the HP pin as mic or HP according to the input source */
10739 snd_hda_codec_write_cache(codec, 0x15, 0,
10740 AC_VERB_SET_PIN_WIDGET_CONTROL,
10741 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10742 alc262_ultra_automute(codec); /* mute/unmute HP */
10743 return ret;
10744}
10745
10746static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10747 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10748 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10749 {
10750 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10751 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010752 .info = alc_mux_enum_info,
10753 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010754 .put = alc262_ultra_mux_enum_put,
10755 },
10756 { } /* end */
10757};
10758
Kailang Yangdf694da2005-12-05 19:42:22 +010010759/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010760static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10761 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010762{
10763 hda_nid_t nid;
10764 int err;
10765
10766 spec->multiout.num_dacs = 1; /* only use one dac */
10767 spec->multiout.dac_nids = spec->private_dac_nids;
10768 spec->multiout.dac_nids[0] = 2;
10769
10770 nid = cfg->line_out_pins[0];
10771 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010772 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10773 "Front Playback Volume",
10774 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10775 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010776 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010777 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10778 "Front Playback Switch",
10779 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10780 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010781 return err;
10782 }
10783
Takashi Iwai82bc9552006-03-21 11:24:42 +010010784 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010785 if (nid) {
10786 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010787 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10788 "Speaker Playback Volume",
10789 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10790 HDA_OUTPUT));
10791 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010792 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010793 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10794 "Speaker Playback Switch",
10795 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10796 HDA_OUTPUT));
10797 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010798 return err;
10799 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010800 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10801 "Speaker Playback Switch",
10802 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10803 HDA_OUTPUT));
10804 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010805 return err;
10806 }
10807 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010808 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010809 if (nid) {
10810 /* spec->multiout.hp_nid = 2; */
10811 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010812 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10813 "Headphone Playback Volume",
10814 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10815 HDA_OUTPUT));
10816 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010817 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010818 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10819 "Headphone Playback Switch",
10820 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10821 HDA_OUTPUT));
10822 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010823 return err;
10824 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010825 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10826 "Headphone Playback Switch",
10827 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10828 HDA_OUTPUT));
10829 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010830 return err;
10831 }
10832 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010833 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010834}
10835
Takashi Iwai8c927b42009-06-22 10:56:54 +020010836static int alc262_auto_create_analog_input_ctls(struct alc_spec *spec,
10837 const struct auto_pin_cfg *cfg)
10838{
10839 int err;
10840
10841 err = alc880_auto_create_analog_input_ctls(spec, cfg);
10842 if (err < 0)
10843 return err;
10844 /* digital-mic input pin is excluded in alc880_auto_create..()
10845 * because it's under 0x18
10846 */
10847 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
10848 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
10849 struct hda_input_mux *imux = &spec->private_imux[0];
10850 imux->items[imux->num_items].label = "Int Mic";
10851 imux->items[imux->num_items].index = 0x09;
10852 imux->num_items++;
10853 }
10854 return 0;
10855}
10856
Kailang Yangdf694da2005-12-05 19:42:22 +010010857
10858/*
10859 * generic initialization of ADC, input mixers and output mixers
10860 */
10861static struct hda_verb alc262_volume_init_verbs[] = {
10862 /*
10863 * Unmute ADC0-2 and set the default input to mic-in
10864 */
10865 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10866 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10867 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10868 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10869 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10870 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10871
Takashi Iwaicb53c622007-08-10 17:21:45 +020010872 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010873 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010874 * Note: PASD motherboards uses the Line In 2 as the input for
10875 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010876 */
10877 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010883
10884 /*
10885 * Set up output mixers (0x0c - 0x0f)
10886 */
10887 /* set vol=0 to output mixers */
10888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10890 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010891
Kailang Yangdf694da2005-12-05 19:42:22 +010010892 /* set up input amps for analog loopback */
10893 /* Amp Indices: DAC = 0, mixer = 1 */
10894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10895 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10897 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10898 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10899 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10900
10901 /* FIXME: use matrix-type input source selection */
10902 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10903 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10904 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10905 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10906 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10907 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10908 /* Input mixer2 */
10909 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10910 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10911 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10912 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10913 /* Input mixer3 */
10914 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10915 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10916 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10918
10919 { }
10920};
10921
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010922static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10923 /*
10924 * Unmute ADC0-2 and set the default input to mic-in
10925 */
10926 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10927 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10928 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10929 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10930 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10931 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10932
Takashi Iwaicb53c622007-08-10 17:21:45 +020010933 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010934 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010935 * Note: PASD motherboards uses the Line In 2 as the input for
10936 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010937 */
10938 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010939 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010946
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010947 /*
10948 * Set up output mixers (0x0c - 0x0e)
10949 */
10950 /* set vol=0 to output mixers */
10951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10954
10955 /* set up input amps for analog loopback */
10956 /* Amp Indices: DAC = 0, mixer = 1 */
10957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10963
Takashi Iwaice875f02008-01-28 18:17:43 +010010964 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010965 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10967
10968 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10970
10971 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10973
10974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10975 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10976 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10977 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10978 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10979
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010980 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010981 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10982 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010983 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010984 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10985 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10986
10987
10988 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010989 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
10990 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020010992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
10993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10996 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
10997 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
10998 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
10999 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011000 /* Input mixer2 */
11001 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011002 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11003 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11009 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011010 /* Input mixer3 */
11011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11016 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11017 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020
Takashi Iwaice875f02008-01-28 18:17:43 +010011021 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11022
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011023 { }
11024};
11025
Kailang Yangcd7509a2007-01-26 18:33:17 +010011026static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11027 /*
11028 * Unmute ADC0-2 and set the default input to mic-in
11029 */
11030 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11032 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11034 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11036
Takashi Iwaicb53c622007-08-10 17:21:45 +020011037 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011038 * mixer widget
11039 * Note: PASD motherboards uses the Line In 2 as the input for front
11040 * panel mic (mic 2)
11041 */
11042 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11044 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11045 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11046 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11047 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11048 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11049 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11050 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011051 /*
11052 * Set up output mixers (0x0c - 0x0e)
11053 */
11054 /* set vol=0 to output mixers */
11055 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11056 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11057 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11058
11059 /* set up input amps for analog loopback */
11060 /* Amp Indices: DAC = 0, mixer = 1 */
11061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11067
11068
11069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11070 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11071 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11072 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11073 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11074 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11075 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11076
11077 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11079
11080 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11081 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11082
11083 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11084 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11085 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11086 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11087 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11088 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11089
11090 /* FIXME: use matrix-type input source selection */
11091 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11092 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11093 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11094 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11095 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11096 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11097 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11098 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11099 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11100 /* Input mixer2 */
11101 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11104 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11105 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11106 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11107 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11108 /* Input mixer3 */
11109 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11110 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11111 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11112 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11114 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11116
Takashi Iwaice875f02008-01-28 18:17:43 +010011117 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11118
Kailang Yangcd7509a2007-01-26 18:33:17 +010011119 { }
11120};
11121
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011122static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11123
11124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11127
11128 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11131 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11132
11133 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11136 {}
11137};
11138
11139
Takashi Iwaicb53c622007-08-10 17:21:45 +020011140#ifdef CONFIG_SND_HDA_POWER_SAVE
11141#define alc262_loopbacks alc880_loopbacks
11142#endif
11143
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011144/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011145#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11146#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11147#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11148#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11149
11150/*
11151 * BIOS auto configuration
11152 */
11153static int alc262_parse_auto_config(struct hda_codec *codec)
11154{
11155 struct alc_spec *spec = codec->spec;
11156 int err;
11157 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11158
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011159 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11160 alc262_ignore);
11161 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011162 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011163 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011164 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011165 spec->multiout.max_channels = 2;
11166 spec->no_analog = 1;
11167 goto dig_only;
11168 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011169 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011170 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011171 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11172 if (err < 0)
11173 return err;
11174 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
11175 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011176 return err;
11177
11178 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11179
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011180 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011181 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011182 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011183 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011184 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011185 if (spec->autocfg.dig_in_pin)
11186 spec->dig_in_nid = ALC262_DIGIN_NID;
11187
Takashi Iwai603c4012008-07-30 15:01:44 +020011188 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011189 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011190
Takashi Iwaid88897e2008-10-31 15:01:37 +010011191 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011192 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011193 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011194
Takashi Iwai776e1842007-08-29 15:07:11 +020011195 err = alc_auto_add_mic_boost(codec);
11196 if (err < 0)
11197 return err;
11198
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011199 alc_ssid_check(codec, 0x15, 0x14, 0x1b);
11200
Kailang Yangdf694da2005-12-05 19:42:22 +010011201 return 1;
11202}
11203
11204#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11205#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11206#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011207#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011208
11209
11210/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011211static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011212{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011213 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011214 alc262_auto_init_multi_out(codec);
11215 alc262_auto_init_hp_out(codec);
11216 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011217 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011218 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011219 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011220}
11221
11222/*
11223 * configuration and preset
11224 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011225static const char *alc262_models[ALC262_MODEL_LAST] = {
11226 [ALC262_BASIC] = "basic",
11227 [ALC262_HIPPO] = "hippo",
11228 [ALC262_HIPPO_1] = "hippo_1",
11229 [ALC262_FUJITSU] = "fujitsu",
11230 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011231 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011232 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011233 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011234 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011235 [ALC262_BENQ_T31] = "benq-t31",
11236 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011237 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011238 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011239 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011240 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011241 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011242 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011243 [ALC262_AUTO] = "auto",
11244};
11245
11246static struct snd_pci_quirk alc262_cfg_tbl[] = {
11247 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011248 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011249 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11250 ALC262_HP_BPC),
11251 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11252 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011253 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11254 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011255 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011256 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011257 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011258 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011259 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011260 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011261 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011262 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011263 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11264 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11265 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011266 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11267 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011268 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011269 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011270 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011271 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011272 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011273 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Takashi Iwaif872a912009-02-26 00:57:01 +010011274 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11275 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090011276 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011277 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011278 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011279 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011280 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011281 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011282 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11283 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011284 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011285 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011286 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011287 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011288 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011289 {}
11290};
11291
11292static struct alc_config_preset alc262_presets[] = {
11293 [ALC262_BASIC] = {
11294 .mixers = { alc262_base_mixer },
11295 .init_verbs = { alc262_init_verbs },
11296 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11297 .dac_nids = alc262_dac_nids,
11298 .hp_nid = 0x03,
11299 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11300 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011301 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011302 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011303 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011304 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011305 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011306 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11307 .dac_nids = alc262_dac_nids,
11308 .hp_nid = 0x03,
11309 .dig_out_nid = ALC262_DIGOUT_NID,
11310 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11311 .channel_mode = alc262_modes,
11312 .input_mux = &alc262_capture_source,
11313 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011314 .init_hook = alc262_hippo_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011315 },
11316 [ALC262_HIPPO_1] = {
11317 .mixers = { alc262_hippo1_mixer },
11318 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11319 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11320 .dac_nids = alc262_dac_nids,
11321 .hp_nid = 0x02,
11322 .dig_out_nid = ALC262_DIGOUT_NID,
11323 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11324 .channel_mode = alc262_modes,
11325 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011326 .unsol_event = alc262_hippo_unsol_event,
11327 .init_hook = alc262_hippo1_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +020011328 },
Takashi Iwai834be882006-03-01 14:16:17 +010011329 [ALC262_FUJITSU] = {
11330 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011331 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11332 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011333 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11334 .dac_nids = alc262_dac_nids,
11335 .hp_nid = 0x03,
11336 .dig_out_nid = ALC262_DIGOUT_NID,
11337 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11338 .channel_mode = alc262_modes,
11339 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011340 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011341 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011342 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011343 [ALC262_HP_BPC] = {
11344 .mixers = { alc262_HP_BPC_mixer },
11345 .init_verbs = { alc262_HP_BPC_init_verbs },
11346 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11347 .dac_nids = alc262_dac_nids,
11348 .hp_nid = 0x03,
11349 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11350 .channel_mode = alc262_modes,
11351 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011352 .unsol_event = alc262_hp_bpc_unsol_event,
11353 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011354 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011355 [ALC262_HP_BPC_D7000_WF] = {
11356 .mixers = { alc262_HP_BPC_WildWest_mixer },
11357 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11358 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11359 .dac_nids = alc262_dac_nids,
11360 .hp_nid = 0x03,
11361 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11362 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011363 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011364 .unsol_event = alc262_hp_wildwest_unsol_event,
11365 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011366 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011367 [ALC262_HP_BPC_D7000_WL] = {
11368 .mixers = { alc262_HP_BPC_WildWest_mixer,
11369 alc262_HP_BPC_WildWest_option_mixer },
11370 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11371 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11372 .dac_nids = alc262_dac_nids,
11373 .hp_nid = 0x03,
11374 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11375 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011376 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011377 .unsol_event = alc262_hp_wildwest_unsol_event,
11378 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011379 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011380 [ALC262_HP_TC_T5735] = {
11381 .mixers = { alc262_hp_t5735_mixer },
11382 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11383 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11384 .dac_nids = alc262_dac_nids,
11385 .hp_nid = 0x03,
11386 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11387 .channel_mode = alc262_modes,
11388 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011389 .unsol_event = alc_automute_amp_unsol_event,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011390 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010011391 },
11392 [ALC262_HP_RP5700] = {
11393 .mixers = { alc262_hp_rp5700_mixer },
11394 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11395 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11396 .dac_nids = alc262_dac_nids,
11397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11398 .channel_mode = alc262_modes,
11399 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011400 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011401 [ALC262_BENQ_ED8] = {
11402 .mixers = { alc262_base_mixer },
11403 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
11404 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11405 .dac_nids = alc262_dac_nids,
11406 .hp_nid = 0x03,
11407 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11408 .channel_mode = alc262_modes,
11409 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011410 },
Kailang Yang272a5272007-05-14 11:00:38 +020011411 [ALC262_SONY_ASSAMD] = {
11412 .mixers = { alc262_sony_mixer },
11413 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
11414 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11415 .dac_nids = alc262_dac_nids,
11416 .hp_nid = 0x02,
11417 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11418 .channel_mode = alc262_modes,
11419 .input_mux = &alc262_capture_source,
11420 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011421 .init_hook = alc262_hippo_init_hook,
Kailang Yang83c34212007-07-05 11:43:05 +020011422 },
11423 [ALC262_BENQ_T31] = {
11424 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011425 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
11426 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020011427 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11428 .dac_nids = alc262_dac_nids,
11429 .hp_nid = 0x03,
11430 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11431 .channel_mode = alc262_modes,
11432 .input_mux = &alc262_capture_source,
11433 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011434 .init_hook = alc262_hippo_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020011435 },
Tobin Davisf651b502007-10-26 12:40:47 +020011436 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011437 .mixers = { alc262_ultra_mixer },
11438 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011439 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020011440 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11441 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020011442 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11443 .channel_mode = alc262_modes,
11444 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011445 .adc_nids = alc262_adc_nids, /* ADC0 */
11446 .capsrc_nids = alc262_capsrc_nids,
11447 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020011448 .unsol_event = alc262_ultra_unsol_event,
11449 .init_hook = alc262_ultra_automute,
11450 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010011451 [ALC262_LENOVO_3000] = {
11452 .mixers = { alc262_lenovo_3000_mixer },
11453 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11454 alc262_lenovo_3000_unsol_verbs },
11455 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11456 .dac_nids = alc262_dac_nids,
11457 .hp_nid = 0x03,
11458 .dig_out_nid = ALC262_DIGOUT_NID,
11459 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11460 .channel_mode = alc262_modes,
11461 .input_mux = &alc262_fujitsu_capture_source,
11462 .unsol_event = alc262_lenovo_3000_unsol_event,
11463 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011464 [ALC262_NEC] = {
11465 .mixers = { alc262_nec_mixer },
11466 .init_verbs = { alc262_nec_verbs },
11467 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11468 .dac_nids = alc262_dac_nids,
11469 .hp_nid = 0x03,
11470 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11471 .channel_mode = alc262_modes,
11472 .input_mux = &alc262_capture_source,
11473 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020011474 [ALC262_TOSHIBA_S06] = {
11475 .mixers = { alc262_toshiba_s06_mixer },
11476 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
11477 alc262_eapd_verbs },
11478 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11479 .capsrc_nids = alc262_dmic_capsrc_nids,
11480 .dac_nids = alc262_dac_nids,
11481 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020011482 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020011483 .dig_out_nid = ALC262_DIGOUT_NID,
11484 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11485 .channel_mode = alc262_modes,
11486 .input_mux = &alc262_dmic_capture_source,
11487 .unsol_event = alc262_toshiba_s06_unsol_event,
11488 .init_hook = alc262_toshiba_s06_init_hook,
11489 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011490 [ALC262_TOSHIBA_RX1] = {
11491 .mixers = { alc262_toshiba_rx1_mixer },
11492 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_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 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020011500 .init_hook = alc262_hippo_init_hook,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011501 },
Tony Vroonba340e82009-02-02 19:01:30 +000011502 [ALC262_TYAN] = {
11503 .mixers = { alc262_tyan_mixer },
11504 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
11505 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11506 .dac_nids = alc262_dac_nids,
11507 .hp_nid = 0x02,
11508 .dig_out_nid = ALC262_DIGOUT_NID,
11509 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11510 .channel_mode = alc262_modes,
11511 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011512 .unsol_event = alc_automute_amp_unsol_event,
11513 .init_hook = alc262_tyan_init_hook,
Tony Vroonba340e82009-02-02 19:01:30 +000011514 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011515};
11516
11517static int patch_alc262(struct hda_codec *codec)
11518{
11519 struct alc_spec *spec;
11520 int board_config;
11521 int err;
11522
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011523 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011524 if (spec == NULL)
11525 return -ENOMEM;
11526
11527 codec->spec = spec;
11528#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011529 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11530 * under-run
11531 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011532 {
11533 int tmp;
11534 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11535 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11536 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11537 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11538 }
11539#endif
11540
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011541 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11542
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011543 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11544 alc262_models,
11545 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011546
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011547 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020011548 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
11549 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010011550 board_config = ALC262_AUTO;
11551 }
11552
11553 if (board_config == ALC262_AUTO) {
11554 /* automatic parse from the BIOS config */
11555 err = alc262_parse_auto_config(codec);
11556 if (err < 0) {
11557 alc_free(codec);
11558 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011559 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011560 printk(KERN_INFO
11561 "hda_codec: Cannot set up configuration "
11562 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011563 board_config = ALC262_BASIC;
11564 }
11565 }
11566
Takashi Iwai07eba612009-02-19 08:06:35 +010011567 if (!spec->no_analog) {
11568 err = snd_hda_attach_beep_device(codec, 0x1);
11569 if (err < 0) {
11570 alc_free(codec);
11571 return err;
11572 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011573 }
11574
Kailang Yangdf694da2005-12-05 19:42:22 +010011575 if (board_config != ALC262_AUTO)
11576 setup_preset(spec, &alc262_presets[board_config]);
11577
Kailang Yangdf694da2005-12-05 19:42:22 +010011578 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11579 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011580
Kailang Yangdf694da2005-12-05 19:42:22 +010011581 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11582 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11583
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011584 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011585 int i;
11586 /* check whether the digital-mic has to be supported */
11587 for (i = 0; i < spec->input_mux->num_items; i++) {
11588 if (spec->input_mux->items[i].index >= 9)
11589 break;
11590 }
11591 if (i < spec->input_mux->num_items) {
11592 /* use only ADC0 */
11593 spec->adc_nids = alc262_dmic_adc_nids;
11594 spec->num_adc_nids = 1;
11595 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011596 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020011597 /* all analog inputs */
11598 /* check whether NID 0x07 is valid */
11599 unsigned int wcap = get_wcaps(codec, 0x07);
11600
11601 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011602 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020011603 if (wcap != AC_WID_AUD_IN) {
11604 spec->adc_nids = alc262_adc_nids_alt;
11605 spec->num_adc_nids =
11606 ARRAY_SIZE(alc262_adc_nids_alt);
11607 spec->capsrc_nids = alc262_capsrc_nids_alt;
11608 } else {
11609 spec->adc_nids = alc262_adc_nids;
11610 spec->num_adc_nids =
11611 ARRAY_SIZE(alc262_adc_nids);
11612 spec->capsrc_nids = alc262_capsrc_nids;
11613 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011614 }
11615 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011616 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011617 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011618 if (!spec->no_analog)
11619 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011620
Takashi Iwai2134ea42008-01-10 16:53:55 +010011621 spec->vmaster_nid = 0x0c;
11622
Kailang Yangdf694da2005-12-05 19:42:22 +010011623 codec->patch_ops = alc_patch_ops;
11624 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011625 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011626#ifdef CONFIG_SND_HDA_POWER_SAVE
11627 if (!spec->loopback.amplist)
11628 spec->loopback.amplist = alc262_loopbacks;
11629#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011630 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011631
Kailang Yangdf694da2005-12-05 19:42:22 +010011632 return 0;
11633}
11634
Kailang Yangdf694da2005-12-05 19:42:22 +010011635/*
Kailang Yanga361d842007-06-05 12:30:55 +020011636 * ALC268 channel source setting (2 channel)
11637 */
11638#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11639#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011640
Kailang Yanga361d842007-06-05 12:30:55 +020011641static hda_nid_t alc268_dac_nids[2] = {
11642 /* front, hp */
11643 0x02, 0x03
11644};
11645
11646static hda_nid_t alc268_adc_nids[2] = {
11647 /* ADC0-1 */
11648 0x08, 0x07
11649};
11650
11651static hda_nid_t alc268_adc_nids_alt[1] = {
11652 /* ADC0 */
11653 0x08
11654};
11655
Takashi Iwaie1406342008-02-11 18:32:32 +010011656static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11657
Kailang Yanga361d842007-06-05 12:30:55 +020011658static struct snd_kcontrol_new alc268_base_mixer[] = {
11659 /* output mixer control */
11660 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11661 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11662 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11663 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011664 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11665 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11666 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011667 { }
11668};
11669
Takashi Iwai42171c12009-05-08 14:11:43 +020011670static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
11671 /* output mixer control */
11672 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11673 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11674 ALC262_HIPPO_MASTER_SWITCH,
11675 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11676 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11677 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11678 { }
11679};
11680
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011681/* bind Beep switches of both NID 0x0f and 0x10 */
11682static struct hda_bind_ctls alc268_bind_beep_sw = {
11683 .ops = &snd_hda_bind_sw,
11684 .values = {
11685 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11686 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11687 0
11688 },
11689};
11690
11691static struct snd_kcontrol_new alc268_beep_mixer[] = {
11692 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11693 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11694 { }
11695};
11696
Kailang Yangd1a991a2007-08-15 16:21:59 +020011697static struct hda_verb alc268_eapd_verbs[] = {
11698 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11699 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11700 { }
11701};
11702
Takashi Iwaid2738092007-08-16 14:59:45 +020011703/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020011704static struct hda_verb alc268_toshiba_verbs[] = {
11705 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11706 { } /* end */
11707};
11708
Kailang Yang8ef355d2008-08-26 13:10:22 +020011709static struct hda_input_mux alc268_acer_lc_capture_source = {
11710 .num_items = 2,
11711 .items = {
11712 { "i-Mic", 0x6 },
11713 { "E-Mic", 0x0 },
11714 },
11715};
11716
Takashi Iwaid2738092007-08-16 14:59:45 +020011717/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011718/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011719static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11720 .ops = &snd_hda_bind_vol,
11721 .values = {
11722 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11723 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11724 0
11725 },
11726};
11727
Takashi Iwai889c4392007-08-23 18:56:52 +020011728/* mute/unmute internal speaker according to the hp jack and mute state */
11729static void alc268_acer_automute(struct hda_codec *codec, int force)
11730{
11731 struct alc_spec *spec = codec->spec;
11732 unsigned int mute;
11733
11734 if (force || !spec->sense_updated) {
11735 unsigned int present;
11736 present = snd_hda_codec_read(codec, 0x14, 0,
11737 AC_VERB_GET_PIN_SENSE, 0);
11738 spec->jack_present = (present & 0x80000000) != 0;
11739 spec->sense_updated = 1;
11740 }
11741 if (spec->jack_present)
11742 mute = HDA_AMP_MUTE; /* mute internal speaker */
11743 else /* unmute internal speaker if necessary */
11744 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11745 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11746 HDA_AMP_MUTE, mute);
11747}
11748
11749
11750/* bind hp and internal speaker mute (with plug check) */
11751static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11752 struct snd_ctl_elem_value *ucontrol)
11753{
11754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11755 long *valp = ucontrol->value.integer.value;
11756 int change;
11757
Takashi Iwai8de56b72009-07-24 16:51:47 +020011758 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020011759 if (change)
11760 alc268_acer_automute(codec, 0);
11761 return change;
11762}
Takashi Iwaid2738092007-08-16 14:59:45 +020011763
Kailang Yang8ef355d2008-08-26 13:10:22 +020011764static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11765 /* output mixer control */
11766 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11767 {
11768 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11769 .name = "Master Playback Switch",
11770 .info = snd_hda_mixer_amp_switch_info,
11771 .get = snd_hda_mixer_amp_switch_get,
11772 .put = alc268_acer_master_sw_put,
11773 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11774 },
11775 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11776 { }
11777};
11778
Takashi Iwaid2738092007-08-16 14:59:45 +020011779static struct snd_kcontrol_new alc268_acer_mixer[] = {
11780 /* output mixer control */
11781 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11782 {
11783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11784 .name = "Master Playback Switch",
11785 .info = snd_hda_mixer_amp_switch_info,
11786 .get = snd_hda_mixer_amp_switch_get,
11787 .put = alc268_acer_master_sw_put,
11788 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11789 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011790 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11791 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11792 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011793 { }
11794};
11795
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011796static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11797 /* output mixer control */
11798 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11799 {
11800 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11801 .name = "Master Playback Switch",
11802 .info = snd_hda_mixer_amp_switch_info,
11803 .get = snd_hda_mixer_amp_switch_get,
11804 .put = alc268_acer_master_sw_put,
11805 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11806 },
11807 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11808 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11809 { }
11810};
11811
Kailang Yang8ef355d2008-08-26 13:10:22 +020011812static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11813 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11814 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11815 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11816 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11817 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11818 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11819 { }
11820};
11821
Takashi Iwaid2738092007-08-16 14:59:45 +020011822static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11824 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011825 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11826 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011829 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11830 { }
11831};
11832
11833/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020011834#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
11835#define alc268_toshiba_init_hook alc262_hippo_init_hook
Takashi Iwaid2738092007-08-16 14:59:45 +020011836
11837static void alc268_acer_unsol_event(struct hda_codec *codec,
11838 unsigned int res)
11839{
Takashi Iwai889c4392007-08-23 18:56:52 +020011840 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011841 return;
11842 alc268_acer_automute(codec, 1);
11843}
11844
Takashi Iwai889c4392007-08-23 18:56:52 +020011845static void alc268_acer_init_hook(struct hda_codec *codec)
11846{
11847 alc268_acer_automute(codec, 1);
11848}
11849
Kailang Yang8ef355d2008-08-26 13:10:22 +020011850/* toggle speaker-output according to the hp-jack state */
11851static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11852{
11853 unsigned int present;
11854 unsigned char bits;
11855
11856 present = snd_hda_codec_read(codec, 0x15, 0,
11857 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11858 bits = present ? AMP_IN_MUTE(0) : 0;
11859 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11860 AMP_IN_MUTE(0), bits);
11861 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11862 AMP_IN_MUTE(0), bits);
11863}
11864
11865
11866static void alc268_acer_mic_automute(struct hda_codec *codec)
11867{
11868 unsigned int present;
11869
11870 present = snd_hda_codec_read(codec, 0x18, 0,
11871 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11872 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11873 present ? 0x0 : 0x6);
11874}
11875
11876static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11877 unsigned int res)
11878{
11879 if ((res >> 26) == ALC880_HP_EVENT)
11880 alc268_aspire_one_speaker_automute(codec);
11881 if ((res >> 26) == ALC880_MIC_EVENT)
11882 alc268_acer_mic_automute(codec);
11883}
11884
11885static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11886{
11887 alc268_aspire_one_speaker_automute(codec);
11888 alc268_acer_mic_automute(codec);
11889}
11890
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011891static struct snd_kcontrol_new alc268_dell_mixer[] = {
11892 /* output mixer control */
11893 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11894 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11895 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11896 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11898 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11899 { }
11900};
11901
11902static struct hda_verb alc268_dell_verbs[] = {
11903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11905 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11906 { }
11907};
11908
11909/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011910static void alc268_dell_init_hook(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011911{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011912 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011913
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011914 spec->autocfg.hp_pins[0] = 0x15;
11915 spec->autocfg.speaker_pins[0] = 0x14;
11916 alc_automute_pin(codec);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011917}
11918
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011919static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11920 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11921 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11922 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11924 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11925 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11926 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11927 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11928 { }
11929};
11930
11931static struct hda_verb alc267_quanta_il1_verbs[] = {
11932 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11933 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11934 { }
11935};
11936
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011937static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11938{
11939 unsigned int present;
11940
11941 present = snd_hda_codec_read(codec, 0x18, 0,
11942 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11943 snd_hda_codec_write(codec, 0x23, 0,
11944 AC_VERB_SET_CONNECT_SEL,
11945 present ? 0x00 : 0x01);
11946}
11947
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011948static void alc267_quanta_il1_init_hook(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011949{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011950 struct alc_spec *spec = codec->spec;
11951
11952 spec->autocfg.hp_pins[0] = 0x15;
11953 spec->autocfg.speaker_pins[0] = 0x14;
11954 alc_automute_pin(codec);
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011955 alc267_quanta_il1_mic_automute(codec);
11956}
11957
11958static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11959 unsigned int res)
11960{
11961 switch (res >> 26) {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011962 case ALC880_MIC_EVENT:
11963 alc267_quanta_il1_mic_automute(codec);
11964 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011965 default:
11966 alc_sku_unsol_event(codec, res);
11967 break;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011968 }
11969}
11970
Kailang Yanga361d842007-06-05 12:30:55 +020011971/*
11972 * generic initialization of ADC, input mixers and output mixers
11973 */
11974static struct hda_verb alc268_base_init_verbs[] = {
11975 /* Unmute DAC0-1 and set vol = 0 */
11976 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011977 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011978
11979 /*
11980 * Set up output mixers (0x0c - 0x0e)
11981 */
11982 /* set vol=0 to output mixers */
11983 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011984 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11985
11986 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11987 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11988
11989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11990 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11992 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11994 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11995 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11996 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11997
11998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11999 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12000 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12001 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012002 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012003
12004 /* set PCBEEP vol = 0, mute connections */
12005 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12006 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12007 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012008
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012009 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012010
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012011 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12012 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12013 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12014 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012015
Kailang Yanga361d842007-06-05 12:30:55 +020012016 { }
12017};
12018
12019/*
12020 * generic initialization of ADC, input mixers and output mixers
12021 */
12022static struct hda_verb alc268_volume_init_verbs[] = {
12023 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012024 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12025 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012026
12027 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12028 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12030 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12031 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12032
Kailang Yanga361d842007-06-05 12:30:55 +020012033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012034 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12035 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12036
12037 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012038 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012039
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012040 /* set PCBEEP vol = 0, mute connections */
12041 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12042 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12043 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012044
12045 { }
12046};
12047
Kailang Yanga361d842007-06-05 12:30:55 +020012048static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12049 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12050 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12051 {
12052 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12053 /* The multiple "Capture Source" controls confuse alsamixer
12054 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012055 */
12056 /* .name = "Capture Source", */
12057 .name = "Input Source",
12058 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012059 .info = alc_mux_enum_info,
12060 .get = alc_mux_enum_get,
12061 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012062 },
12063 { } /* end */
12064};
12065
12066static struct snd_kcontrol_new alc268_capture_mixer[] = {
12067 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12068 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12069 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12070 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
12071 {
12072 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12073 /* The multiple "Capture Source" controls confuse alsamixer
12074 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020012075 */
12076 /* .name = "Capture Source", */
12077 .name = "Input Source",
12078 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012079 .info = alc_mux_enum_info,
12080 .get = alc_mux_enum_get,
12081 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020012082 },
12083 { } /* end */
12084};
12085
12086static struct hda_input_mux alc268_capture_source = {
12087 .num_items = 4,
12088 .items = {
12089 { "Mic", 0x0 },
12090 { "Front Mic", 0x1 },
12091 { "Line", 0x2 },
12092 { "CD", 0x3 },
12093 },
12094};
12095
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012096static struct hda_input_mux alc268_acer_capture_source = {
12097 .num_items = 3,
12098 .items = {
12099 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012100 { "Internal Mic", 0x1 },
12101 { "Line", 0x2 },
12102 },
12103};
12104
12105static struct hda_input_mux alc268_acer_dmic_capture_source = {
12106 .num_items = 3,
12107 .items = {
12108 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012109 { "Internal Mic", 0x6 },
12110 { "Line", 0x2 },
12111 },
12112};
12113
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012114#ifdef CONFIG_SND_DEBUG
12115static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012116 /* Volume widgets */
12117 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12118 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12119 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12120 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12121 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12122 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12123 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12124 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12125 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12126 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12127 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12128 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12129 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012130 /* The below appears problematic on some hardwares */
12131 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012132 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12133 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12134 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12135 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12136
12137 /* Modes for retasking pin widgets */
12138 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12139 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12140 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12141 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12142
12143 /* Controls for GPIO pins, assuming they are configured as outputs */
12144 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12145 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12146 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12147 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12148
12149 /* Switches to allow the digital SPDIF output pin to be enabled.
12150 * The ALC268 does not have an SPDIF input.
12151 */
12152 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12153
12154 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12155 * this output to turn on an external amplifier.
12156 */
12157 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12158 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12159
12160 { } /* end */
12161};
12162#endif
12163
Kailang Yanga361d842007-06-05 12:30:55 +020012164/* create input playback/capture controls for the given pin */
12165static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12166 const char *ctlname, int idx)
12167{
12168 char name[32];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012169 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012170 int err;
12171
12172 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012173 switch (nid) {
12174 case 0x14:
12175 case 0x16:
12176 dac = 0x02;
12177 break;
12178 case 0x15:
12179 dac = 0x03;
12180 break;
12181 default:
12182 return 0;
12183 }
12184 if (spec->multiout.dac_nids[0] != dac &&
12185 spec->multiout.dac_nids[1] != dac) {
Kailang Yanga361d842007-06-05 12:30:55 +020012186 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012187 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012188 HDA_OUTPUT));
12189 if (err < 0)
12190 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012191 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12192 }
12193
Kailang Yanga361d842007-06-05 12:30:55 +020012194 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012195 if (nid != 0x16)
12196 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
Kailang Yanga361d842007-06-05 12:30:55 +020012197 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012198 else /* mono */
12199 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
12200 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012201 if (err < 0)
12202 return err;
12203 return 0;
12204}
12205
12206/* add playback controls from the parsed DAC table */
12207static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12208 const struct auto_pin_cfg *cfg)
12209{
12210 hda_nid_t nid;
12211 int err;
12212
Kailang Yanga361d842007-06-05 12:30:55 +020012213 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012214
12215 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012216 if (nid) {
12217 const char *name;
12218 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12219 name = "Speaker";
12220 else
12221 name = "Front";
12222 err = alc268_new_analog_output(spec, nid, name, 0);
12223 if (err < 0)
12224 return err;
12225 }
Kailang Yanga361d842007-06-05 12:30:55 +020012226
12227 nid = cfg->speaker_pins[0];
12228 if (nid == 0x1d) {
12229 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12230 "Speaker Playback Volume",
12231 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12232 if (err < 0)
12233 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012234 } else {
12235 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12236 if (err < 0)
12237 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012238 }
12239 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012240 if (nid) {
12241 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12242 if (err < 0)
12243 return err;
12244 }
Kailang Yanga361d842007-06-05 12:30:55 +020012245
12246 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12247 if (nid == 0x16) {
12248 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12249 "Mono Playback Switch",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012250 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012251 if (err < 0)
12252 return err;
12253 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012254 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012255}
12256
12257/* create playback/capture controls for input pins */
12258static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
12259 const struct auto_pin_cfg *cfg)
12260{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012261 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012262 int i, idx1;
12263
12264 for (i = 0; i < AUTO_PIN_LAST; i++) {
12265 switch(cfg->input_pins[i]) {
12266 case 0x18:
12267 idx1 = 0; /* Mic 1 */
12268 break;
12269 case 0x19:
12270 idx1 = 1; /* Mic 2 */
12271 break;
12272 case 0x1a:
12273 idx1 = 2; /* Line In */
12274 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020012275 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020012276 idx1 = 3; /* CD */
12277 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010012278 case 0x12:
12279 case 0x13:
12280 idx1 = 6; /* digital mics */
12281 break;
Kailang Yanga361d842007-06-05 12:30:55 +020012282 default:
12283 continue;
12284 }
12285 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
12286 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020012287 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020012288 }
12289 return 0;
12290}
12291
12292static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12293{
12294 struct alc_spec *spec = codec->spec;
12295 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12296 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12297 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12298 unsigned int dac_vol1, dac_vol2;
12299
12300 if (speaker_nid) {
12301 snd_hda_codec_write(codec, speaker_nid, 0,
12302 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
12303 snd_hda_codec_write(codec, 0x0f, 0,
12304 AC_VERB_SET_AMP_GAIN_MUTE,
12305 AMP_IN_UNMUTE(1));
12306 snd_hda_codec_write(codec, 0x10, 0,
12307 AC_VERB_SET_AMP_GAIN_MUTE,
12308 AMP_IN_UNMUTE(1));
12309 } else {
12310 snd_hda_codec_write(codec, 0x0f, 0,
12311 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12312 snd_hda_codec_write(codec, 0x10, 0,
12313 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12314 }
12315
12316 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012317 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012318 dac_vol2 = AMP_OUT_ZERO;
12319 else if (line_nid == 0x15)
12320 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012321 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012322 dac_vol2 = AMP_OUT_ZERO;
12323 else if (hp_nid == 0x15)
12324 dac_vol1 = AMP_OUT_ZERO;
12325 if (line_nid != 0x16 || hp_nid != 0x16 ||
12326 spec->autocfg.line_out_pins[1] != 0x16 ||
12327 spec->autocfg.line_out_pins[2] != 0x16)
12328 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12329
12330 snd_hda_codec_write(codec, 0x02, 0,
12331 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12332 snd_hda_codec_write(codec, 0x03, 0,
12333 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12334}
12335
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012336/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012337#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12338#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012339#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012340#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12341
12342/*
12343 * BIOS auto configuration
12344 */
12345static int alc268_parse_auto_config(struct hda_codec *codec)
12346{
12347 struct alc_spec *spec = codec->spec;
12348 int err;
12349 static hda_nid_t alc268_ignore[] = { 0 };
12350
12351 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12352 alc268_ignore);
12353 if (err < 0)
12354 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012355 if (!spec->autocfg.line_outs) {
12356 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12357 spec->multiout.max_channels = 2;
12358 spec->no_analog = 1;
12359 goto dig_only;
12360 }
Kailang Yanga361d842007-06-05 12:30:55 +020012361 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012362 }
Kailang Yanga361d842007-06-05 12:30:55 +020012363 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12364 if (err < 0)
12365 return err;
12366 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
12367 if (err < 0)
12368 return err;
12369
12370 spec->multiout.max_channels = 2;
12371
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012372 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012373 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012374 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012375 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012376 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12377 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012378 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012379 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012380
Takashi Iwai892981f2009-03-02 08:04:35 +010012381 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012382 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012383
Takashi Iwaid88897e2008-10-31 15:01:37 +010012384 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020012385 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012386 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012387
Takashi Iwai776e1842007-08-29 15:07:11 +020012388 err = alc_auto_add_mic_boost(codec);
12389 if (err < 0)
12390 return err;
12391
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012392 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
12393
Kailang Yanga361d842007-06-05 12:30:55 +020012394 return 1;
12395}
12396
12397#define alc268_auto_init_multi_out alc882_auto_init_multi_out
12398#define alc268_auto_init_hp_out alc882_auto_init_hp_out
12399#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12400
12401/* init callback for auto-configuration model -- overriding the default init */
12402static void alc268_auto_init(struct hda_codec *codec)
12403{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012404 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012405 alc268_auto_init_multi_out(codec);
12406 alc268_auto_init_hp_out(codec);
12407 alc268_auto_init_mono_speaker_out(codec);
12408 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012409 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012410 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012411}
12412
12413/*
12414 * configuration and preset
12415 */
12416static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012417 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012418 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012419 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012420 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012421 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012422 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012423 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012424 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012425#ifdef CONFIG_SND_DEBUG
12426 [ALC268_TEST] = "test",
12427#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012428 [ALC268_AUTO] = "auto",
12429};
12430
12431static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020012432 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012433 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010012434 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012435 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010012436 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020012437 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
12438 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012439 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010012440 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012441 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
12442 ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020012443 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012444 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12445 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12446 ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020012447 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020012448 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012449 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020012450 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020012451 {}
12452};
12453
12454static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012455 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010012456 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012457 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12458 alc267_quanta_il1_verbs },
12459 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12460 .dac_nids = alc268_dac_nids,
12461 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12462 .adc_nids = alc268_adc_nids_alt,
12463 .hp_nid = 0x03,
12464 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12465 .channel_mode = alc268_modes,
12466 .input_mux = &alc268_capture_source,
12467 .unsol_event = alc267_quanta_il1_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012468 .init_hook = alc267_quanta_il1_init_hook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012469 },
Kailang Yanga361d842007-06-05 12:30:55 +020012470 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012471 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12472 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020012473 .init_verbs = { alc268_base_init_verbs },
12474 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12475 .dac_nids = alc268_dac_nids,
12476 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12477 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012478 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020012479 .hp_nid = 0x03,
12480 .dig_out_nid = ALC268_DIGOUT_NID,
12481 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12482 .channel_mode = alc268_modes,
12483 .input_mux = &alc268_capture_source,
12484 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012485 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012486 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012487 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012488 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12489 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020012490 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12491 .dac_nids = alc268_dac_nids,
12492 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12493 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012494 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012495 .hp_nid = 0x03,
12496 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12497 .channel_mode = alc268_modes,
12498 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012499 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012500 .init_hook = alc268_toshiba_init_hook,
Takashi Iwaid2738092007-08-16 14:59:45 +020012501 },
12502 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012503 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
12504 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020012505 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12506 alc268_acer_verbs },
12507 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12508 .dac_nids = alc268_dac_nids,
12509 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12510 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012511 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020012512 .hp_nid = 0x02,
12513 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12514 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012515 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020012516 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020012517 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020012518 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012519 [ALC268_ACER_DMIC] = {
12520 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
12521 alc268_beep_mixer },
12522 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12523 alc268_acer_verbs },
12524 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12525 .dac_nids = alc268_dac_nids,
12526 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12527 .adc_nids = alc268_adc_nids_alt,
12528 .capsrc_nids = alc268_capsrc_nids,
12529 .hp_nid = 0x02,
12530 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12531 .channel_mode = alc268_modes,
12532 .input_mux = &alc268_acer_dmic_capture_source,
12533 .unsol_event = alc268_acer_unsol_event,
12534 .init_hook = alc268_acer_init_hook,
12535 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012536 [ALC268_ACER_ASPIRE_ONE] = {
12537 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012538 alc268_beep_mixer,
12539 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012540 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12541 alc268_acer_aspire_one_verbs },
12542 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12543 .dac_nids = alc268_dac_nids,
12544 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12545 .adc_nids = alc268_adc_nids_alt,
12546 .capsrc_nids = alc268_capsrc_nids,
12547 .hp_nid = 0x03,
12548 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12549 .channel_mode = alc268_modes,
12550 .input_mux = &alc268_acer_lc_capture_source,
12551 .unsol_event = alc268_acer_lc_unsol_event,
12552 .init_hook = alc268_acer_lc_init_hook,
12553 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012554 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012555 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012556 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12557 alc268_dell_verbs },
12558 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12559 .dac_nids = alc268_dac_nids,
12560 .hp_nid = 0x02,
12561 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12562 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012563 .unsol_event = alc_sku_unsol_event,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012564 .init_hook = alc268_dell_init_hook,
12565 .input_mux = &alc268_capture_source,
12566 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012567 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012568 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12569 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012570 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12571 alc268_toshiba_verbs },
12572 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12573 .dac_nids = alc268_dac_nids,
12574 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12575 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012576 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012577 .hp_nid = 0x03,
12578 .dig_out_nid = ALC268_DIGOUT_NID,
12579 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12580 .channel_mode = alc268_modes,
12581 .input_mux = &alc268_capture_source,
12582 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai42171c12009-05-08 14:11:43 +020012583 .init_hook = alc268_toshiba_init_hook
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012584 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012585#ifdef CONFIG_SND_DEBUG
12586 [ALC268_TEST] = {
12587 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12588 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12589 alc268_volume_init_verbs },
12590 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12591 .dac_nids = alc268_dac_nids,
12592 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12593 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012594 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012595 .hp_nid = 0x03,
12596 .dig_out_nid = ALC268_DIGOUT_NID,
12597 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12598 .channel_mode = alc268_modes,
12599 .input_mux = &alc268_capture_source,
12600 },
12601#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012602};
12603
12604static int patch_alc268(struct hda_codec *codec)
12605{
12606 struct alc_spec *spec;
12607 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012608 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012609
12610 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12611 if (spec == NULL)
12612 return -ENOMEM;
12613
12614 codec->spec = spec;
12615
12616 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12617 alc268_models,
12618 alc268_cfg_tbl);
12619
12620 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012621 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12622 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020012623 board_config = ALC268_AUTO;
12624 }
12625
12626 if (board_config == ALC268_AUTO) {
12627 /* automatic parse from the BIOS config */
12628 err = alc268_parse_auto_config(codec);
12629 if (err < 0) {
12630 alc_free(codec);
12631 return err;
12632 } else if (!err) {
12633 printk(KERN_INFO
12634 "hda_codec: Cannot set up configuration "
12635 "from BIOS. Using base mode...\n");
12636 board_config = ALC268_3ST;
12637 }
12638 }
12639
12640 if (board_config != ALC268_AUTO)
12641 setup_preset(spec, &alc268_presets[board_config]);
12642
Kailang Yanga361d842007-06-05 12:30:55 +020012643 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12644 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012645 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012646
Kailang Yanga361d842007-06-05 12:30:55 +020012647 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12648
Takashi Iwai22971e32009-02-10 11:56:44 +010012649 has_beep = 0;
12650 for (i = 0; i < spec->num_mixers; i++) {
12651 if (spec->mixers[i] == alc268_beep_mixer) {
12652 has_beep = 1;
12653 break;
12654 }
12655 }
12656
12657 if (has_beep) {
12658 err = snd_hda_attach_beep_device(codec, 0x1);
12659 if (err < 0) {
12660 alc_free(codec);
12661 return err;
12662 }
12663 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12664 /* override the amp caps for beep generator */
12665 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012666 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12667 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12668 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12669 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012670 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012671
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012672 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012673 /* check whether NID 0x07 is valid */
12674 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012675 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012676
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012677 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012678 wcap = get_wcaps_type(wcap);
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012679 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012680 spec->adc_nids = alc268_adc_nids_alt;
12681 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012682 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012683 } else {
12684 spec->adc_nids = alc268_adc_nids;
12685 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012686 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012687 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012688 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012689 /* set default input source */
12690 for (i = 0; i < spec->num_adc_nids; i++)
12691 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12692 0, AC_VERB_SET_CONNECT_SEL,
12693 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012694 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012695
12696 spec->vmaster_nid = 0x02;
12697
Kailang Yanga361d842007-06-05 12:30:55 +020012698 codec->patch_ops = alc_patch_ops;
12699 if (board_config == ALC268_AUTO)
12700 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012701
Takashi Iwaidaead532008-11-28 12:55:36 +010012702 codec->proc_widget_hook = print_realtek_coef;
12703
Kailang Yanga361d842007-06-05 12:30:55 +020012704 return 0;
12705}
12706
12707/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012708 * ALC269 channel source setting (2 channel)
12709 */
12710#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12711
12712#define alc269_dac_nids alc260_dac_nids
12713
12714static hda_nid_t alc269_adc_nids[1] = {
12715 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012716 0x08,
12717};
12718
Takashi Iwaie01bf502008-08-21 16:25:07 +020012719static hda_nid_t alc269_capsrc_nids[1] = {
12720 0x23,
12721};
12722
12723/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12724 * not a mux!
12725 */
12726
Kailang Yangf53281e2008-07-18 12:36:43 +020012727static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12728 .num_items = 2,
12729 .items = {
12730 { "i-Mic", 0x5 },
12731 { "e-Mic", 0x0 },
12732 },
12733};
12734
12735static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12736 .num_items = 2,
12737 .items = {
12738 { "i-Mic", 0x1 },
12739 { "e-Mic", 0x0 },
12740 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012741};
12742
12743#define alc269_modes alc260_modes
12744#define alc269_capture_source alc880_lg_lw_capture_source
12745
12746static struct snd_kcontrol_new alc269_base_mixer[] = {
12747 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12748 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12749 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12750 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12752 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12753 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12755 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12756 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12758 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12759 { } /* end */
12760};
12761
Kailang Yang60db6b52008-08-26 13:13:00 +020012762static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12763 /* output mixer control */
12764 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12765 {
12766 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12767 .name = "Master Playback Switch",
12768 .info = snd_hda_mixer_amp_switch_info,
12769 .get = snd_hda_mixer_amp_switch_get,
12770 .put = alc268_acer_master_sw_put,
12771 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12772 },
12773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12776 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12777 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12778 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012779 { }
12780};
12781
Tony Vroon64154832008-11-06 15:08:49 +000012782static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12783 /* output mixer control */
12784 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12785 {
12786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12787 .name = "Master Playback Switch",
12788 .info = snd_hda_mixer_amp_switch_info,
12789 .get = snd_hda_mixer_amp_switch_get,
12790 .put = alc268_acer_master_sw_put,
12791 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12792 },
12793 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12794 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12795 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12796 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12797 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12798 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12799 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12800 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12801 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012802 { }
12803};
12804
Kailang Yangf53281e2008-07-18 12:36:43 +020012805static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020012806 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012807 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020012808 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010012809 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020012810 { } /* end */
12811};
12812
Kailang Yangf6a92242007-12-13 16:52:54 +010012813/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012814static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12815 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12816 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012817 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12818 { } /* end */
12819};
12820
12821/* FSC amilo */
Takashi Iwaiaa202452009-07-03 15:00:54 +020012822#define alc269_fujitsu_mixer alc269_eeepc_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020012823
Kailang Yang60db6b52008-08-26 13:13:00 +020012824static struct hda_verb alc269_quanta_fl1_verbs[] = {
12825 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12826 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12828 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12829 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12830 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12831 { }
12832};
12833
Tony Vroon64154832008-11-06 15:08:49 +000012834static struct hda_verb alc269_lifebook_verbs[] = {
12835 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12836 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12837 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12838 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12839 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12840 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12842 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12843 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12844 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12845 { }
12846};
12847
Kailang Yang60db6b52008-08-26 13:13:00 +020012848/* toggle speaker-output according to the hp-jack state */
12849static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12850{
12851 unsigned int present;
12852 unsigned char bits;
12853
12854 present = snd_hda_codec_read(codec, 0x15, 0,
12855 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12856 bits = present ? AMP_IN_MUTE(0) : 0;
12857 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12858 AMP_IN_MUTE(0), bits);
12859 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12860 AMP_IN_MUTE(0), bits);
12861
12862 snd_hda_codec_write(codec, 0x20, 0,
12863 AC_VERB_SET_COEF_INDEX, 0x0c);
12864 snd_hda_codec_write(codec, 0x20, 0,
12865 AC_VERB_SET_PROC_COEF, 0x680);
12866
12867 snd_hda_codec_write(codec, 0x20, 0,
12868 AC_VERB_SET_COEF_INDEX, 0x0c);
12869 snd_hda_codec_write(codec, 0x20, 0,
12870 AC_VERB_SET_PROC_COEF, 0x480);
12871}
12872
Tony Vroon64154832008-11-06 15:08:49 +000012873/* toggle speaker-output according to the hp-jacks state */
12874static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12875{
12876 unsigned int present;
12877 unsigned char bits;
12878
12879 /* Check laptop headphone socket */
12880 present = snd_hda_codec_read(codec, 0x15, 0,
12881 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12882
12883 /* Check port replicator headphone socket */
12884 present |= snd_hda_codec_read(codec, 0x1a, 0,
12885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12886
12887 bits = present ? AMP_IN_MUTE(0) : 0;
12888 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12889 AMP_IN_MUTE(0), bits);
12890 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12891 AMP_IN_MUTE(0), bits);
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, 0x680);
12897
12898 snd_hda_codec_write(codec, 0x20, 0,
12899 AC_VERB_SET_COEF_INDEX, 0x0c);
12900 snd_hda_codec_write(codec, 0x20, 0,
12901 AC_VERB_SET_PROC_COEF, 0x480);
12902}
12903
Kailang Yang60db6b52008-08-26 13:13:00 +020012904static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12905{
12906 unsigned int present;
12907
12908 present = snd_hda_codec_read(codec, 0x18, 0,
12909 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12910 snd_hda_codec_write(codec, 0x23, 0,
12911 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12912}
12913
Tony Vroon64154832008-11-06 15:08:49 +000012914static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12915{
12916 unsigned int present_laptop;
12917 unsigned int present_dock;
12918
12919 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12920 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12921
12922 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12923 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12924
12925 /* Laptop mic port overrides dock mic port, design decision */
12926 if (present_dock)
12927 snd_hda_codec_write(codec, 0x23, 0,
12928 AC_VERB_SET_CONNECT_SEL, 0x3);
12929 if (present_laptop)
12930 snd_hda_codec_write(codec, 0x23, 0,
12931 AC_VERB_SET_CONNECT_SEL, 0x0);
12932 if (!present_dock && !present_laptop)
12933 snd_hda_codec_write(codec, 0x23, 0,
12934 AC_VERB_SET_CONNECT_SEL, 0x1);
12935}
12936
Kailang Yang60db6b52008-08-26 13:13:00 +020012937static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12938 unsigned int res)
12939{
12940 if ((res >> 26) == ALC880_HP_EVENT)
12941 alc269_quanta_fl1_speaker_automute(codec);
12942 if ((res >> 26) == ALC880_MIC_EVENT)
12943 alc269_quanta_fl1_mic_automute(codec);
12944}
12945
Tony Vroon64154832008-11-06 15:08:49 +000012946static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12947 unsigned int res)
12948{
12949 if ((res >> 26) == ALC880_HP_EVENT)
12950 alc269_lifebook_speaker_automute(codec);
12951 if ((res >> 26) == ALC880_MIC_EVENT)
12952 alc269_lifebook_mic_autoswitch(codec);
12953}
12954
Kailang Yang60db6b52008-08-26 13:13:00 +020012955static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12956{
12957 alc269_quanta_fl1_speaker_automute(codec);
12958 alc269_quanta_fl1_mic_automute(codec);
12959}
12960
Tony Vroon64154832008-11-06 15:08:49 +000012961static void alc269_lifebook_init_hook(struct hda_codec *codec)
12962{
12963 alc269_lifebook_speaker_automute(codec);
12964 alc269_lifebook_mic_autoswitch(codec);
12965}
12966
Kailang Yang60db6b52008-08-26 13:13:00 +020012967static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12968 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12969 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12970 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12971 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12972 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12973 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12974 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12975 {}
12976};
12977
12978static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12980 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12981 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12982 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12983 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12984 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12985 {}
12986};
12987
12988/* toggle speaker-output according to the hp-jack state */
12989static void alc269_speaker_automute(struct hda_codec *codec)
12990{
12991 unsigned int present;
12992 unsigned char bits;
12993
12994 present = snd_hda_codec_read(codec, 0x15, 0,
12995 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12996 bits = present ? AMP_IN_MUTE(0) : 0;
12997 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12998 AMP_IN_MUTE(0), bits);
12999 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13000 AMP_IN_MUTE(0), bits);
13001}
13002
13003static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
13004{
13005 unsigned int present;
13006
13007 present = snd_hda_codec_read(codec, 0x18, 0,
13008 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13009 snd_hda_codec_write(codec, 0x23, 0,
13010 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
13011}
13012
13013static void alc269_eeepc_amic_automute(struct hda_codec *codec)
13014{
13015 unsigned int present;
13016
13017 present = snd_hda_codec_read(codec, 0x18, 0,
13018 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
13019 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13020 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
13021 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13022 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
13023}
13024
13025/* unsolicited event for HP jack sensing */
13026static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
13027 unsigned int res)
13028{
13029 if ((res >> 26) == ALC880_HP_EVENT)
13030 alc269_speaker_automute(codec);
13031
13032 if ((res >> 26) == ALC880_MIC_EVENT)
13033 alc269_eeepc_dmic_automute(codec);
13034}
13035
13036static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
13037{
13038 alc269_speaker_automute(codec);
13039 alc269_eeepc_dmic_automute(codec);
13040}
13041
13042/* unsolicited event for HP jack sensing */
13043static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
13044 unsigned int res)
13045{
13046 if ((res >> 26) == ALC880_HP_EVENT)
13047 alc269_speaker_automute(codec);
13048
13049 if ((res >> 26) == ALC880_MIC_EVENT)
13050 alc269_eeepc_amic_automute(codec);
13051}
13052
13053static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
13054{
13055 alc269_speaker_automute(codec);
13056 alc269_eeepc_amic_automute(codec);
13057}
13058
Kailang Yangf6a92242007-12-13 16:52:54 +010013059/*
13060 * generic initialization of ADC, input mixers and output mixers
13061 */
13062static struct hda_verb alc269_init_verbs[] = {
13063 /*
13064 * Unmute ADC0 and set the default input to mic-in
13065 */
Kailang Yang60db6b52008-08-26 13:13:00 +020013066 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013067
13068 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
13069 * analog-loopback mixer widget
13070 * Note: PASD motherboards uses the Line In 2 as the input for
13071 * front panel mic (mic 2)
13072 */
13073 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
13074 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13075 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13076 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13077 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13078 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13079
13080 /*
13081 * Set up output mixers (0x0c - 0x0e)
13082 */
13083 /* set vol=0 to output mixers */
13084 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13085 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13086
13087 /* set up input amps for analog loopback */
13088 /* Amp Indices: DAC = 0, mixer = 1 */
13089 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13092 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13095
13096 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13098 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13100 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13101 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13102 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13103
13104 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13106 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13107 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13108 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13109 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13110 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13111
13112 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13113 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
13114
13115 /* FIXME: use matrix-type input source selection */
13116 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13117 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020013118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13119 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13121 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13122
13123 /* set EAPD */
13124 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13125 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13126 { }
13127};
13128
13129/* add playback controls from the parsed DAC table */
13130static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
13131 const struct auto_pin_cfg *cfg)
13132{
13133 hda_nid_t nid;
13134 int err;
13135
13136 spec->multiout.num_dacs = 1; /* only use one dac */
13137 spec->multiout.dac_nids = spec->private_dac_nids;
13138 spec->multiout.dac_nids[0] = 2;
13139
13140 nid = cfg->line_out_pins[0];
13141 if (nid) {
13142 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13143 "Front Playback Volume",
13144 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
13145 if (err < 0)
13146 return err;
13147 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13148 "Front Playback Switch",
13149 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13150 if (err < 0)
13151 return err;
13152 }
13153
13154 nid = cfg->speaker_pins[0];
13155 if (nid) {
13156 if (!cfg->line_out_pins[0]) {
13157 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13158 "Speaker Playback Volume",
13159 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13160 HDA_OUTPUT));
13161 if (err < 0)
13162 return err;
13163 }
13164 if (nid == 0x16) {
13165 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13166 "Speaker Playback Switch",
13167 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13168 HDA_OUTPUT));
13169 if (err < 0)
13170 return err;
13171 } else {
13172 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13173 "Speaker Playback Switch",
13174 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13175 HDA_OUTPUT));
13176 if (err < 0)
13177 return err;
13178 }
13179 }
13180 nid = cfg->hp_pins[0];
13181 if (nid) {
13182 /* spec->multiout.hp_nid = 2; */
13183 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
13184 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13185 "Headphone Playback Volume",
13186 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
13187 HDA_OUTPUT));
13188 if (err < 0)
13189 return err;
13190 }
13191 if (nid == 0x16) {
13192 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13193 "Headphone Playback Switch",
13194 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13195 HDA_OUTPUT));
13196 if (err < 0)
13197 return err;
13198 } else {
13199 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13200 "Headphone Playback Switch",
13201 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13202 HDA_OUTPUT));
13203 if (err < 0)
13204 return err;
13205 }
13206 }
13207 return 0;
13208}
13209
Takashi Iwai8c927b42009-06-22 10:56:54 +020013210#define alc269_auto_create_analog_input_ctls \
13211 alc262_auto_create_analog_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013212
13213#ifdef CONFIG_SND_HDA_POWER_SAVE
13214#define alc269_loopbacks alc880_loopbacks
13215#endif
13216
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013217/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013218#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13219#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13220#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13221#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13222
Takashi Iwaif03d3112009-03-05 14:18:16 +010013223static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13224 .substreams = 1,
13225 .channels_min = 2,
13226 .channels_max = 8,
13227 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13228 /* NID is set in alc_build_pcms */
13229 .ops = {
13230 .open = alc880_playback_pcm_open,
13231 .prepare = alc880_playback_pcm_prepare,
13232 .cleanup = alc880_playback_pcm_cleanup
13233 },
13234};
13235
13236static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13237 .substreams = 1,
13238 .channels_min = 2,
13239 .channels_max = 2,
13240 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13241 /* NID is set in alc_build_pcms */
13242};
13243
Kailang Yangf6a92242007-12-13 16:52:54 +010013244/*
13245 * BIOS auto configuration
13246 */
13247static int alc269_parse_auto_config(struct hda_codec *codec)
13248{
13249 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013250 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013251 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
13252
13253 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13254 alc269_ignore);
13255 if (err < 0)
13256 return err;
13257
13258 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13259 if (err < 0)
13260 return err;
13261 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
13262 if (err < 0)
13263 return err;
13264
13265 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13266
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013267 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013268 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13269
Takashi Iwai603c4012008-07-30 15:01:44 +020013270 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013271 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013272
Takashi Iwaid88897e2008-10-31 15:01:37 +010013273 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010013274 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013275 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013276 /* set default input source */
13277 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
13278 0, AC_VERB_SET_CONNECT_SEL,
13279 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013280
13281 err = alc_auto_add_mic_boost(codec);
13282 if (err < 0)
13283 return err;
13284
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013285 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013286 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013287
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013288 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
13289
Kailang Yangf6a92242007-12-13 16:52:54 +010013290 return 1;
13291}
13292
13293#define alc269_auto_init_multi_out alc882_auto_init_multi_out
13294#define alc269_auto_init_hp_out alc882_auto_init_hp_out
13295#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13296
13297
13298/* init callback for auto-configuration model -- overriding the default init */
13299static void alc269_auto_init(struct hda_codec *codec)
13300{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013301 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013302 alc269_auto_init_multi_out(codec);
13303 alc269_auto_init_hp_out(codec);
13304 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013305 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013306 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013307}
13308
13309/*
13310 * configuration and preset
13311 */
13312static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013313 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013314 [ALC269_QUANTA_FL1] = "quanta",
13315 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010013316 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000013317 [ALC269_FUJITSU] = "fujitsu",
13318 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010013319};
13320
13321static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013322 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013323 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
13324 ALC269_ASUS_EEEPC_P703),
Kailang Yang622e84c2009-04-21 07:39:04 +020013325 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_ASUS_EEEPC_P703),
13326 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_ASUS_EEEPC_P703),
13327 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_ASUS_EEEPC_P703),
13328 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_ASUS_EEEPC_P703),
13329 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_ASUS_EEEPC_P703),
13330 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_ASUS_EEEPC_P703),
Kailang Yangf53281e2008-07-18 12:36:43 +020013331 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
13332 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020013333 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
13334 ALC269_ASUS_EEEPC_P901),
Kailang Yang622e84c2009-04-21 07:39:04 +020013335 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013336 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000013337 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010013338 {}
13339};
13340
13341static struct alc_config_preset alc269_presets[] = {
13342 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013343 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013344 .init_verbs = { alc269_init_verbs },
13345 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13346 .dac_nids = alc269_dac_nids,
13347 .hp_nid = 0x03,
13348 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13349 .channel_mode = alc269_modes,
13350 .input_mux = &alc269_capture_source,
13351 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013352 [ALC269_QUANTA_FL1] = {
13353 .mixers = { alc269_quanta_fl1_mixer },
13354 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13355 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13356 .dac_nids = alc269_dac_nids,
13357 .hp_nid = 0x03,
13358 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13359 .channel_mode = alc269_modes,
13360 .input_mux = &alc269_capture_source,
13361 .unsol_event = alc269_quanta_fl1_unsol_event,
13362 .init_hook = alc269_quanta_fl1_init_hook,
13363 },
Kailang Yangf53281e2008-07-18 12:36:43 +020013364 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013365 .mixers = { alc269_eeepc_mixer },
13366 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013367 .init_verbs = { alc269_init_verbs,
13368 alc269_eeepc_amic_init_verbs },
13369 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13370 .dac_nids = alc269_dac_nids,
13371 .hp_nid = 0x03,
13372 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13373 .channel_mode = alc269_modes,
13374 .input_mux = &alc269_eeepc_amic_capture_source,
13375 .unsol_event = alc269_eeepc_amic_unsol_event,
13376 .init_hook = alc269_eeepc_amic_inithook,
13377 },
13378 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013379 .mixers = { alc269_eeepc_mixer },
13380 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020013381 .init_verbs = { alc269_init_verbs,
13382 alc269_eeepc_dmic_init_verbs },
13383 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13384 .dac_nids = alc269_dac_nids,
13385 .hp_nid = 0x03,
13386 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13387 .channel_mode = alc269_modes,
13388 .input_mux = &alc269_eeepc_dmic_capture_source,
13389 .unsol_event = alc269_eeepc_dmic_unsol_event,
13390 .init_hook = alc269_eeepc_dmic_inithook,
13391 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013392 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013393 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010013394 .cap_mixer = alc269_epc_capture_mixer,
13395 .init_verbs = { alc269_init_verbs,
13396 alc269_eeepc_dmic_init_verbs },
13397 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13398 .dac_nids = alc269_dac_nids,
13399 .hp_nid = 0x03,
13400 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13401 .channel_mode = alc269_modes,
13402 .input_mux = &alc269_eeepc_dmic_capture_source,
13403 .unsol_event = alc269_eeepc_dmic_unsol_event,
13404 .init_hook = alc269_eeepc_dmic_inithook,
13405 },
Tony Vroon64154832008-11-06 15:08:49 +000013406 [ALC269_LIFEBOOK] = {
13407 .mixers = { alc269_lifebook_mixer },
13408 .init_verbs = { alc269_init_verbs, alc269_lifebook_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_capture_source,
13415 .unsol_event = alc269_lifebook_unsol_event,
13416 .init_hook = alc269_lifebook_init_hook,
13417 },
Kailang Yangf6a92242007-12-13 16:52:54 +010013418};
13419
13420static int patch_alc269(struct hda_codec *codec)
13421{
13422 struct alc_spec *spec;
13423 int board_config;
13424 int err;
13425
13426 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
13427 if (spec == NULL)
13428 return -ENOMEM;
13429
13430 codec->spec = spec;
13431
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020013432 alc_fix_pll_init(codec, 0x20, 0x04, 15);
13433
Kailang Yangf6a92242007-12-13 16:52:54 +010013434 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
13435 alc269_models,
13436 alc269_cfg_tbl);
13437
13438 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013439 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13440 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010013441 board_config = ALC269_AUTO;
13442 }
13443
13444 if (board_config == ALC269_AUTO) {
13445 /* automatic parse from the BIOS config */
13446 err = alc269_parse_auto_config(codec);
13447 if (err < 0) {
13448 alc_free(codec);
13449 return err;
13450 } else if (!err) {
13451 printk(KERN_INFO
13452 "hda_codec: Cannot set up configuration "
13453 "from BIOS. Using base mode...\n");
13454 board_config = ALC269_BASIC;
13455 }
13456 }
13457
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090013458 err = snd_hda_attach_beep_device(codec, 0x1);
13459 if (err < 0) {
13460 alc_free(codec);
13461 return err;
13462 }
13463
Kailang Yangf6a92242007-12-13 16:52:54 +010013464 if (board_config != ALC269_AUTO)
13465 setup_preset(spec, &alc269_presets[board_config]);
13466
Takashi Iwaif03d3112009-03-05 14:18:16 +010013467 if (codec->subsystem_id == 0x17aa3bf8) {
13468 /* Due to a hardware problem on Lenovo Ideadpad, we need to
13469 * fix the sample rate of analog I/O to 44.1kHz
13470 */
13471 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
13472 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
13473 } else {
13474 spec->stream_analog_playback = &alc269_pcm_analog_playback;
13475 spec->stream_analog_capture = &alc269_pcm_analog_capture;
13476 }
Kailang Yangf6a92242007-12-13 16:52:54 +010013477 spec->stream_digital_playback = &alc269_pcm_digital_playback;
13478 spec->stream_digital_capture = &alc269_pcm_digital_capture;
13479
13480 spec->adc_nids = alc269_adc_nids;
13481 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020013482 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013483 if (!spec->cap_mixer)
13484 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010013485 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010013486
Takashi Iwai100d5eb2009-08-10 11:55:51 +020013487 spec->vmaster_nid = 0x02;
13488
Kailang Yangf6a92242007-12-13 16:52:54 +010013489 codec->patch_ops = alc_patch_ops;
13490 if (board_config == ALC269_AUTO)
13491 spec->init_hook = alc269_auto_init;
13492#ifdef CONFIG_SND_HDA_POWER_SAVE
13493 if (!spec->loopback.amplist)
13494 spec->loopback.amplist = alc269_loopbacks;
13495#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010013496 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010013497
13498 return 0;
13499}
13500
13501/*
Kailang Yangdf694da2005-12-05 19:42:22 +010013502 * ALC861 channel source setting (2/6 channel selection for 3-stack)
13503 */
13504
13505/*
13506 * set the path ways for 2 channel output
13507 * need to set the codec line out and mic 1 pin widgets to inputs
13508 */
13509static struct hda_verb alc861_threestack_ch2_init[] = {
13510 /* set pin widget 1Ah (line in) for input */
13511 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013512 /* set pin widget 18h (mic1/2) for input, for mic also enable
13513 * the vref
13514 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013515 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13516
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013517 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13518#if 0
13519 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13520 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13521#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013522 { } /* end */
13523};
13524/*
13525 * 6ch mode
13526 * need to set the codec line out and mic 1 pin widgets to outputs
13527 */
13528static struct hda_verb alc861_threestack_ch6_init[] = {
13529 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13530 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13531 /* set pin widget 18h (mic1) for output (CLFE)*/
13532 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13533
13534 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013535 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013536
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013537 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13538#if 0
13539 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13540 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13541#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013542 { } /* end */
13543};
13544
13545static struct hda_channel_mode alc861_threestack_modes[2] = {
13546 { 2, alc861_threestack_ch2_init },
13547 { 6, alc861_threestack_ch6_init },
13548};
Takashi Iwai22309c32006-08-09 16:57:28 +020013549/* Set mic1 as input and unmute the mixer */
13550static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13551 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13552 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13553 { } /* end */
13554};
13555/* Set mic1 as output and mute mixer */
13556static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13557 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13558 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13559 { } /* end */
13560};
13561
13562static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13563 { 2, alc861_uniwill_m31_ch2_init },
13564 { 4, alc861_uniwill_m31_ch4_init },
13565};
Kailang Yangdf694da2005-12-05 19:42:22 +010013566
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013567/* Set mic1 and line-in as input and unmute the mixer */
13568static struct hda_verb alc861_asus_ch2_init[] = {
13569 /* set pin widget 1Ah (line in) for input */
13570 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013571 /* set pin widget 18h (mic1/2) for input, for mic also enable
13572 * the vref
13573 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013574 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13575
13576 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13577#if 0
13578 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13579 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13580#endif
13581 { } /* end */
13582};
13583/* Set mic1 nad line-in as output and mute mixer */
13584static struct hda_verb alc861_asus_ch6_init[] = {
13585 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13586 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13587 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13588 /* set pin widget 18h (mic1) for output (CLFE)*/
13589 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13590 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13591 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13592 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13593
13594 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13595#if 0
13596 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13597 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13598#endif
13599 { } /* end */
13600};
13601
13602static struct hda_channel_mode alc861_asus_modes[2] = {
13603 { 2, alc861_asus_ch2_init },
13604 { 6, alc861_asus_ch6_init },
13605};
13606
Kailang Yangdf694da2005-12-05 19:42:22 +010013607/* patch-ALC861 */
13608
13609static struct snd_kcontrol_new alc861_base_mixer[] = {
13610 /* output mixer control */
13611 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13612 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13613 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13614 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13615 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13616
13617 /*Input mixer control */
13618 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13619 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13620 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13621 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13622 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13623 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13625 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13626 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13627 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013628
Kailang Yangdf694da2005-12-05 19:42:22 +010013629 { } /* end */
13630};
13631
13632static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13633 /* output mixer control */
13634 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13635 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13636 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13637 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13638 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13639
13640 /* Input mixer control */
13641 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13642 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13643 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13644 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13645 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13646 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13648 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13649 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13650 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013651
Kailang Yangdf694da2005-12-05 19:42:22 +010013652 {
13653 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13654 .name = "Channel Mode",
13655 .info = alc_ch_mode_info,
13656 .get = alc_ch_mode_get,
13657 .put = alc_ch_mode_put,
13658 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13659 },
13660 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013661};
13662
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013663static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013664 /* output mixer control */
13665 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13667 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013668
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013669 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013670};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013671
Takashi Iwai22309c32006-08-09 16:57:28 +020013672static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13673 /* output mixer control */
13674 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13675 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13676 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13677 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13678 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13679
13680 /* Input mixer control */
13681 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13682 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13683 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13684 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13685 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13686 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13688 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13689 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013691
Takashi Iwai22309c32006-08-09 16:57:28 +020013692 {
13693 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13694 .name = "Channel Mode",
13695 .info = alc_ch_mode_info,
13696 .get = alc_ch_mode_get,
13697 .put = alc_ch_mode_put,
13698 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13699 },
13700 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013701};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013702
13703static struct snd_kcontrol_new alc861_asus_mixer[] = {
13704 /* output mixer control */
13705 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13706 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13707 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13708 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13709 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13710
13711 /* Input mixer control */
13712 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13713 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13714 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13715 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13716 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13717 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13719 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13720 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13722
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013723 {
13724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13725 .name = "Channel Mode",
13726 .info = alc_ch_mode_info,
13727 .get = alc_ch_mode_get,
13728 .put = alc_ch_mode_put,
13729 .private_value = ARRAY_SIZE(alc861_asus_modes),
13730 },
13731 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013732};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013733
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013734/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013735static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013736 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13737 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013738 { }
13739};
13740
Kailang Yangdf694da2005-12-05 19:42:22 +010013741/*
13742 * generic initialization of ADC, input mixers and output mixers
13743 */
13744static struct hda_verb alc861_base_init_verbs[] = {
13745 /*
13746 * Unmute ADC0 and set the default input to mic-in
13747 */
13748 /* port-A for surround (rear panel) */
13749 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13750 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13751 /* port-B for mic-in (rear panel) with vref */
13752 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13753 /* port-C for line-in (rear panel) */
13754 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13755 /* port-D for Front */
13756 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13757 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13758 /* port-E for HP out (front panel) */
13759 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13760 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013761 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013762 /* port-F for mic-in (front panel) with vref */
13763 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13764 /* port-G for CLFE (rear panel) */
13765 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13766 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13767 /* port-H for side (rear panel) */
13768 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13769 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13770 /* CD-in */
13771 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13772 /* route front mic to ADC1*/
13773 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13774 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013775
Kailang Yangdf694da2005-12-05 19:42:22 +010013776 /* Unmute DAC0~3 & spdif out*/
13777 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13778 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13779 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13780 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013782
Kailang Yangdf694da2005-12-05 19:42:22 +010013783 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13784 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13785 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13786 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13787 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013788
Kailang Yangdf694da2005-12-05 19:42:22 +010013789 /* Unmute Stereo Mixer 15 */
13790 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13791 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013793 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013794
13795 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13796 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13797 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13798 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13799 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13800 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13801 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13802 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013803 /* hp used DAC 3 (Front) */
13804 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13806
13807 { }
13808};
13809
13810static struct hda_verb alc861_threestack_init_verbs[] = {
13811 /*
13812 * Unmute ADC0 and set the default input to mic-in
13813 */
13814 /* port-A for surround (rear panel) */
13815 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13816 /* port-B for mic-in (rear panel) with vref */
13817 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13818 /* port-C for line-in (rear panel) */
13819 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13820 /* port-D for Front */
13821 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13822 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13823 /* port-E for HP out (front panel) */
13824 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13825 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013826 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013827 /* port-F for mic-in (front panel) with vref */
13828 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13829 /* port-G for CLFE (rear panel) */
13830 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13831 /* port-H for side (rear panel) */
13832 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13833 /* CD-in */
13834 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13835 /* route front mic to ADC1*/
13836 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13837 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13838 /* Unmute DAC0~3 & spdif out*/
13839 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13840 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13841 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13842 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13843 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013844
Kailang Yangdf694da2005-12-05 19:42:22 +010013845 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13846 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13847 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13848 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13849 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013850
Kailang Yangdf694da2005-12-05 19:42:22 +010013851 /* Unmute Stereo Mixer 15 */
13852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013856
13857 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13859 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13860 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13861 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013865 /* hp used DAC 3 (Front) */
13866 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13868 { }
13869};
Takashi Iwai22309c32006-08-09 16:57:28 +020013870
13871static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13872 /*
13873 * Unmute ADC0 and set the default input to mic-in
13874 */
13875 /* port-A for surround (rear panel) */
13876 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13877 /* port-B for mic-in (rear panel) with vref */
13878 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13879 /* port-C for line-in (rear panel) */
13880 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13881 /* port-D for Front */
13882 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13883 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13884 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013885 /* this has to be set to VREF80 */
13886 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013887 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013888 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013889 /* port-F for mic-in (front panel) with vref */
13890 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13891 /* port-G for CLFE (rear panel) */
13892 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13893 /* port-H for side (rear panel) */
13894 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13895 /* CD-in */
13896 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13897 /* route front mic to ADC1*/
13898 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13899 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13900 /* Unmute DAC0~3 & spdif out*/
13901 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13902 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13903 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13904 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13905 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013906
Takashi Iwai22309c32006-08-09 16:57:28 +020013907 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13908 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13909 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13910 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13911 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013912
Takashi Iwai22309c32006-08-09 16:57:28 +020013913 /* Unmute Stereo Mixer 15 */
13914 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013918
13919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13921 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13922 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13924 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13925 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13926 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013927 /* hp used DAC 3 (Front) */
13928 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13930 { }
13931};
13932
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013933static struct hda_verb alc861_asus_init_verbs[] = {
13934 /*
13935 * Unmute ADC0 and set the default input to mic-in
13936 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013937 /* port-A for surround (rear panel)
13938 * according to codec#0 this is the HP jack
13939 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013940 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13941 /* route front PCM to HP */
13942 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13943 /* port-B for mic-in (rear panel) with vref */
13944 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13945 /* port-C for line-in (rear panel) */
13946 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13947 /* port-D for Front */
13948 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13949 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13950 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013951 /* this has to be set to VREF80 */
13952 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013953 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013954 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013955 /* port-F for mic-in (front panel) with vref */
13956 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13957 /* port-G for CLFE (rear panel) */
13958 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13959 /* port-H for side (rear panel) */
13960 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13961 /* CD-in */
13962 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13963 /* route front mic to ADC1*/
13964 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13965 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13966 /* Unmute DAC0~3 & spdif out*/
13967 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13968 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13969 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13970 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13972 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13973 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13974 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13975 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13976 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013977
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013978 /* Unmute Stereo Mixer 15 */
13979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013983
13984 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13985 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13989 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13990 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013992 /* hp used DAC 3 (Front) */
13993 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13995 { }
13996};
13997
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013998/* additional init verbs for ASUS laptops */
13999static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14000 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14001 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14002 { }
14003};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014004
Kailang Yangdf694da2005-12-05 19:42:22 +010014005/*
14006 * generic initialization of ADC, input mixers and output mixers
14007 */
14008static struct hda_verb alc861_auto_init_verbs[] = {
14009 /*
14010 * Unmute ADC0 and set the default input to mic-in
14011 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014012 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014013 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014014
Kailang Yangdf694da2005-12-05 19:42:22 +010014015 /* Unmute DAC0~3 & spdif out*/
14016 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14017 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14018 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14019 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014021
Kailang Yangdf694da2005-12-05 19:42:22 +010014022 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14023 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14024 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14025 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14026 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014027
Kailang Yangdf694da2005-12-05 19:42:22 +010014028 /* Unmute Stereo Mixer 15 */
14029 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14033
Takashi Iwai1c209302009-07-22 15:17:45 +020014034 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14035 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14036 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14037 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14038 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14040 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14041 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014042
14043 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14044 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014047 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14048 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014049 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14050 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014051
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014052 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014053
14054 { }
14055};
14056
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014057static struct hda_verb alc861_toshiba_init_verbs[] = {
14058 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014059
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014060 { }
14061};
14062
14063/* toggle speaker-output according to the hp-jack state */
14064static void alc861_toshiba_automute(struct hda_codec *codec)
14065{
14066 unsigned int present;
14067
14068 present = snd_hda_codec_read(codec, 0x0f, 0,
14069 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014070 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14071 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14072 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14073 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014074}
14075
14076static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14077 unsigned int res)
14078{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014079 if ((res >> 26) == ALC880_HP_EVENT)
14080 alc861_toshiba_automute(codec);
14081}
14082
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014083/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014084#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14085#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14086#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14087#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14088
14089
14090#define ALC861_DIGOUT_NID 0x07
14091
14092static struct hda_channel_mode alc861_8ch_modes[1] = {
14093 { 8, NULL }
14094};
14095
14096static hda_nid_t alc861_dac_nids[4] = {
14097 /* front, surround, clfe, side */
14098 0x03, 0x06, 0x05, 0x04
14099};
14100
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014101static hda_nid_t alc660_dac_nids[3] = {
14102 /* front, clfe, surround */
14103 0x03, 0x05, 0x06
14104};
14105
Kailang Yangdf694da2005-12-05 19:42:22 +010014106static hda_nid_t alc861_adc_nids[1] = {
14107 /* ADC0-2 */
14108 0x08,
14109};
14110
14111static struct hda_input_mux alc861_capture_source = {
14112 .num_items = 5,
14113 .items = {
14114 { "Mic", 0x0 },
14115 { "Front Mic", 0x3 },
14116 { "Line", 0x1 },
14117 { "CD", 0x4 },
14118 { "Mixer", 0x5 },
14119 },
14120};
14121
Takashi Iwai1c209302009-07-22 15:17:45 +020014122static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14123{
14124 struct alc_spec *spec = codec->spec;
14125 hda_nid_t mix, srcs[5];
14126 int i, j, num;
14127
14128 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14129 return 0;
14130 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14131 if (num < 0)
14132 return 0;
14133 for (i = 0; i < num; i++) {
14134 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014135 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014136 if (type != AC_WID_AUD_OUT)
14137 continue;
14138 for (j = 0; j < spec->multiout.num_dacs; j++)
14139 if (spec->multiout.dac_nids[j] == srcs[i])
14140 break;
14141 if (j >= spec->multiout.num_dacs)
14142 return srcs[i];
14143 }
14144 return 0;
14145}
14146
Kailang Yangdf694da2005-12-05 19:42:22 +010014147/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014148static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014149 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014150{
Takashi Iwai1c209302009-07-22 15:17:45 +020014151 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014152 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014153 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014154
14155 spec->multiout.dac_nids = spec->private_dac_nids;
14156 for (i = 0; i < cfg->line_outs; i++) {
14157 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014158 dac = alc861_look_for_dac(codec, nid);
14159 if (!dac)
14160 continue;
14161 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014162 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014163 return 0;
14164}
14165
Takashi Iwai1c209302009-07-22 15:17:45 +020014166static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14167 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014168{
14169 char name[32];
Takashi Iwai1c209302009-07-22 15:17:45 +020014170 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
14171 return add_control(codec->spec, ALC_CTL_WIDGET_MUTE, name,
14172 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14173}
14174
14175/* add playback controls from the parsed DAC table */
14176static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14177 const struct auto_pin_cfg *cfg)
14178{
14179 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014180 static const char *chname[4] = {
14181 "Front", "Surround", NULL /*CLFE*/, "Side"
14182 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014183 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014184 int i, err;
14185
14186 if (cfg->line_outs == 1) {
14187 const char *pfx = NULL;
14188 if (!cfg->hp_outs)
14189 pfx = "Master";
14190 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14191 pfx = "Speaker";
14192 if (pfx) {
14193 nid = spec->multiout.dac_nids[0];
14194 return alc861_create_out_sw(codec, pfx, nid, 3);
14195 }
14196 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014197
14198 for (i = 0; i < cfg->line_outs; i++) {
14199 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014200 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014201 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014202 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014203 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014204 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014205 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014206 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014207 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014208 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014209 return err;
14210 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014211 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014212 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014213 return err;
14214 }
14215 }
14216 return 0;
14217}
14218
Takashi Iwai1c209302009-07-22 15:17:45 +020014219static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014220{
Takashi Iwai1c209302009-07-22 15:17:45 +020014221 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014222 int err;
14223 hda_nid_t nid;
14224
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014225 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014226 return 0;
14227
14228 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014229 nid = alc861_look_for_dac(codec, pin);
14230 if (nid) {
14231 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14232 if (err < 0)
14233 return err;
14234 spec->multiout.hp_nid = nid;
14235 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014236 }
14237 return 0;
14238}
14239
14240/* create playback/capture controls for input pins */
Takashi Iwai1c209302009-07-22 15:17:45 +020014241static int alc861_auto_create_analog_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014242 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014243{
Takashi Iwai1c209302009-07-22 15:17:45 +020014244 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014245 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014246 int i, err, idx, idx1;
14247
14248 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014249 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014250 case 0x0c:
14251 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014252 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014253 break;
14254 case 0x0f:
14255 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014256 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014257 break;
14258 case 0x0d:
14259 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014260 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014261 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014262 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010014263 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014264 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010014265 break;
14266 case 0x11:
14267 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014268 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010014269 break;
14270 default:
14271 continue;
14272 }
14273
Takashi Iwai4a471b72005-12-07 13:56:29 +010014274 err = new_analog_input(spec, cfg->input_pins[i],
14275 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010014276 if (err < 0)
14277 return err;
14278
Takashi Iwai4a471b72005-12-07 13:56:29 +010014279 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010014280 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014281 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010014282 }
14283 return 0;
14284}
14285
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014286static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14287 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014288 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014289{
Takashi Iwai1c209302009-07-22 15:17:45 +020014290 hda_nid_t mix, srcs[5];
14291 int i, num;
14292
Jacek Luczak564c5be2008-05-03 18:41:23 +020014293 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14294 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014295 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014296 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014297 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14298 return;
14299 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14300 if (num < 0)
14301 return;
14302 for (i = 0; i < num; i++) {
14303 unsigned int mute;
14304 if (srcs[i] == dac || srcs[i] == 0x15)
14305 mute = AMP_IN_UNMUTE(i);
14306 else
14307 mute = AMP_IN_MUTE(i);
14308 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14309 mute);
14310 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014311}
14312
14313static void alc861_auto_init_multi_out(struct hda_codec *codec)
14314{
14315 struct alc_spec *spec = codec->spec;
14316 int i;
14317
14318 for (i = 0; i < spec->autocfg.line_outs; i++) {
14319 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014320 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014321 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014322 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014323 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014324 }
14325}
14326
14327static void alc861_auto_init_hp_out(struct hda_codec *codec)
14328{
14329 struct alc_spec *spec = codec->spec;
14330 hda_nid_t pin;
14331
Takashi Iwaieb06ed82006-09-20 17:10:27 +020014332 pin = spec->autocfg.hp_pins[0];
Takashi Iwai1c209302009-07-22 15:17:45 +020014333 if (pin)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014334 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014335 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014336 pin = spec->autocfg.speaker_pins[0];
14337 if (pin)
Takashi Iwai1c209302009-07-22 15:17:45 +020014338 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT,
14339 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014340}
14341
14342static void alc861_auto_init_analog_input(struct hda_codec *codec)
14343{
14344 struct alc_spec *spec = codec->spec;
14345 int i;
14346
14347 for (i = 0; i < AUTO_PIN_LAST; i++) {
14348 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014349 if (nid >= 0x0c && nid <= 0x11)
14350 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014351 }
14352}
14353
14354/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014355/* return 1 if successful, 0 if the proper config is not found,
14356 * or a negative error code
14357 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014358static int alc861_parse_auto_config(struct hda_codec *codec)
14359{
14360 struct alc_spec *spec = codec->spec;
14361 int err;
14362 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
14363
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014364 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14365 alc861_ignore);
14366 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014367 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014368 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014369 return 0; /* can't find valid BIOS pin config */
14370
Takashi Iwai1c209302009-07-22 15:17:45 +020014371 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014372 if (err < 0)
14373 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014374 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014375 if (err < 0)
14376 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014377 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014378 if (err < 0)
14379 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014380 err = alc861_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014381 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014382 return err;
14383
14384 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14385
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014386 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014387 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
14388
Takashi Iwai603c4012008-07-30 15:01:44 +020014389 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014390 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010014391
Takashi Iwaid88897e2008-10-31 15:01:37 +010014392 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010014393
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020014394 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014395 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010014396
14397 spec->adc_nids = alc861_adc_nids;
14398 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014399 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014400
Takashi Iwai4a79ba32009-04-22 16:31:35 +020014401 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b);
14402
Kailang Yangdf694da2005-12-05 19:42:22 +010014403 return 1;
14404}
14405
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014406/* additional initialization for auto-configuration model */
14407static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010014408{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014409 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014410 alc861_auto_init_multi_out(codec);
14411 alc861_auto_init_hp_out(codec);
14412 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014413 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014414 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010014415}
14416
Takashi Iwaicb53c622007-08-10 17:21:45 +020014417#ifdef CONFIG_SND_HDA_POWER_SAVE
14418static struct hda_amp_list alc861_loopbacks[] = {
14419 { 0x15, HDA_INPUT, 0 },
14420 { 0x15, HDA_INPUT, 1 },
14421 { 0x15, HDA_INPUT, 2 },
14422 { 0x15, HDA_INPUT, 3 },
14423 { } /* end */
14424};
14425#endif
14426
Kailang Yangdf694da2005-12-05 19:42:22 +010014427
14428/*
14429 * configuration and preset
14430 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014431static const char *alc861_models[ALC861_MODEL_LAST] = {
14432 [ALC861_3ST] = "3stack",
14433 [ALC660_3ST] = "3stack-660",
14434 [ALC861_3ST_DIG] = "3stack-dig",
14435 [ALC861_6ST_DIG] = "6stack-dig",
14436 [ALC861_UNIWILL_M31] = "uniwill-m31",
14437 [ALC861_TOSHIBA] = "toshiba",
14438 [ALC861_ASUS] = "asus",
14439 [ALC861_ASUS_LAPTOP] = "asus-laptop",
14440 [ALC861_AUTO] = "auto",
14441};
14442
14443static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010014444 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014445 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14446 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
14447 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014448 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020014449 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010014450 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020014451 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
14452 * Any other models that need this preset?
14453 */
14454 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020014455 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
14456 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014457 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
14458 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
14459 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
14460 /* FIXME: the below seems conflict */
14461 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
14462 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
14463 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010014464 {}
14465};
14466
14467static struct alc_config_preset alc861_presets[] = {
14468 [ALC861_3ST] = {
14469 .mixers = { alc861_3ST_mixer },
14470 .init_verbs = { alc861_threestack_init_verbs },
14471 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14472 .dac_nids = alc861_dac_nids,
14473 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14474 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014475 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014476 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14477 .adc_nids = alc861_adc_nids,
14478 .input_mux = &alc861_capture_source,
14479 },
14480 [ALC861_3ST_DIG] = {
14481 .mixers = { alc861_base_mixer },
14482 .init_verbs = { alc861_threestack_init_verbs },
14483 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14484 .dac_nids = alc861_dac_nids,
14485 .dig_out_nid = ALC861_DIGOUT_NID,
14486 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14487 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014488 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010014489 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14490 .adc_nids = alc861_adc_nids,
14491 .input_mux = &alc861_capture_source,
14492 },
14493 [ALC861_6ST_DIG] = {
14494 .mixers = { alc861_base_mixer },
14495 .init_verbs = { alc861_base_init_verbs },
14496 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14497 .dac_nids = alc861_dac_nids,
14498 .dig_out_nid = ALC861_DIGOUT_NID,
14499 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
14500 .channel_mode = alc861_8ch_modes,
14501 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14502 .adc_nids = alc861_adc_nids,
14503 .input_mux = &alc861_capture_source,
14504 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014505 [ALC660_3ST] = {
14506 .mixers = { alc861_3ST_mixer },
14507 .init_verbs = { alc861_threestack_init_verbs },
14508 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
14509 .dac_nids = alc660_dac_nids,
14510 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
14511 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020014512 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014513 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14514 .adc_nids = alc861_adc_nids,
14515 .input_mux = &alc861_capture_source,
14516 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014517 [ALC861_UNIWILL_M31] = {
14518 .mixers = { alc861_uniwill_m31_mixer },
14519 .init_verbs = { alc861_uniwill_m31_init_verbs },
14520 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14521 .dac_nids = alc861_dac_nids,
14522 .dig_out_nid = ALC861_DIGOUT_NID,
14523 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
14524 .channel_mode = alc861_uniwill_m31_modes,
14525 .need_dac_fix = 1,
14526 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14527 .adc_nids = alc861_adc_nids,
14528 .input_mux = &alc861_capture_source,
14529 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014530 [ALC861_TOSHIBA] = {
14531 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014532 .init_verbs = { alc861_base_init_verbs,
14533 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014534 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14535 .dac_nids = alc861_dac_nids,
14536 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14537 .channel_mode = alc883_3ST_2ch_modes,
14538 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14539 .adc_nids = alc861_adc_nids,
14540 .input_mux = &alc861_capture_source,
14541 .unsol_event = alc861_toshiba_unsol_event,
14542 .init_hook = alc861_toshiba_automute,
14543 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014544 [ALC861_ASUS] = {
14545 .mixers = { alc861_asus_mixer },
14546 .init_verbs = { alc861_asus_init_verbs },
14547 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14548 .dac_nids = alc861_dac_nids,
14549 .dig_out_nid = ALC861_DIGOUT_NID,
14550 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
14551 .channel_mode = alc861_asus_modes,
14552 .need_dac_fix = 1,
14553 .hp_nid = 0x06,
14554 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14555 .adc_nids = alc861_adc_nids,
14556 .input_mux = &alc861_capture_source,
14557 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014558 [ALC861_ASUS_LAPTOP] = {
14559 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
14560 .init_verbs = { alc861_asus_init_verbs,
14561 alc861_asus_laptop_init_verbs },
14562 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
14563 .dac_nids = alc861_dac_nids,
14564 .dig_out_nid = ALC861_DIGOUT_NID,
14565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
14566 .channel_mode = alc883_3ST_2ch_modes,
14567 .need_dac_fix = 1,
14568 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
14569 .adc_nids = alc861_adc_nids,
14570 .input_mux = &alc861_capture_source,
14571 },
14572};
Kailang Yangdf694da2005-12-05 19:42:22 +010014573
14574
14575static int patch_alc861(struct hda_codec *codec)
14576{
14577 struct alc_spec *spec;
14578 int board_config;
14579 int err;
14580
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014581 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014582 if (spec == NULL)
14583 return -ENOMEM;
14584
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014585 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014586
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014587 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14588 alc861_models,
14589 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014590
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014591 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014592 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14593 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010014594 board_config = ALC861_AUTO;
14595 }
14596
14597 if (board_config == ALC861_AUTO) {
14598 /* automatic parse from the BIOS config */
14599 err = alc861_parse_auto_config(codec);
14600 if (err < 0) {
14601 alc_free(codec);
14602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014603 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014604 printk(KERN_INFO
14605 "hda_codec: Cannot set up configuration "
14606 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014607 board_config = ALC861_3ST_DIG;
14608 }
14609 }
14610
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014611 err = snd_hda_attach_beep_device(codec, 0x23);
14612 if (err < 0) {
14613 alc_free(codec);
14614 return err;
14615 }
14616
Kailang Yangdf694da2005-12-05 19:42:22 +010014617 if (board_config != ALC861_AUTO)
14618 setup_preset(spec, &alc861_presets[board_config]);
14619
Kailang Yangdf694da2005-12-05 19:42:22 +010014620 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14621 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14622
Kailang Yangdf694da2005-12-05 19:42:22 +010014623 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14624 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14625
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014626 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14627
Takashi Iwai2134ea42008-01-10 16:53:55 +010014628 spec->vmaster_nid = 0x03;
14629
Kailang Yangdf694da2005-12-05 19:42:22 +010014630 codec->patch_ops = alc_patch_ops;
14631 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014632 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014633#ifdef CONFIG_SND_HDA_POWER_SAVE
14634 if (!spec->loopback.amplist)
14635 spec->loopback.amplist = alc861_loopbacks;
14636#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014637 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014638
Kailang Yangdf694da2005-12-05 19:42:22 +010014639 return 0;
14640}
14641
14642/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014643 * ALC861-VD support
14644 *
14645 * Based on ALC882
14646 *
14647 * In addition, an independent DAC
14648 */
14649#define ALC861VD_DIGOUT_NID 0x06
14650
14651static hda_nid_t alc861vd_dac_nids[4] = {
14652 /* front, surr, clfe, side surr */
14653 0x02, 0x03, 0x04, 0x05
14654};
14655
14656/* dac_nids for ALC660vd are in a different order - according to
14657 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014658 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014659 * of ALC660vd codecs, but for now there is only 3stack mixer
14660 * - and it is the same as in 861vd.
14661 * adc_nids in ALC660vd are (is) the same as in 861vd
14662 */
14663static hda_nid_t alc660vd_dac_nids[3] = {
14664 /* front, rear, clfe, rear_surr */
14665 0x02, 0x04, 0x03
14666};
14667
14668static hda_nid_t alc861vd_adc_nids[1] = {
14669 /* ADC0 */
14670 0x09,
14671};
14672
Takashi Iwaie1406342008-02-11 18:32:32 +010014673static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14674
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014675/* input MUX */
14676/* FIXME: should be a matrix-type input source selection */
14677static struct hda_input_mux alc861vd_capture_source = {
14678 .num_items = 4,
14679 .items = {
14680 { "Mic", 0x0 },
14681 { "Front Mic", 0x1 },
14682 { "Line", 0x2 },
14683 { "CD", 0x4 },
14684 },
14685};
14686
Kailang Yang272a5272007-05-14 11:00:38 +020014687static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014688 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014689 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014690 { "Ext Mic", 0x0 },
14691 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014692 },
14693};
14694
Kailang Yangd1a991a2007-08-15 16:21:59 +020014695static struct hda_input_mux alc861vd_hp_capture_source = {
14696 .num_items = 2,
14697 .items = {
14698 { "Front Mic", 0x0 },
14699 { "ATAPI Mic", 0x1 },
14700 },
14701};
14702
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014703/*
14704 * 2ch mode
14705 */
14706static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14707 { 2, NULL }
14708};
14709
14710/*
14711 * 6ch mode
14712 */
14713static struct hda_verb alc861vd_6stack_ch6_init[] = {
14714 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14715 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14716 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14717 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14718 { } /* end */
14719};
14720
14721/*
14722 * 8ch mode
14723 */
14724static struct hda_verb alc861vd_6stack_ch8_init[] = {
14725 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14726 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14727 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14728 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14729 { } /* end */
14730};
14731
14732static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14733 { 6, alc861vd_6stack_ch6_init },
14734 { 8, alc861vd_6stack_ch8_init },
14735};
14736
14737static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14738 {
14739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14740 .name = "Channel Mode",
14741 .info = alc_ch_mode_info,
14742 .get = alc_ch_mode_get,
14743 .put = alc_ch_mode_put,
14744 },
14745 { } /* end */
14746};
14747
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014748/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14749 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14750 */
14751static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14752 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14753 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14754
14755 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14756 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14757
14758 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14759 HDA_OUTPUT),
14760 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14761 HDA_OUTPUT),
14762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14764
14765 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14766 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14767
14768 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14769
14770 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14773
14774 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14777
14778 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14779 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14780
14781 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14782 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14783
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014784 { } /* end */
14785};
14786
14787static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14788 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14790
14791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14792
14793 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14794 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14795 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14796
14797 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14798 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14799 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14800
14801 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14802 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14803
14804 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14805 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14806
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014807 { } /* end */
14808};
14809
Kailang Yangbdd148a2007-05-08 15:19:08 +020014810static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14811 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14812 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14813 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14814
14815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14816
14817 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14818 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14820
14821 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14822 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14823 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14824
14825 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14826 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14827
14828 { } /* end */
14829};
14830
Tobin Davisb419f342008-03-07 11:57:51 +010014831/* Pin assignment: Speaker=0x14, HP = 0x15,
14832 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014833 */
14834static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014835 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14836 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014837 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14838 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014839 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14840 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14841 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14842 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14843 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14844 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014845 { } /* end */
14846};
14847
Kailang Yangd1a991a2007-08-15 16:21:59 +020014848/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14849 * Front Mic=0x18, ATAPI Mic = 0x19,
14850 */
14851static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14852 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14853 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14854 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14855 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14856 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14858 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14859 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014860
Kailang Yangd1a991a2007-08-15 16:21:59 +020014861 { } /* end */
14862};
14863
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014864/*
14865 * generic initialization of ADC, input mixers and output mixers
14866 */
14867static struct hda_verb alc861vd_volume_init_verbs[] = {
14868 /*
14869 * Unmute ADC0 and set the default input to mic-in
14870 */
14871 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14872 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14873
14874 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14875 * the analog-loopback mixer widget
14876 */
14877 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014878 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14879 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14880 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14881 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14882 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014883
14884 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014885 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014889
14890 /*
14891 * Set up output mixers (0x02 - 0x05)
14892 */
14893 /* set vol=0 to output mixers */
14894 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14895 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14896 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14898
14899 /* set up input amps for analog loopback */
14900 /* Amp Indices: DAC = 0, mixer = 1 */
14901 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14902 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14903 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14904 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14905 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14906 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14908 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14909
14910 { }
14911};
14912
14913/*
14914 * 3-stack pin configuration:
14915 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14916 */
14917static struct hda_verb alc861vd_3stack_init_verbs[] = {
14918 /*
14919 * Set pin mode and muting
14920 */
14921 /* set front pin widgets 0x14 for output */
14922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14924 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14925
14926 /* Mic (rear) pin: input vref at 80% */
14927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14929 /* Front Mic pin: input vref at 80% */
14930 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14931 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14932 /* Line In pin: input */
14933 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14934 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14935 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14936 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14937 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14938 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14939 /* CD pin widget for input */
14940 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14941
14942 { }
14943};
14944
14945/*
14946 * 6-stack pin configuration:
14947 */
14948static struct hda_verb alc861vd_6stack_init_verbs[] = {
14949 /*
14950 * Set pin mode and muting
14951 */
14952 /* set front pin widgets 0x14 for output */
14953 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14954 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14955 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14956
14957 /* Rear Pin: output 1 (0x0d) */
14958 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14960 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14961 /* CLFE Pin: output 2 (0x0e) */
14962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14964 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14965 /* Side Pin: output 3 (0x0f) */
14966 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14967 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14968 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14969
14970 /* Mic (rear) pin: input vref at 80% */
14971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14972 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14973 /* Front Mic pin: input vref at 80% */
14974 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14975 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14976 /* Line In pin: input */
14977 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14979 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14980 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14981 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14982 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14983 /* CD pin widget for input */
14984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14985
14986 { }
14987};
14988
Kailang Yangbdd148a2007-05-08 15:19:08 +020014989static struct hda_verb alc861vd_eapd_verbs[] = {
14990 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14991 { }
14992};
14993
Kailang Yangf9423e72008-05-27 12:32:25 +020014994static struct hda_verb alc660vd_eapd_verbs[] = {
14995 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14996 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14997 { }
14998};
14999
Kailang Yangbdd148a2007-05-08 15:19:08 +020015000static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15001 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15002 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15004 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015005 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015006 {}
15007};
15008
Kailang Yangbdd148a2007-05-08 15:19:08 +020015009static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15010{
15011 unsigned int present;
15012 unsigned char bits;
15013
15014 present = snd_hda_codec_read(codec, 0x18, 0,
15015 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015016 bits = present ? HDA_AMP_MUTE : 0;
15017 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15018 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015019}
15020
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015021static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015022{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015023 struct alc_spec *spec = codec->spec;
15024
15025 spec->autocfg.hp_pins[0] = 0x1b;
15026 spec->autocfg.speaker_pins[0] = 0x14;
15027 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015028 alc861vd_lenovo_mic_automute(codec);
15029}
15030
15031static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15032 unsigned int res)
15033{
15034 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015035 case ALC880_MIC_EVENT:
15036 alc861vd_lenovo_mic_automute(codec);
15037 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015038 default:
15039 alc_automute_amp_unsol_event(codec, res);
15040 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015041 }
15042}
15043
Kailang Yang272a5272007-05-14 11:00:38 +020015044static struct hda_verb alc861vd_dallas_verbs[] = {
15045 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15046 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15047 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15048 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15049
15050 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15051 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15053 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15056 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015058
Kailang Yang272a5272007-05-14 11:00:38 +020015059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15061 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15062 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15063 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15064 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15065 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15066 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15067
15068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15074 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15075 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15076
15077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15081
15082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015083 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015084 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15085
15086 { } /* end */
15087};
15088
15089/* toggle speaker-output according to the hp-jack state */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015090static void alc861vd_dallas_init_hook(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015091{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015092 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015093
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015094 spec->autocfg.hp_pins[0] = 0x15;
15095 spec->autocfg.speaker_pins[0] = 0x14;
15096 alc_automute_amp(codec);
Kailang Yang272a5272007-05-14 11:00:38 +020015097}
15098
Takashi Iwaicb53c622007-08-10 17:21:45 +020015099#ifdef CONFIG_SND_HDA_POWER_SAVE
15100#define alc861vd_loopbacks alc880_loopbacks
15101#endif
15102
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015103/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015104#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15105#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15106#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15107#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15108
15109/*
15110 * configuration and preset
15111 */
15112static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15113 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015114 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015115 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015116 [ALC861VD_3ST] = "3stack",
15117 [ALC861VD_3ST_DIG] = "3stack-digout",
15118 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015119 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015120 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015121 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015122 [ALC861VD_AUTO] = "auto",
15123};
15124
15125static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015126 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15127 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015128 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015129 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010015130 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015131 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015132 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015133 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015134 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015135 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015136 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015137 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015138 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015139 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015140 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015141 {}
15142};
15143
15144static struct alc_config_preset alc861vd_presets[] = {
15145 [ALC660VD_3ST] = {
15146 .mixers = { alc861vd_3st_mixer },
15147 .init_verbs = { alc861vd_volume_init_verbs,
15148 alc861vd_3stack_init_verbs },
15149 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15150 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015151 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15152 .channel_mode = alc861vd_3stack_2ch_modes,
15153 .input_mux = &alc861vd_capture_source,
15154 },
Mike Crash6963f842007-06-25 12:12:51 +020015155 [ALC660VD_3ST_DIG] = {
15156 .mixers = { alc861vd_3st_mixer },
15157 .init_verbs = { alc861vd_volume_init_verbs,
15158 alc861vd_3stack_init_verbs },
15159 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15160 .dac_nids = alc660vd_dac_nids,
15161 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015162 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15163 .channel_mode = alc861vd_3stack_2ch_modes,
15164 .input_mux = &alc861vd_capture_source,
15165 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015166 [ALC861VD_3ST] = {
15167 .mixers = { alc861vd_3st_mixer },
15168 .init_verbs = { alc861vd_volume_init_verbs,
15169 alc861vd_3stack_init_verbs },
15170 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15171 .dac_nids = alc861vd_dac_nids,
15172 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15173 .channel_mode = alc861vd_3stack_2ch_modes,
15174 .input_mux = &alc861vd_capture_source,
15175 },
15176 [ALC861VD_3ST_DIG] = {
15177 .mixers = { alc861vd_3st_mixer },
15178 .init_verbs = { alc861vd_volume_init_verbs,
15179 alc861vd_3stack_init_verbs },
15180 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15181 .dac_nids = alc861vd_dac_nids,
15182 .dig_out_nid = ALC861VD_DIGOUT_NID,
15183 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15184 .channel_mode = alc861vd_3stack_2ch_modes,
15185 .input_mux = &alc861vd_capture_source,
15186 },
15187 [ALC861VD_6ST_DIG] = {
15188 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15189 .init_verbs = { alc861vd_volume_init_verbs,
15190 alc861vd_6stack_init_verbs },
15191 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15192 .dac_nids = alc861vd_dac_nids,
15193 .dig_out_nid = ALC861VD_DIGOUT_NID,
15194 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15195 .channel_mode = alc861vd_6stack_modes,
15196 .input_mux = &alc861vd_capture_source,
15197 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015198 [ALC861VD_LENOVO] = {
15199 .mixers = { alc861vd_lenovo_mixer },
15200 .init_verbs = { alc861vd_volume_init_verbs,
15201 alc861vd_3stack_init_verbs,
15202 alc861vd_eapd_verbs,
15203 alc861vd_lenovo_unsol_verbs },
15204 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15205 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015206 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15207 .channel_mode = alc861vd_3stack_2ch_modes,
15208 .input_mux = &alc861vd_capture_source,
15209 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015210 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015211 },
Kailang Yang272a5272007-05-14 11:00:38 +020015212 [ALC861VD_DALLAS] = {
15213 .mixers = { alc861vd_dallas_mixer },
15214 .init_verbs = { alc861vd_dallas_verbs },
15215 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15216 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015217 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15218 .channel_mode = alc861vd_3stack_2ch_modes,
15219 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015220 .unsol_event = alc_automute_amp_unsol_event,
15221 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015222 },
15223 [ALC861VD_HP] = {
15224 .mixers = { alc861vd_hp_mixer },
15225 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15226 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15227 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015228 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015229 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15230 .channel_mode = alc861vd_3stack_2ch_modes,
15231 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015232 .unsol_event = alc_automute_amp_unsol_event,
15233 .init_hook = alc861vd_dallas_init_hook,
Kailang Yangea1fb292008-08-26 12:58:38 +020015234 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015235 [ALC660VD_ASUS_V1S] = {
15236 .mixers = { alc861vd_lenovo_mixer },
15237 .init_verbs = { alc861vd_volume_init_verbs,
15238 alc861vd_3stack_init_verbs,
15239 alc861vd_eapd_verbs,
15240 alc861vd_lenovo_unsol_verbs },
15241 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15242 .dac_nids = alc660vd_dac_nids,
15243 .dig_out_nid = ALC861VD_DIGOUT_NID,
15244 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15245 .channel_mode = alc861vd_3stack_2ch_modes,
15246 .input_mux = &alc861vd_capture_source,
15247 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015248 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015249 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015250};
15251
15252/*
15253 * BIOS auto configuration
15254 */
15255static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15256 hda_nid_t nid, int pin_type, int dac_idx)
15257{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015258 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015259}
15260
15261static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15262{
15263 struct alc_spec *spec = codec->spec;
15264 int i;
15265
15266 for (i = 0; i <= HDA_SIDE; i++) {
15267 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015268 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015269 if (nid)
15270 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015271 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015272 }
15273}
15274
15275
15276static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15277{
15278 struct alc_spec *spec = codec->spec;
15279 hda_nid_t pin;
15280
15281 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015282 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015283 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015284 pin = spec->autocfg.speaker_pins[0];
15285 if (pin)
15286 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015287}
15288
15289#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
15290#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15291
15292static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15293{
15294 struct alc_spec *spec = codec->spec;
15295 int i;
15296
15297 for (i = 0; i < AUTO_PIN_LAST; i++) {
15298 hda_nid_t nid = spec->autocfg.input_pins[i];
15299 if (alc861vd_is_input_pin(nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015300 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015301 if (nid != ALC861VD_PIN_CD_NID &&
15302 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015303 snd_hda_codec_write(codec, nid, 0,
15304 AC_VERB_SET_AMP_GAIN_MUTE,
15305 AMP_OUT_MUTE);
15306 }
15307 }
15308}
15309
Takashi Iwaif511b012008-08-15 16:46:42 +020015310#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15311
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015312#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15313#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15314
15315/* add playback controls from the parsed DAC table */
15316/* Based on ALC880 version. But ALC861VD has separate,
15317 * different NIDs for mute/unmute switch and volume control */
15318static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15319 const struct auto_pin_cfg *cfg)
15320{
15321 char name[32];
15322 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
15323 hda_nid_t nid_v, nid_s;
15324 int i, err;
15325
15326 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015327 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015328 continue;
15329 nid_v = alc861vd_idx_to_mixer_vol(
15330 alc880_dac_to_idx(
15331 spec->multiout.dac_nids[i]));
15332 nid_s = alc861vd_idx_to_mixer_switch(
15333 alc880_dac_to_idx(
15334 spec->multiout.dac_nids[i]));
15335
15336 if (i == 2) {
15337 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015338 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15339 "Center Playback Volume",
15340 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
15341 HDA_OUTPUT));
15342 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015343 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015344 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15345 "LFE Playback Volume",
15346 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
15347 HDA_OUTPUT));
15348 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015349 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015350 err = add_control(spec, ALC_CTL_BIND_MUTE,
15351 "Center Playback Switch",
15352 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
15353 HDA_INPUT));
15354 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015355 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015356 err = add_control(spec, ALC_CTL_BIND_MUTE,
15357 "LFE Playback Switch",
15358 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
15359 HDA_INPUT));
15360 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015361 return err;
15362 } else {
15363 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015364 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15365 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
15366 HDA_OUTPUT));
15367 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015368 return err;
15369 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015370 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015371 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015372 HDA_INPUT));
15373 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015374 return err;
15375 }
15376 }
15377 return 0;
15378}
15379
15380/* add playback controls for speaker and HP outputs */
15381/* Based on ALC880 version. But ALC861VD has separate,
15382 * different NIDs for mute/unmute switch and volume control */
15383static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
15384 hda_nid_t pin, const char *pfx)
15385{
15386 hda_nid_t nid_v, nid_s;
15387 int err;
15388 char name[32];
15389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015390 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015391 return 0;
15392
15393 if (alc880_is_fixed_pin(pin)) {
15394 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15395 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015396 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015397 spec->multiout.hp_nid = nid_v;
15398 else
15399 spec->multiout.extra_out_nid[0] = nid_v;
15400 /* control HP volume/switch on the output mixer amp */
15401 nid_v = alc861vd_idx_to_mixer_vol(
15402 alc880_fixed_pin_idx(pin));
15403 nid_s = alc861vd_idx_to_mixer_switch(
15404 alc880_fixed_pin_idx(pin));
15405
15406 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015407 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15408 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
15409 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015410 return err;
15411 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015412 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15413 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
15414 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415 return err;
15416 } else if (alc880_is_multi_pin(pin)) {
15417 /* set manual connection */
15418 /* we have only a switch on HP-out PIN */
15419 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015420 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15421 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15422 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015423 return err;
15424 }
15425 return 0;
15426}
15427
15428/* parse the BIOS configuration and set up the alc_spec
15429 * return 1 if successful, 0 if the proper config is not found,
15430 * or a negative error code
15431 * Based on ALC880 version - had to change it to override
15432 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
15433static int alc861vd_parse_auto_config(struct hda_codec *codec)
15434{
15435 struct alc_spec *spec = codec->spec;
15436 int err;
15437 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
15438
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015439 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15440 alc861vd_ignore);
15441 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015442 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015443 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015444 return 0; /* can't find valid BIOS pin config */
15445
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015446 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15447 if (err < 0)
15448 return err;
15449 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
15450 if (err < 0)
15451 return err;
15452 err = alc861vd_auto_create_extra_out(spec,
15453 spec->autocfg.speaker_pins[0],
15454 "Speaker");
15455 if (err < 0)
15456 return err;
15457 err = alc861vd_auto_create_extra_out(spec,
15458 spec->autocfg.hp_pins[0],
15459 "Headphone");
15460 if (err < 0)
15461 return err;
15462 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
15463 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015464 return err;
15465
15466 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15467
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015468 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015469 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
15470
Takashi Iwai603c4012008-07-30 15:01:44 +020015471 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015472 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015473
Takashi Iwaid88897e2008-10-31 15:01:37 +010015474 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015475
15476 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015477 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015478
Takashi Iwai776e1842007-08-29 15:07:11 +020015479 err = alc_auto_add_mic_boost(codec);
15480 if (err < 0)
15481 return err;
15482
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015483 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
15484
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015485 return 1;
15486}
15487
15488/* additional initialization for auto-configuration model */
15489static void alc861vd_auto_init(struct hda_codec *codec)
15490{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015491 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015492 alc861vd_auto_init_multi_out(codec);
15493 alc861vd_auto_init_hp_out(codec);
15494 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015495 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015496 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015497 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015498}
15499
15500static int patch_alc861vd(struct hda_codec *codec)
15501{
15502 struct alc_spec *spec;
15503 int err, board_config;
15504
15505 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15506 if (spec == NULL)
15507 return -ENOMEM;
15508
15509 codec->spec = spec;
15510
15511 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
15512 alc861vd_models,
15513 alc861vd_cfg_tbl);
15514
15515 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015516 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15517 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015518 board_config = ALC861VD_AUTO;
15519 }
15520
15521 if (board_config == ALC861VD_AUTO) {
15522 /* automatic parse from the BIOS config */
15523 err = alc861vd_parse_auto_config(codec);
15524 if (err < 0) {
15525 alc_free(codec);
15526 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015527 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015528 printk(KERN_INFO
15529 "hda_codec: Cannot set up configuration "
15530 "from BIOS. Using base mode...\n");
15531 board_config = ALC861VD_3ST;
15532 }
15533 }
15534
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015535 err = snd_hda_attach_beep_device(codec, 0x23);
15536 if (err < 0) {
15537 alc_free(codec);
15538 return err;
15539 }
15540
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015541 if (board_config != ALC861VD_AUTO)
15542 setup_preset(spec, &alc861vd_presets[board_config]);
15543
Kailang Yang2f893282008-05-27 12:14:47 +020015544 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020015545 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010015546 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020015547 }
15548
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015549 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15550 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15551
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015552 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15553 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15554
15555 spec->adc_nids = alc861vd_adc_nids;
15556 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015557 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015558
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015559 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015560 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015561
Takashi Iwai2134ea42008-01-10 16:53:55 +010015562 spec->vmaster_nid = 0x02;
15563
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015564 codec->patch_ops = alc_patch_ops;
15565
15566 if (board_config == ALC861VD_AUTO)
15567 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015568#ifdef CONFIG_SND_HDA_POWER_SAVE
15569 if (!spec->loopback.amplist)
15570 spec->loopback.amplist = alc861vd_loopbacks;
15571#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015572 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015573
15574 return 0;
15575}
15576
15577/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015578 * ALC662 support
15579 *
15580 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15581 * configuration. Each pin widget can choose any input DACs and a mixer.
15582 * Each ADC is connected from a mixer of all inputs. This makes possible
15583 * 6-channel independent captures.
15584 *
15585 * In addition, an independent DAC for the multi-playback (not used in this
15586 * driver yet).
15587 */
15588#define ALC662_DIGOUT_NID 0x06
15589#define ALC662_DIGIN_NID 0x0a
15590
15591static hda_nid_t alc662_dac_nids[4] = {
15592 /* front, rear, clfe, rear_surr */
15593 0x02, 0x03, 0x04
15594};
15595
Kailang Yang622e84c2009-04-21 07:39:04 +020015596static hda_nid_t alc272_dac_nids[2] = {
15597 0x02, 0x03
15598};
15599
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015600static hda_nid_t alc662_adc_nids[1] = {
15601 /* ADC1-2 */
15602 0x09,
15603};
Takashi Iwaie1406342008-02-11 18:32:32 +010015604
Kailang Yang622e84c2009-04-21 07:39:04 +020015605static hda_nid_t alc272_adc_nids[1] = {
15606 /* ADC1-2 */
15607 0x08,
15608};
15609
Kailang Yang77a261b2008-02-19 11:38:05 +010015610static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Kailang Yang622e84c2009-04-21 07:39:04 +020015611static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
15612
Takashi Iwaie1406342008-02-11 18:32:32 +010015613
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015614/* input MUX */
15615/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015616static struct hda_input_mux alc662_capture_source = {
15617 .num_items = 4,
15618 .items = {
15619 { "Mic", 0x0 },
15620 { "Front Mic", 0x1 },
15621 { "Line", 0x2 },
15622 { "CD", 0x4 },
15623 },
15624};
15625
15626static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15627 .num_items = 2,
15628 .items = {
15629 { "Mic", 0x1 },
15630 { "Line", 0x2 },
15631 },
15632};
Kailang Yang291702f2007-10-16 14:28:03 +020015633
15634static struct hda_input_mux alc662_eeepc_capture_source = {
15635 .num_items = 2,
15636 .items = {
15637 { "i-Mic", 0x1 },
15638 { "e-Mic", 0x0 },
15639 },
15640};
15641
Kailang Yang6dda9f42008-05-27 12:05:31 +020015642static struct hda_input_mux alc663_capture_source = {
15643 .num_items = 3,
15644 .items = {
15645 { "Mic", 0x0 },
15646 { "Front Mic", 0x1 },
15647 { "Line", 0x2 },
15648 },
15649};
15650
15651static struct hda_input_mux alc663_m51va_capture_source = {
15652 .num_items = 2,
15653 .items = {
15654 { "Ext-Mic", 0x0 },
15655 { "D-Mic", 0x9 },
15656 },
15657};
15658
Chris Pockelé9541ba12009-05-12 08:08:53 +020015659#if 1 /* set to 0 for testing other input sources below */
15660static struct hda_input_mux alc272_nc10_capture_source = {
15661 .num_items = 2,
15662 .items = {
15663 { "Autoselect Mic", 0x0 },
15664 { "Internal Mic", 0x1 },
15665 },
15666};
15667#else
15668static struct hda_input_mux alc272_nc10_capture_source = {
15669 .num_items = 16,
15670 .items = {
15671 { "Autoselect Mic", 0x0 },
15672 { "Internal Mic", 0x1 },
15673 { "In-0x02", 0x2 },
15674 { "In-0x03", 0x3 },
15675 { "In-0x04", 0x4 },
15676 { "In-0x05", 0x5 },
15677 { "In-0x06", 0x6 },
15678 { "In-0x07", 0x7 },
15679 { "In-0x08", 0x8 },
15680 { "In-0x09", 0x9 },
15681 { "In-0x0a", 0x0a },
15682 { "In-0x0b", 0x0b },
15683 { "In-0x0c", 0x0c },
15684 { "In-0x0d", 0x0d },
15685 { "In-0x0e", 0x0e },
15686 { "In-0x0f", 0x0f },
15687 },
15688};
15689#endif
15690
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015691/*
15692 * 2ch mode
15693 */
15694static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15695 { 2, NULL }
15696};
15697
15698/*
15699 * 2ch mode
15700 */
15701static struct hda_verb alc662_3ST_ch2_init[] = {
15702 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15703 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15704 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15705 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15706 { } /* end */
15707};
15708
15709/*
15710 * 6ch mode
15711 */
15712static struct hda_verb alc662_3ST_ch6_init[] = {
15713 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15714 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15715 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15716 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15717 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15718 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15719 { } /* end */
15720};
15721
15722static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15723 { 2, alc662_3ST_ch2_init },
15724 { 6, alc662_3ST_ch6_init },
15725};
15726
15727/*
15728 * 2ch mode
15729 */
15730static struct hda_verb alc662_sixstack_ch6_init[] = {
15731 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15732 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15733 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15734 { } /* end */
15735};
15736
15737/*
15738 * 6ch mode
15739 */
15740static struct hda_verb alc662_sixstack_ch8_init[] = {
15741 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15742 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15743 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15744 { } /* end */
15745};
15746
15747static struct hda_channel_mode alc662_5stack_modes[2] = {
15748 { 2, alc662_sixstack_ch6_init },
15749 { 6, alc662_sixstack_ch8_init },
15750};
15751
15752/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15753 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15754 */
15755
15756static struct snd_kcontrol_new alc662_base_mixer[] = {
15757 /* output mixer control */
15758 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015759 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015760 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015761 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015762 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15763 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015764 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15765 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15767
15768 /*Input mixer control */
15769 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15770 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15771 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15772 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15773 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15774 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15775 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015777 { } /* end */
15778};
15779
15780static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15781 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015782 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015783 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15786 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15787 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15788 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15789 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15790 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15791 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015792 { } /* end */
15793};
15794
15795static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15796 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015797 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015798 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015799 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015800 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15801 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015802 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15803 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015804 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15805 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15806 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15807 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15808 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15811 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15812 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015813 { } /* end */
15814};
15815
15816static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15817 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15818 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015819 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15820 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015826 { } /* end */
15827};
15828
Kailang Yang291702f2007-10-16 14:28:03 +020015829static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015830 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15831 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020015832
15833 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15834 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15835 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15836
15837 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15838 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15839 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15840 { } /* end */
15841};
15842
Kailang Yang8c427222008-01-10 13:03:59 +010015843static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020015844 ALC262_HIPPO_MASTER_SWITCH,
15845 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015846 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015847 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15848 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015849 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15854 { } /* end */
15855};
15856
Kailang Yangf1d4e282008-08-26 14:03:29 +020015857static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15858 .ops = &snd_hda_bind_vol,
15859 .values = {
15860 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15861 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15862 0
15863 },
15864};
15865
15866static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15867 .ops = &snd_hda_bind_sw,
15868 .values = {
15869 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15870 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15871 0
15872 },
15873};
15874
Kailang Yang6dda9f42008-05-27 12:05:31 +020015875static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015876 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15877 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15879 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15880 { } /* end */
15881};
15882
15883static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15884 .ops = &snd_hda_bind_sw,
15885 .values = {
15886 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15887 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15888 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15889 0
15890 },
15891};
15892
15893static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15894 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15895 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15896 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15897 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15898 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15899 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15900
15901 { } /* end */
15902};
15903
15904static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15905 .ops = &snd_hda_bind_sw,
15906 .values = {
15907 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15908 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15909 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15910 0
15911 },
15912};
15913
15914static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15915 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15916 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15917 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15918 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15919 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15920 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15921 { } /* end */
15922};
15923
15924static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015925 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15926 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015927 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15928 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15929 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15930 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15931 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15932 { } /* end */
15933};
15934
15935static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15936 .ops = &snd_hda_bind_vol,
15937 .values = {
15938 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15939 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15940 0
15941 },
15942};
15943
15944static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15945 .ops = &snd_hda_bind_sw,
15946 .values = {
15947 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15948 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15949 0
15950 },
15951};
15952
15953static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15954 HDA_BIND_VOL("Master Playback Volume",
15955 &alc663_asus_two_bind_master_vol),
15956 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015961 { } /* end */
15962};
15963
15964static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15965 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15966 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15969 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015971 { } /* end */
15972};
15973
15974static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15975 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15976 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15977 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15978 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15979 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15980
15981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15983 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15984 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15985 { } /* end */
15986};
15987
15988static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15989 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15990 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15992
15993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15995 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15996 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15997 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15998 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15999 { } /* end */
16000};
16001
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016002static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16003 {
16004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16005 .name = "Channel Mode",
16006 .info = alc_ch_mode_info,
16007 .get = alc_ch_mode_get,
16008 .put = alc_ch_mode_put,
16009 },
16010 { } /* end */
16011};
16012
16013static struct hda_verb alc662_init_verbs[] = {
16014 /* ADC: mute amp left and right */
16015 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16016 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16017 /* Front mixer: unmute input/output amp left and right (volume = 0) */
16018
Takashi Iwaicb53c622007-08-10 17:21:45 +020016019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016024
Kailang Yangb60dd392007-09-20 12:50:29 +020016025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16029 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016031
16032 /* Front Pin: output 0 (0x0c) */
16033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16034 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16035
16036 /* Rear Pin: output 1 (0x0d) */
16037 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16039
16040 /* CLFE Pin: output 2 (0x0e) */
16041 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16042 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16043
16044 /* Mic (rear) pin: input vref at 80% */
16045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16046 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16047 /* Front Mic pin: input vref at 80% */
16048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16049 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16050 /* Line In pin: input */
16051 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16052 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16053 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16054 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16055 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16056 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16057 /* CD pin widget for input */
16058 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16059
16060 /* FIXME: use matrix-type input source selection */
16061 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16062 /* Input mixer */
16063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016065
16066 /* always trun on EAPD */
16067 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16068 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16069
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016070 { }
16071};
16072
16073static struct hda_verb alc662_sue_init_verbs[] = {
16074 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16075 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016076 {}
16077};
16078
16079static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16080 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16081 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16082 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016083};
16084
Kailang Yang8c427222008-01-10 13:03:59 +010016085/* Set Unsolicited Event*/
16086static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16088 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16089 {}
16090};
16091
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016092/*
16093 * generic initialization of ADC, input mixers and output mixers
16094 */
16095static struct hda_verb alc662_auto_init_verbs[] = {
16096 /*
16097 * Unmute ADC and set the default input to mic-in
16098 */
16099 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16101
16102 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
16103 * mixer widget
16104 * Note: PASD motherboards uses the Line In 2 as the input for front
16105 * panel mic (mic 2)
16106 */
16107 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016113
16114 /*
16115 * Set up output mixers (0x0c - 0x0f)
16116 */
16117 /* set vol=0 to output mixers */
16118 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16119 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16120 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16121
16122 /* set up input amps for analog loopback */
16123 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020016124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16127 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016130
16131
16132 /* FIXME: use matrix-type input source selection */
16133 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16134 /* Input mixer */
16135 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020016136 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016137 { }
16138};
16139
Takashi Iwai24fb9172008-09-02 14:48:20 +020016140/* additional verbs for ALC663 */
16141static struct hda_verb alc663_auto_init_verbs[] = {
16142 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16143 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16144 { }
16145};
16146
Kailang Yang6dda9f42008-05-27 12:05:31 +020016147static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016148 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16149 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016150 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16151 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016152 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16156 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16157 {}
16158};
16159
Kailang Yangf1d4e282008-08-26 14:03:29 +020016160static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16161 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16162 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16163 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16166 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16167 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16168 {}
16169};
16170
16171static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16172 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16173 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16174 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16175 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16179 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16180 {}
16181};
16182
16183static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16189 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16190 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16191 {}
16192};
16193
16194static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16196 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16197 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16198 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16199 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16201 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16202 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16204 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16205 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16206 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16207 {}
16208};
16209
16210static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16211 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16212 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16213 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16214 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16217 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16220 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16221 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16222 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16223 {}
16224};
16225
Kailang Yang6dda9f42008-05-27 12:05:31 +020016226static struct hda_verb alc663_g71v_init_verbs[] = {
16227 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16228 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16229 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16230
16231 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16232 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16233 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16234
16235 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16237 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16238 {}
16239};
16240
16241static struct hda_verb alc663_g50v_init_verbs[] = {
16242 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16243 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16244 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16245
16246 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16247 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16248 {}
16249};
16250
Kailang Yangf1d4e282008-08-26 14:03:29 +020016251static struct hda_verb alc662_ecs_init_verbs[] = {
16252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16253 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16254 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16255 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16256 {}
16257};
16258
Kailang Yang622e84c2009-04-21 07:39:04 +020016259static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16260 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16261 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16262 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16263 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16264 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16265 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16266 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16268 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16269 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16270 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16271 {}
16272};
16273
16274static struct hda_verb alc272_dell_init_verbs[] = {
16275 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16276 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16277 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16278 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16279 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16280 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16281 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16284 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16285 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16286 {}
16287};
16288
Kailang Yangf1d4e282008-08-26 14:03:29 +020016289static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
16290 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
16291 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
16292 { } /* end */
16293};
16294
Kailang Yang622e84c2009-04-21 07:39:04 +020016295static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
16296 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
16297 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
16298 { } /* end */
16299};
16300
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016301static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
16302{
16303 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016304 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016305
16306 present = snd_hda_codec_read(codec, 0x14, 0,
16307 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016308 bits = present ? HDA_AMP_MUTE : 0;
16309 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16310 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016311}
16312
16313static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
16314{
16315 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016316 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016317
16318 present = snd_hda_codec_read(codec, 0x1b, 0,
16319 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020016320 bits = present ? HDA_AMP_MUTE : 0;
16321 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16322 HDA_AMP_MUTE, bits);
16323 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16324 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325}
16326
16327static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
16328 unsigned int res)
16329{
16330 if ((res >> 26) == ALC880_HP_EVENT)
16331 alc662_lenovo_101e_all_automute(codec);
16332 if ((res >> 26) == ALC880_FRONT_EVENT)
16333 alc662_lenovo_101e_ispeaker_automute(codec);
16334}
16335
Kailang Yang291702f2007-10-16 14:28:03 +020016336static void alc662_eeepc_mic_automute(struct hda_codec *codec)
16337{
16338 unsigned int present;
16339
16340 present = snd_hda_codec_read(codec, 0x18, 0,
16341 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
16342 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16343 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16344 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16345 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
16346 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16347 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16348 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16349 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
16350}
16351
16352/* unsolicited event for HP jack sensing */
16353static void alc662_eeepc_unsol_event(struct hda_codec *codec,
16354 unsigned int res)
16355{
Kailang Yang291702f2007-10-16 14:28:03 +020016356 if ((res >> 26) == ALC880_MIC_EVENT)
16357 alc662_eeepc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020016358 else
16359 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020016360}
16361
16362static void alc662_eeepc_inithook(struct hda_codec *codec)
16363{
Takashi Iwai42171c12009-05-08 14:11:43 +020016364 alc262_hippo1_init_hook(codec);
Kailang Yang291702f2007-10-16 14:28:03 +020016365 alc662_eeepc_mic_automute(codec);
16366}
16367
Kailang Yang8c427222008-01-10 13:03:59 +010016368static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
16369{
Takashi Iwai42171c12009-05-08 14:11:43 +020016370 struct alc_spec *spec = codec->spec;
16371
16372 spec->autocfg.hp_pins[0] = 0x14;
16373 spec->autocfg.speaker_pins[0] = 0x1b;
16374 alc262_hippo_master_update(codec);
Kailang Yang8c427222008-01-10 13:03:59 +010016375}
16376
Kailang Yang6dda9f42008-05-27 12:05:31 +020016377static void alc663_m51va_speaker_automute(struct hda_codec *codec)
16378{
16379 unsigned int present;
16380 unsigned char bits;
16381
16382 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016383 AC_VERB_GET_PIN_SENSE, 0)
16384 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016385 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020016386 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16387 AMP_IN_MUTE(0), bits);
16388 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16389 AMP_IN_MUTE(0), bits);
16390}
16391
16392static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
16393{
16394 unsigned int present;
16395 unsigned char bits;
16396
16397 present = snd_hda_codec_read(codec, 0x21, 0,
16398 AC_VERB_GET_PIN_SENSE, 0)
16399 & AC_PINSENSE_PRESENCE;
16400 bits = present ? HDA_AMP_MUTE : 0;
16401 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16402 AMP_IN_MUTE(0), bits);
16403 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16404 AMP_IN_MUTE(0), bits);
16405 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16406 AMP_IN_MUTE(0), bits);
16407 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16408 AMP_IN_MUTE(0), bits);
16409}
16410
16411static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
16412{
16413 unsigned int present;
16414 unsigned char bits;
16415
16416 present = snd_hda_codec_read(codec, 0x15, 0,
16417 AC_VERB_GET_PIN_SENSE, 0)
16418 & AC_PINSENSE_PRESENCE;
16419 bits = present ? HDA_AMP_MUTE : 0;
16420 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16421 AMP_IN_MUTE(0), bits);
16422 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16423 AMP_IN_MUTE(0), bits);
16424 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
16425 AMP_IN_MUTE(0), bits);
16426 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
16427 AMP_IN_MUTE(0), bits);
16428}
16429
16430static void alc662_f5z_speaker_automute(struct hda_codec *codec)
16431{
16432 unsigned int present;
16433 unsigned char bits;
16434
16435 present = snd_hda_codec_read(codec, 0x1b, 0,
16436 AC_VERB_GET_PIN_SENSE, 0)
16437 & AC_PINSENSE_PRESENCE;
16438 bits = present ? 0 : PIN_OUT;
16439 snd_hda_codec_write(codec, 0x14, 0,
16440 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
16441}
16442
16443static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
16444{
16445 unsigned int present1, present2;
16446
16447 present1 = snd_hda_codec_read(codec, 0x21, 0,
16448 AC_VERB_GET_PIN_SENSE, 0)
16449 & AC_PINSENSE_PRESENCE;
16450 present2 = snd_hda_codec_read(codec, 0x15, 0,
16451 AC_VERB_GET_PIN_SENSE, 0)
16452 & AC_PINSENSE_PRESENCE;
16453
16454 if (present1 || present2) {
16455 snd_hda_codec_write_cache(codec, 0x14, 0,
16456 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
16457 } else {
16458 snd_hda_codec_write_cache(codec, 0x14, 0,
16459 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
16460 }
16461}
16462
16463static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
16464{
16465 unsigned int present1, present2;
16466
16467 present1 = snd_hda_codec_read(codec, 0x1b, 0,
16468 AC_VERB_GET_PIN_SENSE, 0)
16469 & AC_PINSENSE_PRESENCE;
16470 present2 = snd_hda_codec_read(codec, 0x15, 0,
16471 AC_VERB_GET_PIN_SENSE, 0)
16472 & AC_PINSENSE_PRESENCE;
16473
16474 if (present1 || present2) {
16475 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16476 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16477 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16478 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
16479 } else {
16480 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
16481 AMP_IN_MUTE(0), 0);
16482 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
16483 AMP_IN_MUTE(0), 0);
16484 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020016485}
16486
16487static void alc663_m51va_mic_automute(struct hda_codec *codec)
16488{
16489 unsigned int present;
16490
16491 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020016492 AC_VERB_GET_PIN_SENSE, 0)
16493 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020016494 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016495 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016496 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016497 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016498 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016499 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016500 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020016501 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020016502}
16503
16504static void alc663_m51va_unsol_event(struct hda_codec *codec,
16505 unsigned int res)
16506{
16507 switch (res >> 26) {
16508 case ALC880_HP_EVENT:
16509 alc663_m51va_speaker_automute(codec);
16510 break;
16511 case ALC880_MIC_EVENT:
16512 alc663_m51va_mic_automute(codec);
16513 break;
16514 }
16515}
16516
16517static void alc663_m51va_inithook(struct hda_codec *codec)
16518{
16519 alc663_m51va_speaker_automute(codec);
16520 alc663_m51va_mic_automute(codec);
16521}
16522
Kailang Yangf1d4e282008-08-26 14:03:29 +020016523/* ***************** Mode1 ******************************/
16524static void alc663_mode1_unsol_event(struct hda_codec *codec,
16525 unsigned int res)
16526{
16527 switch (res >> 26) {
16528 case ALC880_HP_EVENT:
16529 alc663_m51va_speaker_automute(codec);
16530 break;
16531 case ALC880_MIC_EVENT:
16532 alc662_eeepc_mic_automute(codec);
16533 break;
16534 }
16535}
16536
16537static void alc663_mode1_inithook(struct hda_codec *codec)
16538{
16539 alc663_m51va_speaker_automute(codec);
16540 alc662_eeepc_mic_automute(codec);
16541}
16542/* ***************** Mode2 ******************************/
16543static void alc662_mode2_unsol_event(struct hda_codec *codec,
16544 unsigned int res)
16545{
16546 switch (res >> 26) {
16547 case ALC880_HP_EVENT:
16548 alc662_f5z_speaker_automute(codec);
16549 break;
16550 case ALC880_MIC_EVENT:
16551 alc662_eeepc_mic_automute(codec);
16552 break;
16553 }
16554}
16555
16556static void alc662_mode2_inithook(struct hda_codec *codec)
16557{
16558 alc662_f5z_speaker_automute(codec);
16559 alc662_eeepc_mic_automute(codec);
16560}
16561/* ***************** Mode3 ******************************/
16562static void alc663_mode3_unsol_event(struct hda_codec *codec,
16563 unsigned int res)
16564{
16565 switch (res >> 26) {
16566 case ALC880_HP_EVENT:
16567 alc663_two_hp_m1_speaker_automute(codec);
16568 break;
16569 case ALC880_MIC_EVENT:
16570 alc662_eeepc_mic_automute(codec);
16571 break;
16572 }
16573}
16574
16575static void alc663_mode3_inithook(struct hda_codec *codec)
16576{
16577 alc663_two_hp_m1_speaker_automute(codec);
16578 alc662_eeepc_mic_automute(codec);
16579}
16580/* ***************** Mode4 ******************************/
16581static void alc663_mode4_unsol_event(struct hda_codec *codec,
16582 unsigned int res)
16583{
16584 switch (res >> 26) {
16585 case ALC880_HP_EVENT:
16586 alc663_21jd_two_speaker_automute(codec);
16587 break;
16588 case ALC880_MIC_EVENT:
16589 alc662_eeepc_mic_automute(codec);
16590 break;
16591 }
16592}
16593
16594static void alc663_mode4_inithook(struct hda_codec *codec)
16595{
16596 alc663_21jd_two_speaker_automute(codec);
16597 alc662_eeepc_mic_automute(codec);
16598}
16599/* ***************** Mode5 ******************************/
16600static void alc663_mode5_unsol_event(struct hda_codec *codec,
16601 unsigned int res)
16602{
16603 switch (res >> 26) {
16604 case ALC880_HP_EVENT:
16605 alc663_15jd_two_speaker_automute(codec);
16606 break;
16607 case ALC880_MIC_EVENT:
16608 alc662_eeepc_mic_automute(codec);
16609 break;
16610 }
16611}
16612
16613static void alc663_mode5_inithook(struct hda_codec *codec)
16614{
16615 alc663_15jd_two_speaker_automute(codec);
16616 alc662_eeepc_mic_automute(codec);
16617}
16618/* ***************** Mode6 ******************************/
16619static void alc663_mode6_unsol_event(struct hda_codec *codec,
16620 unsigned int res)
16621{
16622 switch (res >> 26) {
16623 case ALC880_HP_EVENT:
16624 alc663_two_hp_m2_speaker_automute(codec);
16625 break;
16626 case ALC880_MIC_EVENT:
16627 alc662_eeepc_mic_automute(codec);
16628 break;
16629 }
16630}
16631
16632static void alc663_mode6_inithook(struct hda_codec *codec)
16633{
16634 alc663_two_hp_m2_speaker_automute(codec);
16635 alc662_eeepc_mic_automute(codec);
16636}
16637
Kailang Yang6dda9f42008-05-27 12:05:31 +020016638static void alc663_g71v_hp_automute(struct hda_codec *codec)
16639{
16640 unsigned int present;
16641 unsigned char bits;
16642
16643 present = snd_hda_codec_read(codec, 0x21, 0,
16644 AC_VERB_GET_PIN_SENSE, 0)
16645 & AC_PINSENSE_PRESENCE;
16646 bits = present ? HDA_AMP_MUTE : 0;
16647 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16648 HDA_AMP_MUTE, bits);
16649 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16650 HDA_AMP_MUTE, bits);
16651}
16652
16653static void alc663_g71v_front_automute(struct hda_codec *codec)
16654{
16655 unsigned int present;
16656 unsigned char bits;
16657
16658 present = snd_hda_codec_read(codec, 0x15, 0,
16659 AC_VERB_GET_PIN_SENSE, 0)
16660 & AC_PINSENSE_PRESENCE;
16661 bits = present ? HDA_AMP_MUTE : 0;
16662 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16663 HDA_AMP_MUTE, bits);
16664}
16665
16666static void alc663_g71v_unsol_event(struct hda_codec *codec,
16667 unsigned int res)
16668{
16669 switch (res >> 26) {
16670 case ALC880_HP_EVENT:
16671 alc663_g71v_hp_automute(codec);
16672 break;
16673 case ALC880_FRONT_EVENT:
16674 alc663_g71v_front_automute(codec);
16675 break;
16676 case ALC880_MIC_EVENT:
16677 alc662_eeepc_mic_automute(codec);
16678 break;
16679 }
16680}
16681
16682static void alc663_g71v_inithook(struct hda_codec *codec)
16683{
16684 alc663_g71v_front_automute(codec);
16685 alc663_g71v_hp_automute(codec);
16686 alc662_eeepc_mic_automute(codec);
16687}
16688
16689static void alc663_g50v_unsol_event(struct hda_codec *codec,
16690 unsigned int res)
16691{
16692 switch (res >> 26) {
16693 case ALC880_HP_EVENT:
16694 alc663_m51va_speaker_automute(codec);
16695 break;
16696 case ALC880_MIC_EVENT:
16697 alc662_eeepc_mic_automute(codec);
16698 break;
16699 }
16700}
16701
16702static void alc663_g50v_inithook(struct hda_codec *codec)
16703{
16704 alc663_m51va_speaker_automute(codec);
16705 alc662_eeepc_mic_automute(codec);
16706}
16707
Kailang Yangf1d4e282008-08-26 14:03:29 +020016708static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16709 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020016710 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016711
16712 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16713 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16714 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16715
16716 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16717 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16718 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16719 { } /* end */
16720};
16721
Chris Pockelé9541ba12009-05-12 08:08:53 +020016722static struct snd_kcontrol_new alc272_nc10_mixer[] = {
16723 /* Master Playback automatically created from Speaker and Headphone */
16724 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16725 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16726 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16728
16729 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16730 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16731 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16732
16733 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16734 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16735 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16736 { } /* end */
16737};
16738
Takashi Iwaicb53c622007-08-10 17:21:45 +020016739#ifdef CONFIG_SND_HDA_POWER_SAVE
16740#define alc662_loopbacks alc880_loopbacks
16741#endif
16742
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016743
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016744/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016745#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16746#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16747#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16748#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16749
16750/*
16751 * configuration and preset
16752 */
16753static const char *alc662_models[ALC662_MODEL_LAST] = {
16754 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16755 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16756 [ALC662_3ST_6ch] = "3stack-6ch",
16757 [ALC662_5ST_DIG] = "6stack-dig",
16758 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016759 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016760 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016761 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016762 [ALC663_ASUS_M51VA] = "m51va",
16763 [ALC663_ASUS_G71V] = "g71v",
16764 [ALC663_ASUS_H13] = "h13",
16765 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016766 [ALC663_ASUS_MODE1] = "asus-mode1",
16767 [ALC662_ASUS_MODE2] = "asus-mode2",
16768 [ALC663_ASUS_MODE3] = "asus-mode3",
16769 [ALC663_ASUS_MODE4] = "asus-mode4",
16770 [ALC663_ASUS_MODE5] = "asus-mode5",
16771 [ALC663_ASUS_MODE6] = "asus-mode6",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020016772 [ALC272_DELL] = "dell",
16773 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020016774 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016775 [ALC662_AUTO] = "auto",
16776};
16777
16778static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016779 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020016780 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
16781 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016782 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16783 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16784 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16785 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16786 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16787 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16788 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16789 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16790 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16791 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16792 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16793 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016794 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
16795 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
16796 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016797 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16798 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16799 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16800 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016801 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016802 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16803 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016804 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016805 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16806 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16807 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016808 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
16809 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
16810 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016811 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16812 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16813 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016814 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016815 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16816 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020016817 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016818 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016819 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016820 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16821 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16822 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020016823 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016824 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16825 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016826 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016827 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016828 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016829 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016830 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16831 ALC662_3ST_6ch_DIG),
Chris Pockelé9541ba12009-05-12 08:08:53 +020016832 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016833 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16834 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016835 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020016836 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016837 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016838 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016839 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016840 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16841 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016842 {}
16843};
16844
16845static struct alc_config_preset alc662_presets[] = {
16846 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016847 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016848 .init_verbs = { alc662_init_verbs },
16849 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16850 .dac_nids = alc662_dac_nids,
16851 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016852 .dig_in_nid = ALC662_DIGIN_NID,
16853 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16854 .channel_mode = alc662_3ST_2ch_modes,
16855 .input_mux = &alc662_capture_source,
16856 },
16857 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016858 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016859 .init_verbs = { alc662_init_verbs },
16860 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16861 .dac_nids = alc662_dac_nids,
16862 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016863 .dig_in_nid = ALC662_DIGIN_NID,
16864 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16865 .channel_mode = alc662_3ST_6ch_modes,
16866 .need_dac_fix = 1,
16867 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016868 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016869 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016870 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016871 .init_verbs = { alc662_init_verbs },
16872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16873 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016874 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16875 .channel_mode = alc662_3ST_6ch_modes,
16876 .need_dac_fix = 1,
16877 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016878 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016879 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016880 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016881 .init_verbs = { alc662_init_verbs },
16882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16883 .dac_nids = alc662_dac_nids,
16884 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016885 .dig_in_nid = ALC662_DIGIN_NID,
16886 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16887 .channel_mode = alc662_5stack_modes,
16888 .input_mux = &alc662_capture_source,
16889 },
16890 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016891 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016892 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16893 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16894 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016895 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16896 .channel_mode = alc662_3ST_2ch_modes,
16897 .input_mux = &alc662_lenovo_101e_capture_source,
16898 .unsol_event = alc662_lenovo_101e_unsol_event,
16899 .init_hook = alc662_lenovo_101e_all_automute,
16900 },
Kailang Yang291702f2007-10-16 14:28:03 +020016901 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016902 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016903 .init_verbs = { alc662_init_verbs,
16904 alc662_eeepc_sue_init_verbs },
16905 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16906 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016907 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16908 .channel_mode = alc662_3ST_2ch_modes,
16909 .input_mux = &alc662_eeepc_capture_source,
16910 .unsol_event = alc662_eeepc_unsol_event,
16911 .init_hook = alc662_eeepc_inithook,
16912 },
Kailang Yang8c427222008-01-10 13:03:59 +010016913 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016914 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016915 alc662_chmode_mixer },
16916 .init_verbs = { alc662_init_verbs,
16917 alc662_eeepc_ep20_sue_init_verbs },
16918 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16919 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16921 .channel_mode = alc662_3ST_6ch_modes,
16922 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020016923 .unsol_event = alc662_eeepc_unsol_event,
Kailang Yang8c427222008-01-10 13:03:59 +010016924 .init_hook = alc662_eeepc_ep20_inithook,
16925 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016926 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016927 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016928 .init_verbs = { alc662_init_verbs,
16929 alc662_ecs_init_verbs },
16930 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16931 .dac_nids = alc662_dac_nids,
16932 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16933 .channel_mode = alc662_3ST_2ch_modes,
16934 .input_mux = &alc662_eeepc_capture_source,
16935 .unsol_event = alc662_eeepc_unsol_event,
16936 .init_hook = alc662_eeepc_inithook,
16937 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016938 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016939 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016940 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16941 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16942 .dac_nids = alc662_dac_nids,
16943 .dig_out_nid = ALC662_DIGOUT_NID,
16944 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16945 .channel_mode = alc662_3ST_2ch_modes,
16946 .input_mux = &alc663_m51va_capture_source,
16947 .unsol_event = alc663_m51va_unsol_event,
16948 .init_hook = alc663_m51va_inithook,
16949 },
16950 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016951 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016952 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16953 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16954 .dac_nids = alc662_dac_nids,
16955 .dig_out_nid = ALC662_DIGOUT_NID,
16956 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16957 .channel_mode = alc662_3ST_2ch_modes,
16958 .input_mux = &alc662_eeepc_capture_source,
16959 .unsol_event = alc663_g71v_unsol_event,
16960 .init_hook = alc663_g71v_inithook,
16961 },
16962 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016963 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016964 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16965 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16966 .dac_nids = alc662_dac_nids,
16967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16968 .channel_mode = alc662_3ST_2ch_modes,
16969 .input_mux = &alc663_m51va_capture_source,
16970 .unsol_event = alc663_m51va_unsol_event,
16971 .init_hook = alc663_m51va_inithook,
16972 },
16973 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016974 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016975 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16976 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16977 .dac_nids = alc662_dac_nids,
16978 .dig_out_nid = ALC662_DIGOUT_NID,
16979 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16980 .channel_mode = alc662_3ST_6ch_modes,
16981 .input_mux = &alc663_capture_source,
16982 .unsol_event = alc663_g50v_unsol_event,
16983 .init_hook = alc663_g50v_inithook,
16984 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016985 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016986 .mixers = { alc663_m51va_mixer },
16987 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016988 .init_verbs = { alc662_init_verbs,
16989 alc663_21jd_amic_init_verbs },
16990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16991 .hp_nid = 0x03,
16992 .dac_nids = alc662_dac_nids,
16993 .dig_out_nid = ALC662_DIGOUT_NID,
16994 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16995 .channel_mode = alc662_3ST_2ch_modes,
16996 .input_mux = &alc662_eeepc_capture_source,
16997 .unsol_event = alc663_mode1_unsol_event,
16998 .init_hook = alc663_mode1_inithook,
16999 },
17000 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017001 .mixers = { alc662_1bjd_mixer },
17002 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017003 .init_verbs = { alc662_init_verbs,
17004 alc662_1bjd_amic_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_2ch_modes),
17009 .channel_mode = alc662_3ST_2ch_modes,
17010 .input_mux = &alc662_eeepc_capture_source,
17011 .unsol_event = alc662_mode2_unsol_event,
17012 .init_hook = alc662_mode2_inithook,
17013 },
17014 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017015 .mixers = { alc663_two_hp_m1_mixer },
17016 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017017 .init_verbs = { alc662_init_verbs,
17018 alc663_two_hp_amic_m1_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_mode3_unsol_event,
17027 .init_hook = alc663_mode3_inithook,
17028 },
17029 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017030 .mixers = { alc663_asus_21jd_clfe_mixer },
17031 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017032 .init_verbs = { alc662_init_verbs,
17033 alc663_21jd_amic_init_verbs},
17034 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17035 .hp_nid = 0x03,
17036 .dac_nids = alc662_dac_nids,
17037 .dig_out_nid = ALC662_DIGOUT_NID,
17038 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17039 .channel_mode = alc662_3ST_2ch_modes,
17040 .input_mux = &alc662_eeepc_capture_source,
17041 .unsol_event = alc663_mode4_unsol_event,
17042 .init_hook = alc663_mode4_inithook,
17043 },
17044 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017045 .mixers = { alc663_asus_15jd_clfe_mixer },
17046 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017047 .init_verbs = { alc662_init_verbs,
17048 alc663_15jd_amic_init_verbs },
17049 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17050 .hp_nid = 0x03,
17051 .dac_nids = alc662_dac_nids,
17052 .dig_out_nid = ALC662_DIGOUT_NID,
17053 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17054 .channel_mode = alc662_3ST_2ch_modes,
17055 .input_mux = &alc662_eeepc_capture_source,
17056 .unsol_event = alc663_mode5_unsol_event,
17057 .init_hook = alc663_mode5_inithook,
17058 },
17059 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017060 .mixers = { alc663_two_hp_m2_mixer },
17061 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017062 .init_verbs = { alc662_init_verbs,
17063 alc663_two_hp_amic_m2_init_verbs },
17064 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17065 .hp_nid = 0x03,
17066 .dac_nids = alc662_dac_nids,
17067 .dig_out_nid = ALC662_DIGOUT_NID,
17068 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17069 .channel_mode = alc662_3ST_2ch_modes,
17070 .input_mux = &alc662_eeepc_capture_source,
17071 .unsol_event = alc663_mode6_unsol_event,
17072 .init_hook = alc663_mode6_inithook,
17073 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017074 [ALC272_DELL] = {
17075 .mixers = { alc663_m51va_mixer },
17076 .cap_mixer = alc272_auto_capture_mixer,
17077 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17078 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17079 .dac_nids = alc662_dac_nids,
17080 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17081 .adc_nids = alc272_adc_nids,
17082 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17083 .capsrc_nids = alc272_capsrc_nids,
17084 .channel_mode = alc662_3ST_2ch_modes,
17085 .input_mux = &alc663_m51va_capture_source,
17086 .unsol_event = alc663_m51va_unsol_event,
17087 .init_hook = alc663_m51va_inithook,
17088 },
17089 [ALC272_DELL_ZM1] = {
17090 .mixers = { alc663_m51va_mixer },
17091 .cap_mixer = alc662_auto_capture_mixer,
17092 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17093 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17094 .dac_nids = alc662_dac_nids,
17095 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17096 .adc_nids = alc662_adc_nids,
17097 .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
17098 .capsrc_nids = alc662_capsrc_nids,
17099 .channel_mode = alc662_3ST_2ch_modes,
17100 .input_mux = &alc663_m51va_capture_source,
17101 .unsol_event = alc663_m51va_unsol_event,
17102 .init_hook = alc663_m51va_inithook,
17103 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017104 [ALC272_SAMSUNG_NC10] = {
17105 .mixers = { alc272_nc10_mixer },
17106 .init_verbs = { alc662_init_verbs,
17107 alc663_21jd_amic_init_verbs },
17108 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17109 .dac_nids = alc272_dac_nids,
17110 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17111 .channel_mode = alc662_3ST_2ch_modes,
17112 .input_mux = &alc272_nc10_capture_source,
17113 .unsol_event = alc663_mode4_unsol_event,
17114 .init_hook = alc663_mode4_inithook,
17115 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017116};
17117
17118
17119/*
17120 * BIOS auto configuration
17121 */
17122
17123/* add playback controls from the parsed DAC table */
17124static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
17125 const struct auto_pin_cfg *cfg)
17126{
17127 char name[32];
17128 static const char *chname[4] = {
17129 "Front", "Surround", NULL /*CLFE*/, "Side"
17130 };
17131 hda_nid_t nid;
17132 int i, err;
17133
17134 for (i = 0; i < cfg->line_outs; i++) {
17135 if (!spec->multiout.dac_nids[i])
17136 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020017137 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017138 if (i == 2) {
17139 /* Center/LFE */
17140 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17141 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017142 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
17143 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017144 if (err < 0)
17145 return err;
17146 err = add_control(spec, ALC_CTL_WIDGET_VOL,
17147 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017148 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
17149 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017150 if (err < 0)
17151 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017152 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017153 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017154 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017155 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017156 if (err < 0)
17157 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017158 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017159 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017160 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017161 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017162 if (err < 0)
17163 return err;
17164 } else {
17165 sprintf(name, "%s Playback Volume", chname[i]);
17166 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017167 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
17168 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017169 if (err < 0)
17170 return err;
17171 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030017172 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17173 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
17174 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017175 if (err < 0)
17176 return err;
17177 }
17178 }
17179 return 0;
17180}
17181
17182/* add playback controls for speaker and HP outputs */
17183static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
17184 const char *pfx)
17185{
17186 hda_nid_t nid;
17187 int err;
17188 char name[32];
17189
17190 if (!pin)
17191 return 0;
17192
Takashi Iwai24fb9172008-09-02 14:48:20 +020017193 if (pin == 0x17) {
17194 /* ALC663 has a mono output pin on 0x17 */
17195 sprintf(name, "%s Playback Switch", pfx);
17196 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17197 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
17198 return err;
17199 }
17200
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017201 if (alc880_is_fixed_pin(pin)) {
17202 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010017203 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017204 /* specify the DAC as the extra output */
17205 if (!spec->multiout.hp_nid)
17206 spec->multiout.hp_nid = nid;
17207 else
17208 spec->multiout.extra_out_nid[0] = nid;
17209 /* control HP volume/switch on the output mixer amp */
17210 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17211 sprintf(name, "%s Playback Volume", pfx);
17212 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
17213 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
17214 if (err < 0)
17215 return err;
17216 sprintf(name, "%s Playback Switch", pfx);
17217 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
17218 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
17219 if (err < 0)
17220 return err;
17221 } else if (alc880_is_multi_pin(pin)) {
17222 /* set manual connection */
17223 /* we have only a switch on HP-out PIN */
17224 sprintf(name, "%s Playback Switch", pfx);
17225 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
17226 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17227 if (err < 0)
17228 return err;
17229 }
17230 return 0;
17231}
17232
Takashi Iwai2d864c42009-03-20 12:52:47 +010017233static int alc662_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
17234{
Takashi Iwai1327a322009-03-23 13:07:47 +010017235 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai2d864c42009-03-20 12:52:47 +010017236 return (pincap & AC_PINCAP_IN) != 0;
17237}
17238
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017239/* create playback/capture controls for input pins */
Takashi Iwai2d864c42009-03-20 12:52:47 +010017240static int alc662_auto_create_analog_input_ctls(struct hda_codec *codec,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017241 const struct auto_pin_cfg *cfg)
17242{
Takashi Iwai2d864c42009-03-20 12:52:47 +010017243 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017244 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017245 int i, err, idx;
17246
17247 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai2d864c42009-03-20 12:52:47 +010017248 if (alc662_is_input_pin(codec, cfg->input_pins[i])) {
Takashi Iwai6c819492009-08-10 18:47:44 +020017249 idx = get_connection_index(codec, 0x0b,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017250 cfg->input_pins[i]);
17251 if (idx >= 0) {
17252 err = new_analog_input(spec, cfg->input_pins[i],
17253 auto_pin_cfg_labels[i],
17254 idx, 0x0b);
17255 if (err < 0)
17256 return err;
17257 }
Takashi Iwai6c819492009-08-10 18:47:44 +020017258 idx = get_connection_index(codec, 0x22,
Takashi Iwai2d864c42009-03-20 12:52:47 +010017259 cfg->input_pins[i]);
17260 if (idx >= 0) {
17261 imux->items[imux->num_items].label =
17262 auto_pin_cfg_labels[i];
17263 imux->items[imux->num_items].index = idx;
17264 imux->num_items++;
17265 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017266 }
17267 }
17268 return 0;
17269}
17270
17271static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
17272 hda_nid_t nid, int pin_type,
17273 int dac_idx)
17274{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017275 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017276 /* need the manual connection? */
17277 if (alc880_is_multi_pin(nid)) {
17278 struct alc_spec *spec = codec->spec;
17279 int idx = alc880_multi_pin_idx(nid);
17280 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
17281 AC_VERB_SET_CONNECT_SEL,
17282 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
17283 }
17284}
17285
17286static void alc662_auto_init_multi_out(struct hda_codec *codec)
17287{
17288 struct alc_spec *spec = codec->spec;
17289 int i;
17290
17291 for (i = 0; i <= HDA_SIDE; i++) {
17292 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017293 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017294 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017295 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017296 i);
17297 }
17298}
17299
17300static void alc662_auto_init_hp_out(struct hda_codec *codec)
17301{
17302 struct alc_spec *spec = codec->spec;
17303 hda_nid_t pin;
17304
17305 pin = spec->autocfg.hp_pins[0];
17306 if (pin) /* connect to front */
17307 /* use dac 0 */
17308 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017309 pin = spec->autocfg.speaker_pins[0];
17310 if (pin)
17311 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017312}
17313
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017314#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
17315
17316static void alc662_auto_init_analog_input(struct hda_codec *codec)
17317{
17318 struct alc_spec *spec = codec->spec;
17319 int i;
17320
17321 for (i = 0; i < AUTO_PIN_LAST; i++) {
17322 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai2d864c42009-03-20 12:52:47 +010017323 if (alc662_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010017324 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010017325 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010017326 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017327 snd_hda_codec_write(codec, nid, 0,
17328 AC_VERB_SET_AMP_GAIN_MUTE,
17329 AMP_OUT_MUTE);
17330 }
17331 }
17332}
17333
Takashi Iwaif511b012008-08-15 16:46:42 +020017334#define alc662_auto_init_input_src alc882_auto_init_input_src
17335
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017336static int alc662_parse_auto_config(struct hda_codec *codec)
17337{
17338 struct alc_spec *spec = codec->spec;
17339 int err;
17340 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
17341
17342 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17343 alc662_ignore);
17344 if (err < 0)
17345 return err;
17346 if (!spec->autocfg.line_outs)
17347 return 0; /* can't find valid BIOS pin config */
17348
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017349 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17350 if (err < 0)
17351 return err;
17352 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
17353 if (err < 0)
17354 return err;
17355 err = alc662_auto_create_extra_out(spec,
17356 spec->autocfg.speaker_pins[0],
17357 "Speaker");
17358 if (err < 0)
17359 return err;
17360 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
17361 "Headphone");
17362 if (err < 0)
17363 return err;
Takashi Iwai2d864c42009-03-20 12:52:47 +010017364 err = alc662_auto_create_analog_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017365 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017366 return err;
17367
17368 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17369
Takashi Iwai0852d7a2009-02-11 11:35:15 +010017370 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
17372
Takashi Iwai603c4012008-07-30 15:01:44 +020017373 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017374 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375
17376 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017377 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020017378
Takashi Iwaid88897e2008-10-31 15:01:37 +010017379 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020017380 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017381 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020017382
17383 err = alc_auto_add_mic_boost(codec);
17384 if (err < 0)
17385 return err;
17386
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017387 alc_ssid_check(codec, 0x15, 0x1b, 0x14);
17388
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017389 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017390}
17391
17392/* additional initialization for auto-configuration model */
17393static void alc662_auto_init(struct hda_codec *codec)
17394{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017395 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017396 alc662_auto_init_multi_out(codec);
17397 alc662_auto_init_hp_out(codec);
17398 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017399 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017400 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017401 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017402}
17403
17404static int patch_alc662(struct hda_codec *codec)
17405{
17406 struct alc_spec *spec;
17407 int err, board_config;
17408
17409 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17410 if (!spec)
17411 return -ENOMEM;
17412
17413 codec->spec = spec;
17414
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020017415 alc_fix_pll_init(codec, 0x20, 0x04, 15);
17416
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017417 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
17418 alc662_models,
17419 alc662_cfg_tbl);
17420 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017421 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17422 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017423 board_config = ALC662_AUTO;
17424 }
17425
17426 if (board_config == ALC662_AUTO) {
17427 /* automatic parse from the BIOS config */
17428 err = alc662_parse_auto_config(codec);
17429 if (err < 0) {
17430 alc_free(codec);
17431 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020017432 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017433 printk(KERN_INFO
17434 "hda_codec: Cannot set up configuration "
17435 "from BIOS. Using base mode...\n");
17436 board_config = ALC662_3ST_2ch_DIG;
17437 }
17438 }
17439
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017440 err = snd_hda_attach_beep_device(codec, 0x1);
17441 if (err < 0) {
17442 alc_free(codec);
17443 return err;
17444 }
17445
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446 if (board_config != ALC662_AUTO)
17447 setup_preset(spec, &alc662_presets[board_config]);
17448
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017449 spec->stream_analog_playback = &alc662_pcm_analog_playback;
17450 spec->stream_analog_capture = &alc662_pcm_analog_capture;
17451
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017452 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17453 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17454
Takashi Iwaie1406342008-02-11 18:32:32 +010017455 spec->adc_nids = alc662_adc_nids;
17456 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17457 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017458
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017459 if (!spec->cap_mixer)
17460 set_capture_mixer(spec);
Takashi Iwaib9591442009-03-16 15:25:00 +010017461 if (codec->vendor_id == 0x10ec0662)
17462 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
17463 else
17464 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017465
Takashi Iwai2134ea42008-01-10 16:53:55 +010017466 spec->vmaster_nid = 0x02;
17467
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017468 codec->patch_ops = alc_patch_ops;
17469 if (board_config == ALC662_AUTO)
17470 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017471#ifdef CONFIG_SND_HDA_POWER_SAVE
17472 if (!spec->loopback.amplist)
17473 spec->loopback.amplist = alc662_loopbacks;
17474#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010017475 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476
17477 return 0;
17478}
17479
17480/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070017481 * patch entries
17482 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017483static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070017484 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017485 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017486 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020017487 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010017488 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020017489 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017490 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017492 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
17493 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
17494 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017495 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017496 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017497 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
17498 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017499 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017500 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017501 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017502 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020017503 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017504 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020017505 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017506 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010017507 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020017508 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020017509 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020017510 .patch = patch_alc882 },
17511 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
17512 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070017513 {} /* terminator */
17514};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010017515
17516MODULE_ALIAS("snd-hda-codec-id:10ec*");
17517
17518MODULE_LICENSE("GPL");
17519MODULE_DESCRIPTION("Realtek HD-audio codec");
17520
17521static struct hda_codec_preset_list realtek_list = {
17522 .preset = snd_hda_preset_realtek,
17523 .owner = THIS_MODULE,
17524};
17525
17526static int __init patch_realtek_init(void)
17527{
17528 return snd_hda_add_codec_preset(&realtek_list);
17529}
17530
17531static void __exit patch_realtek_exit(void)
17532{
17533 snd_hda_delete_codec_preset(&realtek_list);
17534}
17535
17536module_init(patch_realtek_init)
17537module_exit(patch_realtek_exit)