blob: bcbf9160ed81af7a805007f152067908f9970840 [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 Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200140 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100141 ALC269_AUTO,
142 ALC269_MODEL_LAST /* last tag */
143};
144
Kailang Yangdf694da2005-12-05 19:42:22 +0100145/* ALC861 models */
146enum {
147 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200148 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100149 ALC861_3ST_DIG,
150 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200151 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200152 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200153 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100154 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100155 ALC861_AUTO,
156 ALC861_MODEL_LAST,
157};
158
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100159/* ALC861-VD models */
160enum {
161 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200162 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100163 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100164 ALC861VD_3ST,
165 ALC861VD_3ST_DIG,
166 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200167 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200168 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200169 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100170 ALC861VD_AUTO,
171 ALC861VD_MODEL_LAST,
172};
173
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200174/* ALC662 models */
175enum {
176 ALC662_3ST_2ch_DIG,
177 ALC662_3ST_6ch_DIG,
178 ALC662_3ST_6ch,
179 ALC662_5ST_DIG,
180 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200181 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100182 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200183 ALC663_ASUS_M51VA,
184 ALC663_ASUS_G71V,
185 ALC663_ASUS_H13,
186 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200187 ALC662_ECS,
188 ALC663_ASUS_MODE1,
189 ALC662_ASUS_MODE2,
190 ALC663_ASUS_MODE3,
191 ALC663_ASUS_MODE4,
192 ALC663_ASUS_MODE5,
193 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100194 ALC663_ASUS_MODE7,
195 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200196 ALC272_DELL,
197 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200198 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200199 ALC662_AUTO,
200 ALC662_MODEL_LAST,
201};
202
Kailang Yangdf694da2005-12-05 19:42:22 +0100203/* ALC882 models */
204enum {
205 ALC882_3ST_DIG,
206 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200207 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200208 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200209 ALC882_TARGA,
210 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200211 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100212 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800213 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200214 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200215 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100216 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200217 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800218 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200219 ALC883_3ST_2ch_DIG,
220 ALC883_3ST_6ch_DIG,
221 ALC883_3ST_6ch,
222 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200223 ALC883_TARGA_DIG,
224 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200225 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200226 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200227 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800228 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100229 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200230 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200231 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200232 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200233 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
297};
298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299struct alc_spec {
300 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100301 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100303 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100304 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200306 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200307 * don't forget NULL
308 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200309 */
310 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200312 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 struct hda_pcm_stream *stream_analog_playback;
314 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100315 struct hda_pcm_stream *stream_analog_alt_playback;
316 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200318 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 struct hda_pcm_stream *stream_digital_playback;
320 struct hda_pcm_stream *stream_digital_capture;
321
322 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200323 struct hda_multi_out multiout; /* playback set-up
324 * max_channels, dacs must be set
325 * dig_out_nid and hp_nid are optional
326 */
Takashi Iwai63300792008-01-24 15:31:36 +0100327 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100328 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100329 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
331 /* capture */
332 unsigned int num_adc_nids;
333 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100334 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200335 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Takashi Iwai840b64c2010-07-13 22:49:01 +0200337 /* capture setup for dynamic dual-adc switch */
338 unsigned int cur_adc_idx;
339 hda_nid_t cur_adc;
340 unsigned int cur_adc_stream_tag;
341 unsigned int cur_adc_format;
342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200344 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 const struct hda_input_mux *input_mux;
346 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200347 struct alc_mic_route ext_mic;
348 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
350 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100351 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200353 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200354 int const_channel_count;
355 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100358 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200359
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200360 /* dynamic controls, init_verbs and input_mux */
361 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100362 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200363 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200364 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200365 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200366 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
367 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100368
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100369 /* hooks */
370 void (*init_hook)(struct hda_codec *codec);
371 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100372#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500373 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100374#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100375
Takashi Iwai834be882006-03-01 14:16:17 +0100376 /* for pin sensing */
377 unsigned int sense_updated: 1;
378 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100379 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200380 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200381
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100382 /* other flags */
383 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200384 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200385 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100386
Takashi Iwai2134ea42008-01-10 16:53:55 +0100387 /* for virtual master */
388 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200389#ifdef CONFIG_SND_HDA_POWER_SAVE
390 struct hda_loopback_check loopback;
391#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200392
393 /* for PLL fix */
394 hda_nid_t pll_nid;
395 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100396};
397
398/*
399 * configuration template - to be copied to the spec instance
400 */
401struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402 struct snd_kcontrol_new *mixers[5]; /* should be identical size
403 * with spec
404 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100405 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100406 const struct hda_verb *init_verbs[5];
407 unsigned int num_dacs;
408 hda_nid_t *dac_nids;
409 hda_nid_t dig_out_nid; /* optional */
410 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800411 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100412 unsigned int num_adc_nids;
413 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100414 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100415 hda_nid_t dig_in_nid;
416 unsigned int num_channel_mode;
417 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200418 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200419 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200420 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100421 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100422 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200423 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100424 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200425#ifdef CONFIG_SND_HDA_POWER_SAVE
426 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500427 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200428#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429};
430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432/*
433 * input MUX handling
434 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437{
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200440 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
441 if (mux_idx >= spec->num_mux_defs)
442 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100443 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
444 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200445 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446}
447
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450{
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct alc_spec *spec = codec->spec;
453 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
454
455 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
456 return 0;
457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100464 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100466 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100467 hda_nid_t nid = spec->capsrc_nids ?
468 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200469 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
Takashi Iwaicd896c32008-11-18 12:36:33 +0100471 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
472 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100473 if (!imux->num_items && mux_idx > 0)
474 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475
Takashi Iwaia22d5432009-07-27 12:54:26 +0200476 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200477 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100478 /* Matrix-mixer style (e.g. ALC882) */
479 unsigned int *cur_val = &spec->cur_mux[adc_idx];
480 unsigned int i, idx;
481
482 idx = ucontrol->value.enumerated.item[0];
483 if (idx >= imux->num_items)
484 idx = imux->num_items - 1;
485 if (*cur_val == idx)
486 return 0;
487 for (i = 0; i < imux->num_items; i++) {
488 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
489 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
490 imux->items[i].index,
491 HDA_AMP_MUTE, v);
492 }
493 *cur_val = idx;
494 return 1;
495 } else {
496 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100497 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100498 &spec->cur_mux[adc_idx]);
499 }
500}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200501
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502/*
503 * channel mode setting
504 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200505static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507{
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100510 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
511 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512}
513
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100519 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200521 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200529 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
530 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200531 &spec->ext_channel_count);
532 if (err >= 0 && !spec->const_channel_count) {
533 spec->multiout.max_channels = spec->ext_channel_count;
534 if (spec->need_dac_fix)
535 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
536 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200537 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538}
539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200542 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543 * being part of a format specifier. Maximum allowed length of a value is
544 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100545 *
546 * Note: some retasking pin complexes seem to ignore requests for input
547 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
548 * are requested. Therefore order this list so that this behaviour will not
549 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200550 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
551 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100554 "Mic 50pc bias", "Mic 80pc bias",
555 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100556};
557static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100558 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559};
560/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * in the pin being assumed to be exclusively an input or an output pin. In
562 * addition, "input" pins may or may not process the mic bias option
563 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
564 * accept requests for bias as of chip versions up to March 2006) and/or
565 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200567#define ALC_PIN_DIR_IN 0x00
568#define ALC_PIN_DIR_OUT 0x01
569#define ALC_PIN_DIR_INOUT 0x02
570#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
571#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572
Kailang Yangea1fb292008-08-26 12:58:38 +0200573/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 * For each direction the minimum and maximum values are given.
575 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200576static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 { 0, 2 }, /* ALC_PIN_DIR_IN */
578 { 3, 4 }, /* ALC_PIN_DIR_OUT */
579 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200580 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
581 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582};
583#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
584#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
585#define alc_pin_mode_n_items(_dir) \
586 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
587
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200590{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591 unsigned int item_num = uinfo->value.enumerated.item;
592 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
593
594 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200595 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100596 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
597
598 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
599 item_num = alc_pin_mode_min(dir);
600 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601 return 0;
602}
603
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100610 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
613 AC_VERB_GET_PIN_WIDGET_CONTROL,
614 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200615
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100616 /* Find enumerated value for current pinctl setting */
617 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200618 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200620 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 return 0;
622}
623
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626{
627 signed int change;
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 hda_nid_t nid = kcontrol->private_value & 0xffff;
630 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
631 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200632 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
633 AC_VERB_GET_PIN_WIDGET_CONTROL,
634 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200636 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637 val = alc_pin_mode_min(dir);
638
639 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100640 if (change) {
641 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200642 snd_hda_codec_write_cache(codec, nid, 0,
643 AC_VERB_SET_PIN_WIDGET_CONTROL,
644 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100645
Kailang Yangea1fb292008-08-26 12:58:38 +0200646 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100647 * for the requested pin mode. Enum values of 2 or less are
648 * input modes.
649 *
650 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200651 * reduces noise slightly (particularly on input) so we'll
652 * do it. However, having both input and output buffers
653 * enabled simultaneously doesn't seem to be problematic if
654 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100655 */
656 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200657 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
658 HDA_AMP_MUTE, HDA_AMP_MUTE);
659 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
660 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100661 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200662 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
663 HDA_AMP_MUTE, HDA_AMP_MUTE);
664 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
665 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100666 }
667 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200668 return change;
669}
670
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100671#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200672 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100673 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100674 .info = alc_pin_mode_info, \
675 .get = alc_pin_mode_get, \
676 .put = alc_pin_mode_put, \
677 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100678
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100679/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
680 * together using a mask with more than one bit set. This control is
681 * currently used only by the ALC260 test model. At this stage they are not
682 * needed for any "production" models.
683 */
684#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200685#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200686
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689{
690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
691 hda_nid_t nid = kcontrol->private_value & 0xffff;
692 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
693 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694 unsigned int val = snd_hda_codec_read(codec, nid, 0,
695 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100696
697 *valp = (val & mask) != 0;
698 return 0;
699}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200700static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100702{
703 signed int change;
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 hda_nid_t nid = kcontrol->private_value & 0xffff;
706 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
707 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200708 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
709 AC_VERB_GET_GPIO_DATA,
710 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711
712 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200713 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
714 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100715 gpio_data &= ~mask;
716 else
717 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200718 snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100720
721 return change;
722}
723#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
724 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100725 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726 .info = alc_gpio_data_info, \
727 .get = alc_gpio_data_get, \
728 .put = alc_gpio_data_put, \
729 .private_value = nid | (mask<<16) }
730#endif /* CONFIG_SND_DEBUG */
731
Jonathan Woithe92621f12006-02-28 11:47:47 +0100732/* A switch control to allow the enabling of the digital IO pins on the
733 * ALC260. This is incredibly simplistic; the intention of this control is
734 * to provide something in the test model allowing digital outputs to be
735 * identified if present. If models are found which can utilise these
736 * outputs a more complete mixer control can be devised for those models if
737 * necessary.
738 */
739#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200740#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200741
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200742static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
743 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100744{
745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
746 hda_nid_t nid = kcontrol->private_value & 0xffff;
747 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
748 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200749 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100750 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100751
752 *valp = (val & mask) != 0;
753 return 0;
754}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200755static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100757{
758 signed int change;
759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
760 hda_nid_t nid = kcontrol->private_value & 0xffff;
761 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
762 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200763 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100764 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200765 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766
767 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200768 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100769 if (val==0)
770 ctrl_data &= ~mask;
771 else
772 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200773 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
774 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100775
776 return change;
777}
778#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
779 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100780 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100781 .info = alc_spdif_ctrl_info, \
782 .get = alc_spdif_ctrl_get, \
783 .put = alc_spdif_ctrl_put, \
784 .private_value = nid | (mask<<16) }
785#endif /* CONFIG_SND_DEBUG */
786
Jonathan Woithef8225f62008-01-08 12:16:54 +0100787/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
788 * Again, this is only used in the ALC26x test models to help identify when
789 * the EAPD line must be asserted for features to work.
790 */
791#ifdef CONFIG_SND_DEBUG
792#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
793
794static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
796{
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 hda_nid_t nid = kcontrol->private_value & 0xffff;
799 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
800 long *valp = ucontrol->value.integer.value;
801 unsigned int val = snd_hda_codec_read(codec, nid, 0,
802 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
803
804 *valp = (val & mask) != 0;
805 return 0;
806}
807
808static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
810{
811 int change;
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 hda_nid_t nid = kcontrol->private_value & 0xffff;
814 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
815 long val = *ucontrol->value.integer.value;
816 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
817 AC_VERB_GET_EAPD_BTLENABLE,
818 0x00);
819
820 /* Set/unset the masked control bit(s) as needed */
821 change = (!val ? 0 : mask) != (ctrl_data & mask);
822 if (!val)
823 ctrl_data &= ~mask;
824 else
825 ctrl_data |= mask;
826 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
827 ctrl_data);
828
829 return change;
830}
831
832#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
833 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100834 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100835 .info = alc_eapd_ctrl_info, \
836 .get = alc_eapd_ctrl_get, \
837 .put = alc_eapd_ctrl_put, \
838 .private_value = nid | (mask<<16) }
839#endif /* CONFIG_SND_DEBUG */
840
Kailang Yangdf694da2005-12-05 19:42:22 +0100841/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100842 * set up the input pin config (depending on the given auto-pin type)
843 */
844static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
845 int auto_pin_type)
846{
847 unsigned int val = PIN_IN;
848
849 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
850 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200851 unsigned int oldval;
852 oldval = snd_hda_codec_read(codec, nid, 0,
853 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100854 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100855 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200856 /* if the default pin setup is vref50, we give it priority */
857 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100858 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200859 else if (pincap & AC_PINCAP_VREF_50)
860 val = PIN_VREF50;
861 else if (pincap & AC_PINCAP_VREF_100)
862 val = PIN_VREF100;
863 else if (pincap & AC_PINCAP_VREF_GRD)
864 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100865 }
866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
867}
868
869/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100870 */
871static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
872{
873 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
874 return;
875 spec->mixers[spec->num_mixers++] = mix;
876}
877
878static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
879{
880 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
881 return;
882 spec->init_verbs[spec->num_init_verbs++] = verb;
883}
884
885/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100886 * set up from the preset table
887 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200888static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200889 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100890{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200891 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892 int i;
893
894 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100895 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100896 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200897 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
898 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100899 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200900
Kailang Yangdf694da2005-12-05 19:42:22 +0100901 spec->channel_mode = preset->channel_mode;
902 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200903 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200904 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100905
Hector Martin3b315d72009-06-02 10:54:19 +0200906 if (preset->const_channel_count)
907 spec->multiout.max_channels = preset->const_channel_count;
908 else
909 spec->multiout.max_channels = spec->channel_mode[0].channels;
910 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100911
912 spec->multiout.num_dacs = preset->num_dacs;
913 spec->multiout.dac_nids = preset->dac_nids;
914 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800915 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100916 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200917
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200918 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200919 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200920 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100921 spec->input_mux = preset->input_mux;
922
923 spec->num_adc_nids = preset->num_adc_nids;
924 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100925 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100926 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100927
928 spec->unsol_event = preset->unsol_event;
929 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200930#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100931 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200932 spec->loopback.amplist = preset->loopbacks;
933#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200934
935 if (preset->setup)
936 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100937}
938
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200939/* Enable GPIO mask and set output */
940static struct hda_verb alc_gpio1_init_verbs[] = {
941 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
942 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
943 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
944 { }
945};
946
947static struct hda_verb alc_gpio2_init_verbs[] = {
948 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
949 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
950 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
951 { }
952};
953
Kailang Yangbdd148a2007-05-08 15:19:08 +0200954static struct hda_verb alc_gpio3_init_verbs[] = {
955 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
957 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
958 { }
959};
960
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200961/*
962 * Fix hardware PLL issue
963 * On some codecs, the analog PLL gating control must be off while
964 * the default value is 1.
965 */
966static void alc_fix_pll(struct hda_codec *codec)
967{
968 struct alc_spec *spec = codec->spec;
969 unsigned int val;
970
971 if (!spec->pll_nid)
972 return;
973 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
974 spec->pll_coef_idx);
975 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
976 AC_VERB_GET_PROC_COEF, 0);
977 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
978 spec->pll_coef_idx);
979 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
980 val & ~(1 << spec->pll_coef_bit));
981}
982
983static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
984 unsigned int coef_idx, unsigned int coef_bit)
985{
986 struct alc_spec *spec = codec->spec;
987 spec->pll_nid = nid;
988 spec->pll_coef_idx = coef_idx;
989 spec->pll_coef_bit = coef_bit;
990 alc_fix_pll(codec);
991}
992
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200993static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200994{
995 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200996 unsigned int nid = spec->autocfg.hp_pins[0];
997 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200998
Takashi Iwaiad87c642009-11-02 14:23:15 +0100999 if (!nid)
1000 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001001 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001002 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1003 nid = spec->autocfg.speaker_pins[i];
1004 if (!nid)
1005 break;
1006 snd_hda_codec_write(codec, nid, 0,
1007 AC_VERB_SET_PIN_WIDGET_CONTROL,
1008 spec->jack_present ? 0 : PIN_OUT);
1009 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001010}
1011
Takashi Iwai6c819492009-08-10 18:47:44 +02001012static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1013 hda_nid_t nid)
1014{
1015 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1016 int i, nums;
1017
1018 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1019 for (i = 0; i < nums; i++)
1020 if (conn[i] == nid)
1021 return i;
1022 return -1;
1023}
1024
Takashi Iwai840b64c2010-07-13 22:49:01 +02001025/* switch the current ADC according to the jack state */
1026static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1027{
1028 struct alc_spec *spec = codec->spec;
1029 unsigned int present;
1030 hda_nid_t new_adc;
1031
1032 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1033 if (present)
1034 spec->cur_adc_idx = 1;
1035 else
1036 spec->cur_adc_idx = 0;
1037 new_adc = spec->adc_nids[spec->cur_adc_idx];
1038 if (spec->cur_adc && spec->cur_adc != new_adc) {
1039 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001040 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001041 spec->cur_adc = new_adc;
1042 snd_hda_codec_setup_stream(codec, new_adc,
1043 spec->cur_adc_stream_tag, 0,
1044 spec->cur_adc_format);
1045 }
1046}
1047
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048static void alc_mic_automute(struct hda_codec *codec)
1049{
1050 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001051 struct alc_mic_route *dead, *alive;
1052 unsigned int present, type;
1053 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001054
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001055 if (!spec->auto_mic)
1056 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001057 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1058 return;
1059 if (snd_BUG_ON(!spec->adc_nids))
1060 return;
1061
Takashi Iwai840b64c2010-07-13 22:49:01 +02001062 if (spec->dual_adc_switch) {
1063 alc_dual_mic_adc_auto_switch(codec);
1064 return;
1065 }
1066
Takashi Iwai6c819492009-08-10 18:47:44 +02001067 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1068
Wu Fengguang864f92b2009-11-18 12:38:02 +08001069 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001070 if (present) {
1071 alive = &spec->ext_mic;
1072 dead = &spec->int_mic;
1073 } else {
1074 alive = &spec->int_mic;
1075 dead = &spec->ext_mic;
1076 }
1077
Takashi Iwai6c819492009-08-10 18:47:44 +02001078 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1079 if (type == AC_WID_AUD_MIX) {
1080 /* Matrix-mixer style (e.g. ALC882) */
1081 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1082 alive->mux_idx,
1083 HDA_AMP_MUTE, 0);
1084 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1085 dead->mux_idx,
1086 HDA_AMP_MUTE, HDA_AMP_MUTE);
1087 } else {
1088 /* MUX style (e.g. ALC880) */
1089 snd_hda_codec_write_cache(codec, cap_nid, 0,
1090 AC_VERB_SET_CONNECT_SEL,
1091 alive->mux_idx);
1092 }
1093
1094 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001095}
1096
Kailang Yangc9b58002007-10-16 14:30:01 +02001097/* unsolicited event for HP jack sensing */
1098static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1099{
1100 if (codec->vendor_id == 0x10ec0880)
1101 res >>= 28;
1102 else
1103 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001104 switch (res) {
1105 case ALC880_HP_EVENT:
1106 alc_automute_pin(codec);
1107 break;
1108 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001109 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001110 break;
1111 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001112}
1113
1114static void alc_inithook(struct hda_codec *codec)
1115{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001116 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001117 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001118}
1119
Kailang Yangf9423e72008-05-27 12:32:25 +02001120/* additional initialization for ALC888 variants */
1121static void alc888_coef_init(struct hda_codec *codec)
1122{
1123 unsigned int tmp;
1124
1125 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1126 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1127 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001128 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001129 /* alc888S-VC */
1130 snd_hda_codec_read(codec, 0x20, 0,
1131 AC_VERB_SET_PROC_COEF, 0x830);
1132 else
1133 /* alc888-VB */
1134 snd_hda_codec_read(codec, 0x20, 0,
1135 AC_VERB_SET_PROC_COEF, 0x3030);
1136}
1137
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001138static void alc889_coef_init(struct hda_codec *codec)
1139{
1140 unsigned int tmp;
1141
1142 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1143 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1144 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1145 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1146}
1147
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001148/* turn on/off EAPD control (only if available) */
1149static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1150{
1151 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1152 return;
1153 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1155 on ? 2 : 0);
1156}
1157
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001158static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001159{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001160 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001161
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001162 switch (type) {
1163 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001164 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1165 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001166 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001167 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1168 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001169 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001170 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1171 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001172 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001173 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001174 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001175 set_eapd(codec, 0x0f, 1);
1176 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 break;
1178 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001179 case 0x10ec0267:
1180 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001181 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001182 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001183 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001184 case 0x10ec0660:
1185 case 0x10ec0662:
1186 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001188 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001189 set_eapd(codec, 0x14, 1);
1190 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001191 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001192 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001193 switch (codec->vendor_id) {
1194 case 0x10ec0260:
1195 snd_hda_codec_write(codec, 0x1a, 0,
1196 AC_VERB_SET_COEF_INDEX, 7);
1197 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1198 AC_VERB_GET_PROC_COEF, 0);
1199 snd_hda_codec_write(codec, 0x1a, 0,
1200 AC_VERB_SET_COEF_INDEX, 7);
1201 snd_hda_codec_write(codec, 0x1a, 0,
1202 AC_VERB_SET_PROC_COEF,
1203 tmp | 0x2010);
1204 break;
1205 case 0x10ec0262:
1206 case 0x10ec0880:
1207 case 0x10ec0882:
1208 case 0x10ec0883:
1209 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001210 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001211 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001212 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001213 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001214 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001215 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001216 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001217#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001218 case 0x10ec0267:
1219 case 0x10ec0268:
1220 snd_hda_codec_write(codec, 0x20, 0,
1221 AC_VERB_SET_COEF_INDEX, 7);
1222 tmp = snd_hda_codec_read(codec, 0x20, 0,
1223 AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001225 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001226 snd_hda_codec_write(codec, 0x20, 0,
1227 AC_VERB_SET_PROC_COEF,
1228 tmp | 0x3000);
1229 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001230#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001231 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001232 break;
1233 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001234}
Kailang Yangea1fb292008-08-26 12:58:38 +02001235
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001236static void alc_init_auto_hp(struct hda_codec *codec)
1237{
1238 struct alc_spec *spec = codec->spec;
1239
1240 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001241 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242
Kailang Yangc9b58002007-10-16 14:30:01 +02001243 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001244 if (spec->autocfg.line_out_pins[0] &&
1245 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001246 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001247 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001248 else
1249 return;
1250 }
1251
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001252 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1253 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001254 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1255 AC_VERB_SET_UNSOLICITED_ENABLE,
1256 AC_USRSP_EN | ALC880_HP_EVENT);
1257 spec->unsol_event = alc_sku_unsol_event;
1258}
1259
Takashi Iwai6c819492009-08-10 18:47:44 +02001260static void alc_init_auto_mic(struct hda_codec *codec)
1261{
1262 struct alc_spec *spec = codec->spec;
1263 struct auto_pin_cfg *cfg = &spec->autocfg;
1264 hda_nid_t fixed, ext;
1265 int i;
1266
1267 /* there must be only two mic inputs exclusively */
1268 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1269 if (cfg->input_pins[i])
1270 return;
1271
1272 fixed = ext = 0;
1273 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1274 hda_nid_t nid = cfg->input_pins[i];
1275 unsigned int defcfg;
1276 if (!nid)
1277 return;
1278 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1279 switch (get_defcfg_connect(defcfg)) {
1280 case AC_JACK_PORT_FIXED:
1281 if (fixed)
1282 return; /* already occupied */
1283 fixed = nid;
1284 break;
1285 case AC_JACK_PORT_COMPLEX:
1286 if (ext)
1287 return; /* already occupied */
1288 ext = nid;
1289 break;
1290 default:
1291 return; /* invalid entry */
1292 }
1293 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001294 if (!ext || !fixed)
1295 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001296 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1297 return; /* no unsol support */
1298 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1299 ext, fixed);
1300 spec->ext_mic.pin = ext;
1301 spec->int_mic.pin = fixed;
1302 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1303 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1304 spec->auto_mic = 1;
1305 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1306 AC_VERB_SET_UNSOLICITED_ENABLE,
1307 AC_USRSP_EN | ALC880_MIC_EVENT);
1308 spec->unsol_event = alc_sku_unsol_event;
1309}
1310
Kailang Yangda00c242010-03-19 11:23:45 +01001311static int alc_auto_parse_customize_define(struct hda_codec *codec)
1312{
1313 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001314 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001315 struct alc_spec *spec = codec->spec;
1316
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001317 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1318
Kailang Yangda00c242010-03-19 11:23:45 +01001319 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001320 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001321 goto do_sku;
1322
1323 nid = 0x1d;
1324 if (codec->vendor_id == 0x10ec0260)
1325 nid = 0x17;
1326 ass = snd_hda_codec_get_pincfg(codec, nid);
1327
1328 if (!(ass & 1)) {
1329 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1330 codec->chip_name, ass);
1331 return -1;
1332 }
1333
1334 /* check sum */
1335 tmp = 0;
1336 for (i = 1; i < 16; i++) {
1337 if ((ass >> i) & 1)
1338 tmp++;
1339 }
1340 if (((ass >> 16) & 0xf) != tmp)
1341 return -1;
1342
1343 spec->cdefine.port_connectivity = ass >> 30;
1344 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1345 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1346 spec->cdefine.customization = ass >> 8;
1347do_sku:
1348 spec->cdefine.sku_cfg = ass;
1349 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1350 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1351 spec->cdefine.swap = (ass & 0x2) >> 1;
1352 spec->cdefine.override = ass & 0x1;
1353
1354 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1355 nid, spec->cdefine.sku_cfg);
1356 snd_printd("SKU: port_connectivity=0x%x\n",
1357 spec->cdefine.port_connectivity);
1358 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1359 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1360 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1361 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1362 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1363 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1364 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1365
1366 return 0;
1367}
1368
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001369/* check subsystem ID and set up device-specific initialization;
1370 * return 1 if initialized, 0 if invalid SSID
1371 */
1372/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1373 * 31 ~ 16 : Manufacture ID
1374 * 15 ~ 8 : SKU ID
1375 * 7 ~ 0 : Assembly ID
1376 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1377 */
1378static int alc_subsystem_id(struct hda_codec *codec,
1379 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001380 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001381{
1382 unsigned int ass, tmp, i;
1383 unsigned nid;
1384 struct alc_spec *spec = codec->spec;
1385
1386 ass = codec->subsystem_id & 0xffff;
1387 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1388 goto do_sku;
1389
1390 /* invalid SSID, check the special NID pin defcfg instead */
1391 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001392 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001393 * 29~21 : reserve
1394 * 20 : PCBEEP input
1395 * 19~16 : Check sum (15:1)
1396 * 15~1 : Custom
1397 * 0 : override
1398 */
1399 nid = 0x1d;
1400 if (codec->vendor_id == 0x10ec0260)
1401 nid = 0x17;
1402 ass = snd_hda_codec_get_pincfg(codec, nid);
1403 snd_printd("realtek: No valid SSID, "
1404 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001405 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001406 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001407 return 0;
1408 if ((ass >> 30) != 1) /* no physical connection */
1409 return 0;
1410
1411 /* check sum */
1412 tmp = 0;
1413 for (i = 1; i < 16; i++) {
1414 if ((ass >> i) & 1)
1415 tmp++;
1416 }
1417 if (((ass >> 16) & 0xf) != tmp)
1418 return 0;
1419do_sku:
1420 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1421 ass & 0xffff, codec->vendor_id);
1422 /*
1423 * 0 : override
1424 * 1 : Swap Jack
1425 * 2 : 0 --> Desktop, 1 --> Laptop
1426 * 3~5 : External Amplifier control
1427 * 7~6 : Reserved
1428 */
1429 tmp = (ass & 0x38) >> 3; /* external Amp control */
1430 switch (tmp) {
1431 case 1:
1432 spec->init_amp = ALC_INIT_GPIO1;
1433 break;
1434 case 3:
1435 spec->init_amp = ALC_INIT_GPIO2;
1436 break;
1437 case 7:
1438 spec->init_amp = ALC_INIT_GPIO3;
1439 break;
1440 case 5:
1441 spec->init_amp = ALC_INIT_DEFAULT;
1442 break;
1443 }
1444
1445 /* is laptop or Desktop and enable the function "Mute internal speaker
1446 * when the external headphone out jack is plugged"
1447 */
1448 if (!(ass & 0x8000))
1449 return 1;
1450 /*
1451 * 10~8 : Jack location
1452 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1453 * 14~13: Resvered
1454 * 15 : 1 --> enable the function "Mute internal speaker
1455 * when the external headphone out jack is plugged"
1456 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001457 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001458 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001459 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1460 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001461 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001462 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001463 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001464 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001465 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001466 else if (tmp == 3)
1467 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001468 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001469 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001470 for (i = 0; i < spec->autocfg.line_outs; i++)
1471 if (spec->autocfg.line_out_pins[i] == nid)
1472 return 1;
1473 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001474 }
1475
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001476 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001477 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001478 return 1;
1479}
Kailang Yangea1fb292008-08-26 12:58:38 +02001480
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001481static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001482 hda_nid_t porta, hda_nid_t porte,
1483 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001484{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001485 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001486 struct alc_spec *spec = codec->spec;
1487 snd_printd("realtek: "
1488 "Enable default setup for auto mode as fallback\n");
1489 spec->init_amp = ALC_INIT_DEFAULT;
1490 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001491 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001492 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001493}
1494
Takashi Iwai41e41f12005-06-08 14:48:49 +02001495/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001496 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001497 */
1498
1499struct alc_pincfg {
1500 hda_nid_t nid;
1501 u32 val;
1502};
1503
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001504struct alc_fixup {
1505 const struct alc_pincfg *pins;
1506 const struct hda_verb *verbs;
1507};
1508
1509static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001510 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001511 const struct alc_fixup *fix,
1512 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001513{
1514 const struct alc_pincfg *cfg;
1515
1516 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1517 if (!quirk)
1518 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001519 fix += quirk->value;
1520 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001521 if (pre_init && cfg) {
1522#ifdef CONFIG_SND_DEBUG_VERBOSE
1523 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1524 codec->chip_name, quirk->name);
1525#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001526 for (; cfg->nid; cfg++)
1527 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1528 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001529 if (!pre_init && fix->verbs) {
1530#ifdef CONFIG_SND_DEBUG_VERBOSE
1531 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1532 codec->chip_name, quirk->name);
1533#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001534 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001535 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001536}
1537
Kailang Yang274693f2009-12-03 10:07:50 +01001538static int alc_read_coef_idx(struct hda_codec *codec,
1539 unsigned int coef_idx)
1540{
1541 unsigned int val;
1542 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1543 coef_idx);
1544 val = snd_hda_codec_read(codec, 0x20, 0,
1545 AC_VERB_GET_PROC_COEF, 0);
1546 return val;
1547}
1548
Takashi Iwai757899a2010-07-30 10:48:14 +02001549/* set right pin controls for digital I/O */
1550static void alc_auto_init_digital(struct hda_codec *codec)
1551{
1552 struct alc_spec *spec = codec->spec;
1553 int i;
1554 hda_nid_t pin;
1555
1556 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1557 pin = spec->autocfg.dig_out_pins[i];
1558 if (pin) {
1559 snd_hda_codec_write(codec, pin, 0,
1560 AC_VERB_SET_PIN_WIDGET_CONTROL,
1561 PIN_OUT);
1562 }
1563 }
1564 pin = spec->autocfg.dig_in_pin;
1565 if (pin)
1566 snd_hda_codec_write(codec, pin, 0,
1567 AC_VERB_SET_PIN_WIDGET_CONTROL,
1568 PIN_IN);
1569}
1570
1571/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1572static void alc_auto_parse_digital(struct hda_codec *codec)
1573{
1574 struct alc_spec *spec = codec->spec;
1575 int i, err;
1576 hda_nid_t dig_nid;
1577
1578 /* support multiple SPDIFs; the secondary is set up as a slave */
1579 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1580 err = snd_hda_get_connections(codec,
1581 spec->autocfg.dig_out_pins[i],
1582 &dig_nid, 1);
1583 if (err < 0)
1584 continue;
1585 if (!i) {
1586 spec->multiout.dig_out_nid = dig_nid;
1587 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1588 } else {
1589 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1590 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1591 break;
1592 spec->slave_dig_outs[i - 1] = dig_nid;
1593 }
1594 }
1595
1596 if (spec->autocfg.dig_in_pin) {
1597 hda_nid_t dig_nid;
1598 err = snd_hda_get_connections(codec,
1599 spec->autocfg.dig_in_pin,
1600 &dig_nid, 1);
1601 if (err > 0)
1602 spec->dig_in_nid = dig_nid;
1603 }
1604}
1605
Takashi Iwaif95474e2007-07-10 00:47:43 +02001606/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001607 * ALC888
1608 */
1609
1610/*
1611 * 2ch mode
1612 */
1613static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1614/* Mic-in jack as mic in */
1615 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1617/* Line-in jack as Line in */
1618 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1619 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1620/* Line-Out as Front */
1621 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1622 { } /* end */
1623};
1624
1625/*
1626 * 4ch mode
1627 */
1628static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1629/* Mic-in jack as mic in */
1630 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1631 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1632/* Line-in jack as Surround */
1633 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1634 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1635/* Line-Out as Front */
1636 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1637 { } /* end */
1638};
1639
1640/*
1641 * 6ch mode
1642 */
1643static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1644/* Mic-in jack as CLFE */
1645 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1646 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1647/* Line-in jack as Surround */
1648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1650/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1651 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1652 { } /* end */
1653};
1654
1655/*
1656 * 8ch mode
1657 */
1658static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1659/* Mic-in jack as CLFE */
1660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1662/* Line-in jack as Surround */
1663 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1664 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1665/* Line-Out as Side */
1666 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1667 { } /* end */
1668};
1669
1670static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1671 { 2, alc888_4ST_ch2_intel_init },
1672 { 4, alc888_4ST_ch4_intel_init },
1673 { 6, alc888_4ST_ch6_intel_init },
1674 { 8, alc888_4ST_ch8_intel_init },
1675};
1676
1677/*
1678 * ALC888 Fujitsu Siemens Amillo xa3530
1679 */
1680
1681static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1682/* Front Mic: set to PIN_IN (empty by default) */
1683 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1684/* Connect Internal HP to Front */
1685 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1686 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1687 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1688/* Connect Bass HP to Front */
1689 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1690 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1691 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1692/* Connect Line-Out side jack (SPDIF) to Side */
1693 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1694 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1695 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1696/* Connect Mic jack to CLFE */
1697 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1698 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1699 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1700/* Connect Line-in jack to Surround */
1701 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1702 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1703 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1704/* Connect HP out jack to Front */
1705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1706 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1707 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1708/* Enable unsolicited event for HP jack and Line-out jack */
1709 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1710 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1711 {}
1712};
1713
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001714static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001715{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001716 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001717 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001718 hda_nid_t nid;
1719 int i;
1720
1721 spec->jack_present = 0;
1722 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1723 nid = spec->autocfg.hp_pins[i];
1724 if (!nid)
1725 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001726 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001727 spec->jack_present = 1;
1728 break;
1729 }
1730 }
1731
1732 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001733 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001734 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1735 nid = spec->autocfg.speaker_pins[i];
1736 if (!nid)
1737 break;
1738 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1739 HDA_AMP_MUTE, mute);
1740 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001741}
1742
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001743static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1744 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001745{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001746 if (codec->vendor_id == 0x10ec0880)
1747 res >>= 28;
1748 else
1749 res >>= 26;
1750 if (res == ALC880_HP_EVENT)
1751 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001752}
1753
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001754static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001755{
1756 struct alc_spec *spec = codec->spec;
1757
1758 spec->autocfg.hp_pins[0] = 0x15;
1759 spec->autocfg.speaker_pins[0] = 0x14;
1760 spec->autocfg.speaker_pins[1] = 0x16;
1761 spec->autocfg.speaker_pins[2] = 0x17;
1762 spec->autocfg.speaker_pins[3] = 0x19;
1763 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001764}
1765
1766static void alc889_intel_init_hook(struct hda_codec *codec)
1767{
1768 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001769 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001770}
1771
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001772static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001773{
1774 struct alc_spec *spec = codec->spec;
1775
1776 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1777 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1778 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1779 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001780}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001781
1782/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001783 * ALC888 Acer Aspire 4930G model
1784 */
1785
1786static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1787/* Front Mic: set to PIN_IN (empty by default) */
1788 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1789/* Unselect Front Mic by default in input mixer 3 */
1790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001791/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001792 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1793/* Connect Internal HP to front */
1794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1796 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1797/* Connect HP out to front */
1798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1801 { }
1802};
1803
Hector Martin3b315d72009-06-02 10:54:19 +02001804/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001805 * ALC888 Acer Aspire 6530G model
1806 */
1807
1808static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001809/* Route to built-in subwoofer as well as speakers */
1810 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1812 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001814/* Bias voltage on for external mic port */
1815 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001816/* Front Mic: set to PIN_IN (empty by default) */
1817 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1818/* Unselect Front Mic by default in input mixer 3 */
1819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001820/* Enable unsolicited event for HP jack */
1821 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1822/* Enable speaker output */
1823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001825 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001826/* Enable headphone output */
1827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001830 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001831 { }
1832};
1833
1834/*
Hector Martin018df412009-06-04 00:13:40 +02001835 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001836 */
1837
Hector Martin018df412009-06-04 00:13:40 +02001838static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001839/* Front Mic: set to PIN_IN (empty by default) */
1840 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1841/* Unselect Front Mic by default in input mixer 3 */
1842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1843/* Enable unsolicited event for HP jack */
1844 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1845/* Connect Internal Front to Front */
1846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1847 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1848 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1849/* Connect Internal Rear to Rear */
1850 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1851 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1852 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1853/* Connect Internal CLFE to CLFE */
1854 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1856 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1857/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001859 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1860 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1861/* Enable all DACs */
1862/* DAC DISABLE/MUTE 1? */
1863/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1864 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1865 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1866/* DAC DISABLE/MUTE 2? */
1867/* some bit here disables the other DACs. Init=0x4900 */
1868 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1869 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001870/* DMIC fix
1871 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1872 * which makes the stereo useless. However, either the mic or the ALC889
1873 * makes the signal become a difference/sum signal instead of standard
1874 * stereo, which is annoying. So instead we flip this bit which makes the
1875 * codec replicate the sum signal to both channels, turning it into a
1876 * normal mono mic.
1877 */
1878/* DMIC_CONTROL? Init value = 0x0001 */
1879 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1880 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001881 { }
1882};
1883
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001884static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001885 /* Front mic only available on one ADC */
1886 {
1887 .num_items = 4,
1888 .items = {
1889 { "Mic", 0x0 },
1890 { "Line", 0x2 },
1891 { "CD", 0x4 },
1892 { "Front Mic", 0xb },
1893 },
1894 },
1895 {
1896 .num_items = 3,
1897 .items = {
1898 { "Mic", 0x0 },
1899 { "Line", 0x2 },
1900 { "CD", 0x4 },
1901 },
1902 }
1903};
1904
Tony Vroond2fd4b02009-06-21 00:40:10 +01001905static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1906 /* Interal mic only available on one ADC */
1907 {
Tony Vroon684a8842009-06-26 09:27:50 +01001908 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001909 .items = {
1910 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001911 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001912 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001913 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001914 { "Int Mic", 0xb },
1915 },
1916 },
1917 {
Tony Vroon684a8842009-06-26 09:27:50 +01001918 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001919 .items = {
1920 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001921 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001922 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001923 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001924 },
1925 }
1926};
1927
Hector Martin018df412009-06-04 00:13:40 +02001928static struct hda_input_mux alc889_capture_sources[3] = {
1929 /* Digital mic only available on first "ADC" */
1930 {
1931 .num_items = 5,
1932 .items = {
1933 { "Mic", 0x0 },
1934 { "Line", 0x2 },
1935 { "CD", 0x4 },
1936 { "Front Mic", 0xb },
1937 { "Input Mix", 0xa },
1938 },
1939 },
1940 {
1941 .num_items = 4,
1942 .items = {
1943 { "Mic", 0x0 },
1944 { "Line", 0x2 },
1945 { "CD", 0x4 },
1946 { "Input Mix", 0xa },
1947 },
1948 },
1949 {
1950 .num_items = 4,
1951 .items = {
1952 { "Mic", 0x0 },
1953 { "Line", 0x2 },
1954 { "CD", 0x4 },
1955 { "Input Mix", 0xa },
1956 },
1957 }
1958};
1959
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001960static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001961 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1962 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1963 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1964 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1965 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1966 HDA_OUTPUT),
1967 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1968 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1969 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1970 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1971 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1974 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1975 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1976 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1977 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001979 { } /* end */
1980};
1981
Hector Martin556eea92009-12-20 22:51:23 +01001982static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1983 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1984 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1985 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1986 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1987 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1988 HDA_OUTPUT),
1989 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1990 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1991 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1996 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1997 { } /* end */
1998};
1999
2000
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002001static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002002{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002003 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002004
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002005 spec->autocfg.hp_pins[0] = 0x15;
2006 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002007 spec->autocfg.speaker_pins[1] = 0x16;
2008 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002009}
2010
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002011static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002012{
2013 struct alc_spec *spec = codec->spec;
2014
2015 spec->autocfg.hp_pins[0] = 0x15;
2016 spec->autocfg.speaker_pins[0] = 0x14;
2017 spec->autocfg.speaker_pins[1] = 0x16;
2018 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002019}
2020
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002021static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002022{
2023 struct alc_spec *spec = codec->spec;
2024
2025 spec->autocfg.hp_pins[0] = 0x15;
2026 spec->autocfg.speaker_pins[0] = 0x14;
2027 spec->autocfg.speaker_pins[1] = 0x16;
2028 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002029}
2030
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002031/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002032 * ALC880 3-stack model
2033 *
2034 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002035 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2036 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002037 */
2038
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002039static hda_nid_t alc880_dac_nids[4] = {
2040 /* front, rear, clfe, rear_surr */
2041 0x02, 0x05, 0x04, 0x03
2042};
2043
2044static hda_nid_t alc880_adc_nids[3] = {
2045 /* ADC0-2 */
2046 0x07, 0x08, 0x09,
2047};
2048
2049/* The datasheet says the node 0x07 is connected from inputs,
2050 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002051 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002053static hda_nid_t alc880_adc_nids_alt[2] = {
2054 /* ADC1-2 */
2055 0x08, 0x09,
2056};
2057
2058#define ALC880_DIGOUT_NID 0x06
2059#define ALC880_DIGIN_NID 0x0a
2060
2061static struct hda_input_mux alc880_capture_source = {
2062 .num_items = 4,
2063 .items = {
2064 { "Mic", 0x0 },
2065 { "Front Mic", 0x3 },
2066 { "Line", 0x2 },
2067 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002068 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002069};
2070
2071/* channel source setting (2/6 channel selection for 3-stack) */
2072/* 2ch mode */
2073static struct hda_verb alc880_threestack_ch2_init[] = {
2074 /* set line-in to input, mute it */
2075 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2076 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2077 /* set mic-in to input vref 80%, mute it */
2078 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2079 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002080 { } /* end */
2081};
2082
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083/* 6ch mode */
2084static struct hda_verb alc880_threestack_ch6_init[] = {
2085 /* set line-in to output, unmute it */
2086 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2087 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2088 /* set mic-in to output, unmute it */
2089 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2090 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2091 { } /* end */
2092};
2093
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002094static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 { 2, alc880_threestack_ch2_init },
2096 { 6, alc880_threestack_ch6_init },
2097};
2098
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002099static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002101 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002102 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002103 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002104 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2105 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002106 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2107 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2113 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2114 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2115 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002117 {
2118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2119 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002120 .info = alc_ch_mode_info,
2121 .get = alc_ch_mode_get,
2122 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002123 },
2124 { } /* end */
2125};
2126
2127/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002128static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2129 struct snd_ctl_elem_info *uinfo)
2130{
2131 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2132 struct alc_spec *spec = codec->spec;
2133 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002134
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002135 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002136 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2137 HDA_INPUT);
2138 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002139 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002140 return err;
2141}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002143static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2144 unsigned int size, unsigned int __user *tlv)
2145{
2146 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2147 struct alc_spec *spec = codec->spec;
2148 int err;
2149
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002150 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002151 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2152 HDA_INPUT);
2153 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002154 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002155 return err;
2156}
2157
2158typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2159 struct snd_ctl_elem_value *ucontrol);
2160
2161static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2162 struct snd_ctl_elem_value *ucontrol,
2163 getput_call_t func)
2164{
2165 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2166 struct alc_spec *spec = codec->spec;
2167 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2168 int err;
2169
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002170 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002171 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2172 3, 0, HDA_INPUT);
2173 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002174 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002175 return err;
2176}
2177
2178static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2179 struct snd_ctl_elem_value *ucontrol)
2180{
2181 return alc_cap_getput_caller(kcontrol, ucontrol,
2182 snd_hda_mixer_amp_volume_get);
2183}
2184
2185static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2186 struct snd_ctl_elem_value *ucontrol)
2187{
2188 return alc_cap_getput_caller(kcontrol, ucontrol,
2189 snd_hda_mixer_amp_volume_put);
2190}
2191
2192/* capture mixer elements */
2193#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2194
2195static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2196 struct snd_ctl_elem_value *ucontrol)
2197{
2198 return alc_cap_getput_caller(kcontrol, ucontrol,
2199 snd_hda_mixer_amp_switch_get);
2200}
2201
2202static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2203 struct snd_ctl_elem_value *ucontrol)
2204{
2205 return alc_cap_getput_caller(kcontrol, ucontrol,
2206 snd_hda_mixer_amp_switch_put);
2207}
2208
Takashi Iwaia23b6882009-03-23 15:21:36 +01002209#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002210 { \
2211 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2212 .name = "Capture Switch", \
2213 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2214 .count = num, \
2215 .info = alc_cap_sw_info, \
2216 .get = alc_cap_sw_get, \
2217 .put = alc_cap_sw_put, \
2218 }, \
2219 { \
2220 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2221 .name = "Capture Volume", \
2222 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2223 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2224 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2225 .count = num, \
2226 .info = alc_cap_vol_info, \
2227 .get = alc_cap_vol_get, \
2228 .put = alc_cap_vol_put, \
2229 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002230 }
2231
2232#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002233 { \
2234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2235 /* .name = "Capture Source", */ \
2236 .name = "Input Source", \
2237 .count = num, \
2238 .info = alc_mux_enum_info, \
2239 .get = alc_mux_enum_get, \
2240 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002241 }
2242
2243#define DEFINE_CAPMIX(num) \
2244static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2245 _DEFINE_CAPMIX(num), \
2246 _DEFINE_CAPSRC(num), \
2247 { } /* end */ \
2248}
2249
2250#define DEFINE_CAPMIX_NOSRC(num) \
2251static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2252 _DEFINE_CAPMIX(num), \
2253 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002254}
2255
2256/* up to three ADCs */
2257DEFINE_CAPMIX(1);
2258DEFINE_CAPMIX(2);
2259DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002260DEFINE_CAPMIX_NOSRC(1);
2261DEFINE_CAPMIX_NOSRC(2);
2262DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002263
2264/*
2265 * ALC880 5-stack model
2266 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002267 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2268 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002269 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2270 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2271 */
2272
2273/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002274static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002276 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 { } /* end */
2278};
2279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002280/* channel source setting (6/8 channel selection for 5-stack) */
2281/* 6ch mode */
2282static struct hda_verb alc880_fivestack_ch6_init[] = {
2283 /* set line-in to input, mute it */
2284 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2285 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002286 { } /* end */
2287};
2288
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002289/* 8ch mode */
2290static struct hda_verb alc880_fivestack_ch8_init[] = {
2291 /* set line-in to output, unmute it */
2292 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2293 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2294 { } /* end */
2295};
2296
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002297static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002298 { 6, alc880_fivestack_ch6_init },
2299 { 8, alc880_fivestack_ch8_init },
2300};
2301
2302
2303/*
2304 * ALC880 6-stack model
2305 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002306 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2307 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2309 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2310 */
2311
2312static hda_nid_t alc880_6st_dac_nids[4] = {
2313 /* front, rear, clfe, rear_surr */
2314 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002315};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002316
2317static struct hda_input_mux alc880_6stack_capture_source = {
2318 .num_items = 4,
2319 .items = {
2320 { "Mic", 0x0 },
2321 { "Front Mic", 0x1 },
2322 { "Line", 0x2 },
2323 { "CD", 0x4 },
2324 },
2325};
2326
2327/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002328static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002329 { 8, NULL },
2330};
2331
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002332static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002333 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002334 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002335 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002336 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002337 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2338 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002339 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2340 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002341 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002342 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002343 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2344 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2345 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2346 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2348 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2349 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2350 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002351 {
2352 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2353 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002354 .info = alc_ch_mode_info,
2355 .get = alc_ch_mode_get,
2356 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002357 },
2358 { } /* end */
2359};
2360
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002361
2362/*
2363 * ALC880 W810 model
2364 *
2365 * W810 has rear IO for:
2366 * Front (DAC 02)
2367 * Surround (DAC 03)
2368 * Center/LFE (DAC 04)
2369 * Digital out (06)
2370 *
2371 * The system also has a pair of internal speakers, and a headphone jack.
2372 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002373 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002374 * There is a variable resistor to control the speaker or headphone
2375 * volume. This is a hardware-only device without a software API.
2376 *
2377 * Plugging headphones in will disable the internal speakers. This is
2378 * implemented in hardware, not via the driver using jack sense. In
2379 * a similar fashion, plugging into the rear socket marked "front" will
2380 * disable both the speakers and headphones.
2381 *
2382 * For input, there's a microphone jack, and an "audio in" jack.
2383 * These may not do anything useful with this driver yet, because I
2384 * haven't setup any initialization verbs for these yet...
2385 */
2386
2387static hda_nid_t alc880_w810_dac_nids[3] = {
2388 /* front, rear/surround, clfe */
2389 0x02, 0x03, 0x04
2390};
2391
2392/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002393static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002394 { 6, NULL }
2395};
2396
2397/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002398static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002399 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002400 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002401 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002402 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2404 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002405 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2406 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2408 { } /* end */
2409};
2410
2411
2412/*
2413 * Z710V model
2414 *
2415 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002416 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2417 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002418 */
2419
2420static hda_nid_t alc880_z71v_dac_nids[1] = {
2421 0x02
2422};
2423#define ALC880_Z71V_HP_DAC 0x03
2424
2425/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002426static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002427 { 2, NULL }
2428};
2429
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002430static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002431 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002432 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002433 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002434 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002435 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2436 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2437 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2438 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2439 { } /* end */
2440};
2441
2442
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443/*
2444 * ALC880 F1734 model
2445 *
2446 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2447 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2448 */
2449
2450static hda_nid_t alc880_f1734_dac_nids[1] = {
2451 0x03
2452};
2453#define ALC880_F1734_HP_DAC 0x02
2454
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002455static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002456 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002457 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002458 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2459 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002460 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2461 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002464 { } /* end */
2465};
2466
Takashi Iwai937b4162008-02-11 14:52:36 +01002467static struct hda_input_mux alc880_f1734_capture_source = {
2468 .num_items = 2,
2469 .items = {
2470 { "Mic", 0x1 },
2471 { "CD", 0x4 },
2472 },
2473};
2474
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002475
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002476/*
2477 * ALC880 ASUS model
2478 *
2479 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2480 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2481 * Mic = 0x18, Line = 0x1a
2482 */
2483
2484#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2485#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2486
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002487static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002488 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002489 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002490 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002491 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002492 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2493 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002494 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2495 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002496 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2497 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2498 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2499 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002502 {
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2504 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002505 .info = alc_ch_mode_info,
2506 .get = alc_ch_mode_get,
2507 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002508 },
2509 { } /* end */
2510};
2511
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002512/*
2513 * ALC880 ASUS W1V model
2514 *
2515 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2516 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2517 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2518 */
2519
2520/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002521static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002522 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2523 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002524 { } /* end */
2525};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002526
Kailang Yangdf694da2005-12-05 19:42:22 +01002527/* TCL S700 */
2528static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2529 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2530 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2532 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2533 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2534 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2535 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2536 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2537 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002538 { } /* end */
2539};
2540
Kailang Yangccc656c2006-10-17 12:32:26 +02002541/* Uniwill */
2542static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2544 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2545 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2546 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002547 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2548 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2549 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2550 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2551 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2552 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2553 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2554 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2557 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2558 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002559 {
2560 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2561 .name = "Channel Mode",
2562 .info = alc_ch_mode_info,
2563 .get = alc_ch_mode_get,
2564 .put = alc_ch_mode_put,
2565 },
2566 { } /* end */
2567};
2568
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002569static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2571 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2574 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2575 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2576 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2577 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2578 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2579 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2580 { } /* end */
2581};
2582
Kailang Yangccc656c2006-10-17 12:32:26 +02002583static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002584 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2585 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2586 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2587 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2590 { } /* end */
2591};
2592
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002594 * virtual master controls
2595 */
2596
2597/*
2598 * slave controls for virtual master
2599 */
2600static const char *alc_slave_vols[] = {
2601 "Front Playback Volume",
2602 "Surround Playback Volume",
2603 "Center Playback Volume",
2604 "LFE Playback Volume",
2605 "Side Playback Volume",
2606 "Headphone Playback Volume",
2607 "Speaker Playback Volume",
2608 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002609 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002610 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002611 NULL,
2612};
2613
2614static const char *alc_slave_sws[] = {
2615 "Front Playback Switch",
2616 "Surround Playback Switch",
2617 "Center Playback Switch",
2618 "LFE Playback Switch",
2619 "Side Playback Switch",
2620 "Headphone Playback Switch",
2621 "Speaker Playback Switch",
2622 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002623 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002624 "Line-Out Playback Switch",
2625 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002626 NULL,
2627};
2628
2629/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002632
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002633#define NID_MAPPING (-1)
2634
2635#define SUBDEV_SPEAKER_ (0 << 6)
2636#define SUBDEV_HP_ (1 << 6)
2637#define SUBDEV_LINE_ (2 << 6)
2638#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2639#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2640#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2641
Takashi Iwai603c4012008-07-30 15:01:44 +02002642static void alc_free_kctls(struct hda_codec *codec);
2643
Takashi Iwai67d634c2009-11-16 15:35:59 +01002644#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002645/* additional beep mixers; the actual parameters are overwritten at build */
2646static struct snd_kcontrol_new alc_beep_mixer[] = {
2647 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002648 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002649 { } /* end */
2650};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002651#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002652
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653static int alc_build_controls(struct hda_codec *codec)
2654{
2655 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002656 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002657 struct snd_kcontrol_new *knew;
2658 int i, j, err;
2659 unsigned int u;
2660 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661
2662 for (i = 0; i < spec->num_mixers; i++) {
2663 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2664 if (err < 0)
2665 return err;
2666 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002667 if (spec->cap_mixer) {
2668 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2669 if (err < 0)
2670 return err;
2671 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002673 err = snd_hda_create_spdif_out_ctls(codec,
2674 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 if (err < 0)
2676 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002677 if (!spec->no_analog) {
2678 err = snd_hda_create_spdif_share_sw(codec,
2679 &spec->multiout);
2680 if (err < 0)
2681 return err;
2682 spec->multiout.share_spdif = 1;
2683 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002684 }
2685 if (spec->dig_in_nid) {
2686 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2687 if (err < 0)
2688 return err;
2689 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002690
Takashi Iwai67d634c2009-11-16 15:35:59 +01002691#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002692 /* create beep controls if needed */
2693 if (spec->beep_amp) {
2694 struct snd_kcontrol_new *knew;
2695 for (knew = alc_beep_mixer; knew->name; knew++) {
2696 struct snd_kcontrol *kctl;
2697 kctl = snd_ctl_new1(knew, codec);
2698 if (!kctl)
2699 return -ENOMEM;
2700 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002701 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002702 if (err < 0)
2703 return err;
2704 }
2705 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002706#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002707
Takashi Iwai2134ea42008-01-10 16:53:55 +01002708 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002709 if (!spec->no_analog &&
2710 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002711 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002712 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002713 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002714 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002715 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002716 if (err < 0)
2717 return err;
2718 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002719 if (!spec->no_analog &&
2720 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002721 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2722 NULL, alc_slave_sws);
2723 if (err < 0)
2724 return err;
2725 }
2726
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002727 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002728 if (spec->capsrc_nids || spec->adc_nids) {
2729 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2730 if (!kctl)
2731 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2732 for (i = 0; kctl && i < kctl->count; i++) {
2733 hda_nid_t *nids = spec->capsrc_nids;
2734 if (!nids)
2735 nids = spec->adc_nids;
2736 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2737 if (err < 0)
2738 return err;
2739 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002740 }
2741 if (spec->cap_mixer) {
2742 const char *kname = kctl ? kctl->id.name : NULL;
2743 for (knew = spec->cap_mixer; knew->name; knew++) {
2744 if (kname && strcmp(knew->name, kname) == 0)
2745 continue;
2746 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2747 for (i = 0; kctl && i < kctl->count; i++) {
2748 err = snd_hda_add_nid(codec, kctl, i,
2749 spec->adc_nids[i]);
2750 if (err < 0)
2751 return err;
2752 }
2753 }
2754 }
2755
2756 /* other nid->control mapping */
2757 for (i = 0; i < spec->num_mixers; i++) {
2758 for (knew = spec->mixers[i]; knew->name; knew++) {
2759 if (knew->iface != NID_MAPPING)
2760 continue;
2761 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2762 if (kctl == NULL)
2763 continue;
2764 u = knew->subdevice;
2765 for (j = 0; j < 4; j++, u >>= 8) {
2766 nid = u & 0x3f;
2767 if (nid == 0)
2768 continue;
2769 switch (u & 0xc0) {
2770 case SUBDEV_SPEAKER_:
2771 nid = spec->autocfg.speaker_pins[nid];
2772 break;
2773 case SUBDEV_LINE_:
2774 nid = spec->autocfg.line_out_pins[nid];
2775 break;
2776 case SUBDEV_HP_:
2777 nid = spec->autocfg.hp_pins[nid];
2778 break;
2779 default:
2780 continue;
2781 }
2782 err = snd_hda_add_nid(codec, kctl, 0, nid);
2783 if (err < 0)
2784 return err;
2785 }
2786 u = knew->private_value;
2787 for (j = 0; j < 4; j++, u >>= 8) {
2788 nid = u & 0xff;
2789 if (nid == 0)
2790 continue;
2791 err = snd_hda_add_nid(codec, kctl, 0, nid);
2792 if (err < 0)
2793 return err;
2794 }
2795 }
2796 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002797
2798 alc_free_kctls(codec); /* no longer needed */
2799
Linus Torvalds1da177e2005-04-16 15:20:36 -07002800 return 0;
2801}
2802
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803
Linus Torvalds1da177e2005-04-16 15:20:36 -07002804/*
2805 * initialize the codec volumes, etc
2806 */
2807
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002808/*
2809 * generic initialization of ADC, input mixers and output mixers
2810 */
2811static struct hda_verb alc880_volume_init_verbs[] = {
2812 /*
2813 * Unmute ADC0-2 and set the default input to mic-in
2814 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002815 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002816 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002817 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002819 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2823 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002824 * Note: PASD motherboards uses the Line In 2 as the input for front
2825 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002826 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002827 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2829 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2830 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2831 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2833 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002835
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002836 /*
2837 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002839 /* set vol=0 to output mixers */
2840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2843 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2844 /* set up input amps for analog loopback */
2845 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2847 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002848 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2849 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002850 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2851 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002852 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854
2855 { }
2856};
2857
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002858/*
2859 * 3-stack pin configuration:
2860 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2861 */
2862static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2863 /*
2864 * preset connection lists of input pins
2865 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2866 */
2867 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2868 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2869 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2870
2871 /*
2872 * Set pin mode and muting
2873 */
2874 /* set front pin widgets 0x14 for output */
2875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2876 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2877 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2878 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2880 /* Mic2 (as headphone out) for HP output */
2881 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 /* Line In pin widget for input */
2884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2886 /* Line2 (as front mic) pin widget for input and vref at 80% */
2887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2888 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2889 /* CD pin widget for input */
2890 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2891
2892 { }
2893};
2894
2895/*
2896 * 5-stack pin configuration:
2897 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2898 * line-in/side = 0x1a, f-mic = 0x1b
2899 */
2900static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2901 /*
2902 * preset connection lists of input pins
2903 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2904 */
2905 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2906 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2907
2908 /*
2909 * Set pin mode and muting
2910 */
2911 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002912 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2914 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2915 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002916 /* unmute pins for output (no gain on this amp) */
2917 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2921
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002924 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2925 /* Mic2 (as headphone out) for HP output */
2926 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928 /* Line In pin widget for input */
2929 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2931 /* Line2 (as front mic) pin widget for input and vref at 80% */
2932 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2933 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2934 /* CD pin widget for input */
2935 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936
2937 { }
2938};
2939
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002940/*
2941 * W810 pin configuration:
2942 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2943 */
2944static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002945 /* hphone/speaker input selector: front DAC */
2946 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2947
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002948 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2949 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2950 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2951 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2952 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2953 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2954
2955 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002956 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 { }
2959};
2960
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002961/*
2962 * Z71V pin configuration:
2963 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2964 */
2965static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002966 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002970
Takashi Iwai16ded522005-06-10 19:58:24 +02002971 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002974 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002975
2976 { }
2977};
2978
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002979/*
2980 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002981 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2982 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002983 */
2984static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2985 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2986
Takashi Iwai16ded522005-06-10 19:58:24 +02002987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002990 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002992 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002993 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2995
Takashi Iwai16ded522005-06-10 19:58:24 +02002996 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002997 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002998 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003000 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003001 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003003 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003004 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003005
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003006 { }
3007};
Takashi Iwai16ded522005-06-10 19:58:24 +02003008
Kailang Yangccc656c2006-10-17 12:32:26 +02003009/*
3010 * Uniwill pin configuration:
3011 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3012 * line = 0x1a
3013 */
3014static struct hda_verb alc880_uniwill_init_verbs[] = {
3015 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3016
3017 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3020 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3021 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3022 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3029 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3031
3032 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3034 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3035 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3036 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3037 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3038 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3039 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3040 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3041
3042 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3043 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3044
3045 { }
3046};
3047
3048/*
3049* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003050* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003051 */
3052static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3053 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3054
3055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3059 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3060 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3063 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3064 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3066 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3067
3068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3070 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3071 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3072 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3073 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3074
3075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3076 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3077
3078 { }
3079};
3080
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003081static struct hda_verb alc880_beep_init_verbs[] = {
3082 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3083 { }
3084};
3085
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003086/* auto-toggle front mic */
3087static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3088{
3089 unsigned int present;
3090 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003091
Wu Fengguang864f92b2009-11-18 12:38:02 +08003092 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003093 bits = present ? HDA_AMP_MUTE : 0;
3094 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003095}
3096
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003097static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003098{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003099 struct alc_spec *spec = codec->spec;
3100
3101 spec->autocfg.hp_pins[0] = 0x14;
3102 spec->autocfg.speaker_pins[0] = 0x15;
3103 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003104}
3105
3106static void alc880_uniwill_init_hook(struct hda_codec *codec)
3107{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003108 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003109 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003110}
3111
3112static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3113 unsigned int res)
3114{
3115 /* Looks like the unsol event is incompatible with the standard
3116 * definition. 4bit tag is placed at 28 bit!
3117 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003118 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003119 case ALC880_MIC_EVENT:
3120 alc880_uniwill_mic_automute(codec);
3121 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003122 default:
3123 alc_automute_amp_unsol_event(codec, res);
3124 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003125 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003126}
3127
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003128static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003129{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003130 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003131
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003132 spec->autocfg.hp_pins[0] = 0x14;
3133 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003134}
3135
3136static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3137{
3138 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003139
Kailang Yangccc656c2006-10-17 12:32:26 +02003140 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003141 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3142 present &= HDA_AMP_VOLMASK;
3143 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3144 HDA_AMP_VOLMASK, present);
3145 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3146 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003147}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003148
Kailang Yangccc656c2006-10-17 12:32:26 +02003149static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3150 unsigned int res)
3151{
3152 /* Looks like the unsol event is incompatible with the standard
3153 * definition. 4bit tag is placed at 28 bit!
3154 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003155 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003156 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003157 else
3158 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003159}
3160
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003161/*
3162 * F1734 pin configuration:
3163 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3164 */
3165static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003166 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3168 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3169 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3170 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3171
3172 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3173 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3176
3177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003179 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003180 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3183 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003186
Takashi Iwai937b4162008-02-11 14:52:36 +01003187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3188 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3189
Takashi Iwai16ded522005-06-10 19:58:24 +02003190 { }
3191};
3192
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193/*
3194 * ASUS pin configuration:
3195 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3196 */
3197static struct hda_verb alc880_pin_asus_init_verbs[] = {
3198 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3199 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3200 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3201 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3202
3203 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3204 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3205 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3206 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3207 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3209 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3211
3212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3213 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3214 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3215 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3216 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3218 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3220 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003221
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003222 { }
3223};
3224
3225/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003226#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3227#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003228#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229
Kailang Yangdf694da2005-12-05 19:42:22 +01003230/* Clevo m520g init */
3231static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3232 /* headphone output */
3233 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3234 /* line-out */
3235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3237 /* Line-in */
3238 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3239 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3240 /* CD */
3241 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3242 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243 /* Mic1 (rear panel) */
3244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3245 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3246 /* Mic2 (front panel) */
3247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3248 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3249 /* headphone */
3250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3252 /* change to EAPD mode */
3253 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3254 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3255
3256 { }
3257};
3258
3259static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003260 /* change to EAPD mode */
3261 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3262 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3263
Kailang Yangdf694da2005-12-05 19:42:22 +01003264 /* Headphone output */
3265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3266 /* Front output*/
3267 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3268 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3269
3270 /* Line In pin widget for input */
3271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3272 /* CD pin widget for input */
3273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3274 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3276
3277 /* change to EAPD mode */
3278 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3279 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3280
3281 { }
3282};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283
3284/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003285 * LG m1 express dual
3286 *
3287 * Pin assignment:
3288 * Rear Line-In/Out (blue): 0x14
3289 * Build-in Mic-In: 0x15
3290 * Speaker-out: 0x17
3291 * HP-Out (green): 0x1b
3292 * Mic-In/Out (red): 0x19
3293 * SPDIF-Out: 0x1e
3294 */
3295
3296/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3297static hda_nid_t alc880_lg_dac_nids[3] = {
3298 0x05, 0x02, 0x03
3299};
3300
3301/* seems analog CD is not working */
3302static struct hda_input_mux alc880_lg_capture_source = {
3303 .num_items = 3,
3304 .items = {
3305 { "Mic", 0x1 },
3306 { "Line", 0x5 },
3307 { "Internal Mic", 0x6 },
3308 },
3309};
3310
3311/* 2,4,6 channel modes */
3312static struct hda_verb alc880_lg_ch2_init[] = {
3313 /* set line-in and mic-in to input */
3314 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3315 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3316 { }
3317};
3318
3319static struct hda_verb alc880_lg_ch4_init[] = {
3320 /* set line-in to out and mic-in to input */
3321 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3322 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3323 { }
3324};
3325
3326static struct hda_verb alc880_lg_ch6_init[] = {
3327 /* set line-in and mic-in to output */
3328 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3329 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3330 { }
3331};
3332
3333static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3334 { 2, alc880_lg_ch2_init },
3335 { 4, alc880_lg_ch4_init },
3336 { 6, alc880_lg_ch6_init },
3337};
3338
3339static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003340 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3341 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003342 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3343 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3344 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3345 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3346 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3347 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3349 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3352 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3353 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3354 {
3355 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3356 .name = "Channel Mode",
3357 .info = alc_ch_mode_info,
3358 .get = alc_ch_mode_get,
3359 .put = alc_ch_mode_put,
3360 },
3361 { } /* end */
3362};
3363
3364static struct hda_verb alc880_lg_init_verbs[] = {
3365 /* set capture source to mic-in */
3366 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3367 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3369 /* mute all amp mixer inputs */
3370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003373 /* line-in to input */
3374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3375 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3376 /* built-in mic */
3377 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3378 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3379 /* speaker-out */
3380 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3381 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 /* mic-in to input */
3383 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3384 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3385 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3386 /* HP-out */
3387 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3388 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3389 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3390 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003391 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003392 { }
3393};
3394
3395/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003396static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003398 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003400 spec->autocfg.hp_pins[0] = 0x1b;
3401 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003402}
3403
3404/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003405 * LG LW20
3406 *
3407 * Pin assignment:
3408 * Speaker-out: 0x14
3409 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003410 * Built-in Mic-In: 0x19
3411 * Line-In: 0x1b
3412 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003413 * SPDIF-Out: 0x1e
3414 */
3415
Takashi Iwaid6815182006-03-23 16:06:23 +01003416static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003417 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003418 .items = {
3419 { "Mic", 0x0 },
3420 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003421 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003422 },
3423};
3424
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003425#define alc880_lg_lw_modes alc880_threestack_modes
3426
Takashi Iwaid6815182006-03-23 16:06:23 +01003427static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003428 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3429 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3430 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3431 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3432 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3433 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3434 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3435 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3436 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3437 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3440 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3441 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003442 {
3443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3444 .name = "Channel Mode",
3445 .info = alc_ch_mode_info,
3446 .get = alc_ch_mode_get,
3447 .put = alc_ch_mode_put,
3448 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003449 { } /* end */
3450};
3451
3452static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003453 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3454 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3455 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3456
Takashi Iwaid6815182006-03-23 16:06:23 +01003457 /* set capture source to mic-in */
3458 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3459 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3460 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003461 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003462 /* speaker-out */
3463 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3464 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3465 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003466 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3467 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3468 /* mic-in to input */
3469 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3470 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3471 /* built-in mic */
3472 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3473 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003475 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003476 { }
3477};
3478
3479/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003480static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003481{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003482 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003483
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003484 spec->autocfg.hp_pins[0] = 0x1b;
3485 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003486}
3487
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003488static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3489 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3490 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3492 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3493 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3494 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3495 { } /* end */
3496};
3497
3498static struct hda_input_mux alc880_medion_rim_capture_source = {
3499 .num_items = 2,
3500 .items = {
3501 { "Mic", 0x0 },
3502 { "Internal Mic", 0x1 },
3503 },
3504};
3505
3506static struct hda_verb alc880_medion_rim_init_verbs[] = {
3507 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3508
3509 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3511
3512 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3515 /* Mic2 (as headphone out) for HP output */
3516 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3517 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3518 /* Internal Speaker */
3519 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3520 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521
3522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3524
3525 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3526 { }
3527};
3528
3529/* toggle speaker-output according to the hp-jack state */
3530static void alc880_medion_rim_automute(struct hda_codec *codec)
3531{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003532 struct alc_spec *spec = codec->spec;
3533 alc_automute_amp(codec);
3534 /* toggle EAPD */
3535 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003536 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3537 else
3538 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3539}
3540
3541static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3542 unsigned int res)
3543{
3544 /* Looks like the unsol event is incompatible with the standard
3545 * definition. 4bit tag is placed at 28 bit!
3546 */
3547 if ((res >> 28) == ALC880_HP_EVENT)
3548 alc880_medion_rim_automute(codec);
3549}
3550
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003551static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003552{
3553 struct alc_spec *spec = codec->spec;
3554
3555 spec->autocfg.hp_pins[0] = 0x14;
3556 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003557}
3558
Takashi Iwaicb53c622007-08-10 17:21:45 +02003559#ifdef CONFIG_SND_HDA_POWER_SAVE
3560static struct hda_amp_list alc880_loopbacks[] = {
3561 { 0x0b, HDA_INPUT, 0 },
3562 { 0x0b, HDA_INPUT, 1 },
3563 { 0x0b, HDA_INPUT, 2 },
3564 { 0x0b, HDA_INPUT, 3 },
3565 { 0x0b, HDA_INPUT, 4 },
3566 { } /* end */
3567};
3568
3569static struct hda_amp_list alc880_lg_loopbacks[] = {
3570 { 0x0b, HDA_INPUT, 1 },
3571 { 0x0b, HDA_INPUT, 6 },
3572 { 0x0b, HDA_INPUT, 7 },
3573 { } /* end */
3574};
3575#endif
3576
Takashi Iwaid6815182006-03-23 16:06:23 +01003577/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003578 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003579 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003580
Linus Torvalds1da177e2005-04-16 15:20:36 -07003581static int alc_init(struct hda_codec *codec)
3582{
3583 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003584 unsigned int i;
3585
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003586 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003587 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003588
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589 for (i = 0; i < spec->num_init_verbs; i++)
3590 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003591
3592 if (spec->init_hook)
3593 spec->init_hook(codec);
3594
Takashi Iwaiad358792010-03-30 18:00:59 +02003595#ifdef CONFIG_SND_HDA_POWER_SAVE
3596 if (codec->patch_ops.check_power_status)
3597 codec->patch_ops.check_power_status(codec, 0x01);
3598#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003599 return 0;
3600}
3601
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003602static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3603{
3604 struct alc_spec *spec = codec->spec;
3605
3606 if (spec->unsol_event)
3607 spec->unsol_event(codec, res);
3608}
3609
Takashi Iwaicb53c622007-08-10 17:21:45 +02003610#ifdef CONFIG_SND_HDA_POWER_SAVE
3611static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3612{
3613 struct alc_spec *spec = codec->spec;
3614 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3615}
3616#endif
3617
Linus Torvalds1da177e2005-04-16 15:20:36 -07003618/*
3619 * Analog playback callbacks
3620 */
3621static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3622 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003623 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003624{
3625 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003626 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3627 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628}
3629
3630static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3631 struct hda_codec *codec,
3632 unsigned int stream_tag,
3633 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003634 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003635{
3636 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003637 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3638 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003639}
3640
3641static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3642 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003643 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003644{
3645 struct alc_spec *spec = codec->spec;
3646 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3647}
3648
3649/*
3650 * Digital out
3651 */
3652static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3653 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003654 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003655{
3656 struct alc_spec *spec = codec->spec;
3657 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3658}
3659
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003660static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3661 struct hda_codec *codec,
3662 unsigned int stream_tag,
3663 unsigned int format,
3664 struct snd_pcm_substream *substream)
3665{
3666 struct alc_spec *spec = codec->spec;
3667 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3668 stream_tag, format, substream);
3669}
3670
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003671static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3672 struct hda_codec *codec,
3673 struct snd_pcm_substream *substream)
3674{
3675 struct alc_spec *spec = codec->spec;
3676 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3677}
3678
Linus Torvalds1da177e2005-04-16 15:20:36 -07003679static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3680 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003681 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003682{
3683 struct alc_spec *spec = codec->spec;
3684 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3685}
3686
3687/*
3688 * Analog capture
3689 */
Takashi Iwai63300792008-01-24 15:31:36 +01003690static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003691 struct hda_codec *codec,
3692 unsigned int stream_tag,
3693 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003694 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003695{
3696 struct alc_spec *spec = codec->spec;
3697
Takashi Iwai63300792008-01-24 15:31:36 +01003698 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003699 stream_tag, 0, format);
3700 return 0;
3701}
3702
Takashi Iwai63300792008-01-24 15:31:36 +01003703static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003704 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003705 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706{
3707 struct alc_spec *spec = codec->spec;
3708
Takashi Iwai888afa12008-03-18 09:57:50 +01003709 snd_hda_codec_cleanup_stream(codec,
3710 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003711 return 0;
3712}
3713
Takashi Iwai840b64c2010-07-13 22:49:01 +02003714/* analog capture with dynamic dual-adc changes */
3715static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3716 struct hda_codec *codec,
3717 unsigned int stream_tag,
3718 unsigned int format,
3719 struct snd_pcm_substream *substream)
3720{
3721 struct alc_spec *spec = codec->spec;
3722 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3723 spec->cur_adc_stream_tag = stream_tag;
3724 spec->cur_adc_format = format;
3725 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3726 return 0;
3727}
3728
3729static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3730 struct hda_codec *codec,
3731 struct snd_pcm_substream *substream)
3732{
3733 struct alc_spec *spec = codec->spec;
3734 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3735 spec->cur_adc = 0;
3736 return 0;
3737}
3738
3739static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3740 .substreams = 1,
3741 .channels_min = 2,
3742 .channels_max = 2,
3743 .nid = 0, /* fill later */
3744 .ops = {
3745 .prepare = dualmic_capture_pcm_prepare,
3746 .cleanup = dualmic_capture_pcm_cleanup
3747 },
3748};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003749
3750/*
3751 */
3752static struct hda_pcm_stream alc880_pcm_analog_playback = {
3753 .substreams = 1,
3754 .channels_min = 2,
3755 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003756 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003757 .ops = {
3758 .open = alc880_playback_pcm_open,
3759 .prepare = alc880_playback_pcm_prepare,
3760 .cleanup = alc880_playback_pcm_cleanup
3761 },
3762};
3763
3764static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003765 .substreams = 1,
3766 .channels_min = 2,
3767 .channels_max = 2,
3768 /* NID is set in alc_build_pcms */
3769};
3770
3771static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3772 .substreams = 1,
3773 .channels_min = 2,
3774 .channels_max = 2,
3775 /* NID is set in alc_build_pcms */
3776};
3777
3778static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3779 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003780 .channels_min = 2,
3781 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003782 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003783 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003784 .prepare = alc880_alt_capture_pcm_prepare,
3785 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003786 },
3787};
3788
3789static struct hda_pcm_stream alc880_pcm_digital_playback = {
3790 .substreams = 1,
3791 .channels_min = 2,
3792 .channels_max = 2,
3793 /* NID is set in alc_build_pcms */
3794 .ops = {
3795 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003796 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003797 .prepare = alc880_dig_playback_pcm_prepare,
3798 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003799 },
3800};
3801
3802static struct hda_pcm_stream alc880_pcm_digital_capture = {
3803 .substreams = 1,
3804 .channels_min = 2,
3805 .channels_max = 2,
3806 /* NID is set in alc_build_pcms */
3807};
3808
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003809/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003810static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003811 .substreams = 0,
3812 .channels_min = 0,
3813 .channels_max = 0,
3814};
3815
Linus Torvalds1da177e2005-04-16 15:20:36 -07003816static int alc_build_pcms(struct hda_codec *codec)
3817{
3818 struct alc_spec *spec = codec->spec;
3819 struct hda_pcm *info = spec->pcm_rec;
3820 int i;
3821
3822 codec->num_pcms = 1;
3823 codec->pcm_info = info;
3824
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003825 if (spec->no_analog)
3826 goto skip_analog;
3827
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003828 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3829 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003830 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003831
Takashi Iwai4a471b72005-12-07 13:56:29 +01003832 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003833 if (snd_BUG_ON(!spec->multiout.dac_nids))
3834 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003835 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3836 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3837 }
3838 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003839 if (snd_BUG_ON(!spec->adc_nids))
3840 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003841 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3842 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3843 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003844
Takashi Iwai4a471b72005-12-07 13:56:29 +01003845 if (spec->channel_mode) {
3846 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3847 for (i = 0; i < spec->num_channel_mode; i++) {
3848 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3849 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3850 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003851 }
3852 }
3853
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003854 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003855 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003856 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003857 snprintf(spec->stream_name_digital,
3858 sizeof(spec->stream_name_digital),
3859 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003860 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003861 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003862 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003863 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003864 if (spec->dig_out_type)
3865 info->pcm_type = spec->dig_out_type;
3866 else
3867 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003868 if (spec->multiout.dig_out_nid &&
3869 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003870 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3871 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3872 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003873 if (spec->dig_in_nid &&
3874 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003875 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3876 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3877 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003878 /* FIXME: do we need this for all Realtek codec models? */
3879 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003880 }
3881
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003882 if (spec->no_analog)
3883 return 0;
3884
Takashi Iwaie08a0072006-09-07 17:52:14 +02003885 /* If the use of more than one ADC is requested for the current
3886 * model, configure a second analog capture-only PCM.
3887 */
3888 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003889 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3890 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003891 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003892 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003893 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003894 if (spec->alt_dac_nid) {
3895 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3896 *spec->stream_analog_alt_playback;
3897 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3898 spec->alt_dac_nid;
3899 } else {
3900 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3901 alc_pcm_null_stream;
3902 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3903 }
3904 if (spec->num_adc_nids > 1) {
3905 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3906 *spec->stream_analog_alt_capture;
3907 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3908 spec->adc_nids[1];
3909 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3910 spec->num_adc_nids - 1;
3911 } else {
3912 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3913 alc_pcm_null_stream;
3914 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003915 }
3916 }
3917
Linus Torvalds1da177e2005-04-16 15:20:36 -07003918 return 0;
3919}
3920
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003921static inline void alc_shutup(struct hda_codec *codec)
3922{
3923 snd_hda_shutup_pins(codec);
3924}
3925
Takashi Iwai603c4012008-07-30 15:01:44 +02003926static void alc_free_kctls(struct hda_codec *codec)
3927{
3928 struct alc_spec *spec = codec->spec;
3929
3930 if (spec->kctls.list) {
3931 struct snd_kcontrol_new *kctl = spec->kctls.list;
3932 int i;
3933 for (i = 0; i < spec->kctls.used; i++)
3934 kfree(kctl[i].name);
3935 }
3936 snd_array_free(&spec->kctls);
3937}
3938
Linus Torvalds1da177e2005-04-16 15:20:36 -07003939static void alc_free(struct hda_codec *codec)
3940{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003941 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003942
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003943 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003944 return;
3945
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003946 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003947 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003948 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003949 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003950}
3951
Hector Martinf5de24b2009-12-20 22:51:31 +01003952#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003953static void alc_power_eapd(struct hda_codec *codec)
3954{
3955 /* We currently only handle front, HP */
3956 switch (codec->vendor_id) {
3957 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003958 set_eapd(codec, 0x0f, 0);
3959 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003960 break;
3961 case 0x10ec0262:
3962 case 0x10ec0267:
3963 case 0x10ec0268:
3964 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003965 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003966 case 0x10ec0272:
3967 case 0x10ec0660:
3968 case 0x10ec0662:
3969 case 0x10ec0663:
3970 case 0x10ec0862:
3971 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003972 set_eapd(codec, 0x14, 0);
3973 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003974 break;
3975 }
3976}
3977
Hector Martinf5de24b2009-12-20 22:51:31 +01003978static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3979{
3980 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003981 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003982 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003983 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003984 return 0;
3985}
3986#endif
3987
Takashi Iwaie044c392008-10-27 16:56:24 +01003988#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003989static int alc_resume(struct hda_codec *codec)
3990{
Takashi Iwaie044c392008-10-27 16:56:24 +01003991 codec->patch_ops.init(codec);
3992 snd_hda_codec_resume_amp(codec);
3993 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02003994#ifdef CONFIG_SND_HDA_POWER_SAVE
3995 if (codec->patch_ops.check_power_status)
3996 codec->patch_ops.check_power_status(codec, 0x01);
3997#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01003998 return 0;
3999}
Takashi Iwaie044c392008-10-27 16:56:24 +01004000#endif
4001
Linus Torvalds1da177e2005-04-16 15:20:36 -07004002/*
4003 */
4004static struct hda_codec_ops alc_patch_ops = {
4005 .build_controls = alc_build_controls,
4006 .build_pcms = alc_build_pcms,
4007 .init = alc_init,
4008 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004009 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004010#ifdef SND_HDA_NEEDS_RESUME
4011 .resume = alc_resume,
4012#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004013#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004014 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004015 .check_power_status = alc_check_power_status,
4016#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004017 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004018};
4019
Kailang Yangc027ddc2010-03-19 11:33:06 +01004020/* replace the codec chip_name with the given string */
4021static int alc_codec_rename(struct hda_codec *codec, const char *name)
4022{
4023 kfree(codec->chip_name);
4024 codec->chip_name = kstrdup(name, GFP_KERNEL);
4025 if (!codec->chip_name) {
4026 alc_free(codec);
4027 return -ENOMEM;
4028 }
4029 return 0;
4030}
4031
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004032/*
4033 * Test configuration for debugging
4034 *
4035 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4036 * enum controls.
4037 */
4038#ifdef CONFIG_SND_DEBUG
4039static hda_nid_t alc880_test_dac_nids[4] = {
4040 0x02, 0x03, 0x04, 0x05
4041};
4042
4043static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004044 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004045 .items = {
4046 { "In-1", 0x0 },
4047 { "In-2", 0x1 },
4048 { "In-3", 0x2 },
4049 { "In-4", 0x3 },
4050 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004051 { "Front", 0x5 },
4052 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004053 },
4054};
4055
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004056static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004057 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004058 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004059 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004060 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004061};
4062
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004063static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4064 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004065{
4066 static char *texts[] = {
4067 "N/A", "Line Out", "HP Out",
4068 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4069 };
4070 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4071 uinfo->count = 1;
4072 uinfo->value.enumerated.items = 8;
4073 if (uinfo->value.enumerated.item >= 8)
4074 uinfo->value.enumerated.item = 7;
4075 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4076 return 0;
4077}
4078
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004079static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4080 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004081{
4082 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4083 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4084 unsigned int pin_ctl, item = 0;
4085
4086 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4087 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4088 if (pin_ctl & AC_PINCTL_OUT_EN) {
4089 if (pin_ctl & AC_PINCTL_HP_EN)
4090 item = 2;
4091 else
4092 item = 1;
4093 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4094 switch (pin_ctl & AC_PINCTL_VREFEN) {
4095 case AC_PINCTL_VREF_HIZ: item = 3; break;
4096 case AC_PINCTL_VREF_50: item = 4; break;
4097 case AC_PINCTL_VREF_GRD: item = 5; break;
4098 case AC_PINCTL_VREF_80: item = 6; break;
4099 case AC_PINCTL_VREF_100: item = 7; break;
4100 }
4101 }
4102 ucontrol->value.enumerated.item[0] = item;
4103 return 0;
4104}
4105
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004106static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4107 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004108{
4109 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4110 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4111 static unsigned int ctls[] = {
4112 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4113 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4114 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4115 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4116 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4117 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4118 };
4119 unsigned int old_ctl, new_ctl;
4120
4121 old_ctl = snd_hda_codec_read(codec, nid, 0,
4122 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4123 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4124 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004125 int val;
4126 snd_hda_codec_write_cache(codec, nid, 0,
4127 AC_VERB_SET_PIN_WIDGET_CONTROL,
4128 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004129 val = ucontrol->value.enumerated.item[0] >= 3 ?
4130 HDA_AMP_MUTE : 0;
4131 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4132 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004133 return 1;
4134 }
4135 return 0;
4136}
4137
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004138static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4139 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004140{
4141 static char *texts[] = {
4142 "Front", "Surround", "CLFE", "Side"
4143 };
4144 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4145 uinfo->count = 1;
4146 uinfo->value.enumerated.items = 4;
4147 if (uinfo->value.enumerated.item >= 4)
4148 uinfo->value.enumerated.item = 3;
4149 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4150 return 0;
4151}
4152
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004153static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4154 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004155{
4156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4157 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4158 unsigned int sel;
4159
4160 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4161 ucontrol->value.enumerated.item[0] = sel & 3;
4162 return 0;
4163}
4164
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004165static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4166 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004167{
4168 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4169 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4170 unsigned int sel;
4171
4172 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4173 if (ucontrol->value.enumerated.item[0] != sel) {
4174 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004175 snd_hda_codec_write_cache(codec, nid, 0,
4176 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004177 return 1;
4178 }
4179 return 0;
4180}
4181
4182#define PIN_CTL_TEST(xname,nid) { \
4183 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4184 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004185 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004186 .info = alc_test_pin_ctl_info, \
4187 .get = alc_test_pin_ctl_get, \
4188 .put = alc_test_pin_ctl_put, \
4189 .private_value = nid \
4190 }
4191
4192#define PIN_SRC_TEST(xname,nid) { \
4193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4194 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004195 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004196 .info = alc_test_pin_src_info, \
4197 .get = alc_test_pin_src_get, \
4198 .put = alc_test_pin_src_put, \
4199 .private_value = nid \
4200 }
4201
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004202static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004203 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4204 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4205 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4206 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004207 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4208 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4209 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4210 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004211 PIN_CTL_TEST("Front Pin Mode", 0x14),
4212 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4213 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4214 PIN_CTL_TEST("Side Pin Mode", 0x17),
4215 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4216 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4217 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4218 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4219 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4220 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4221 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4222 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4223 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4224 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4225 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4226 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4227 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4228 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4229 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4230 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004233 {
4234 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4235 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004236 .info = alc_ch_mode_info,
4237 .get = alc_ch_mode_get,
4238 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004239 },
4240 { } /* end */
4241};
4242
4243static struct hda_verb alc880_test_init_verbs[] = {
4244 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004245 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4246 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4247 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4248 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4249 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4250 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4251 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4252 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004253 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4255 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004258 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004259 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4260 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4261 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004263 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4266 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4267 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004268 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004269 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004271 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004274 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4277 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4278 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004279 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004281 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004282 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004283 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004284 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004285 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004286 /* Analog input/passthru */
4287 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4288 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004292 { }
4293};
4294#endif
4295
Linus Torvalds1da177e2005-04-16 15:20:36 -07004296/*
4297 */
4298
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004299static const char *alc880_models[ALC880_MODEL_LAST] = {
4300 [ALC880_3ST] = "3stack",
4301 [ALC880_TCL_S700] = "tcl",
4302 [ALC880_3ST_DIG] = "3stack-digout",
4303 [ALC880_CLEVO] = "clevo",
4304 [ALC880_5ST] = "5stack",
4305 [ALC880_5ST_DIG] = "5stack-digout",
4306 [ALC880_W810] = "w810",
4307 [ALC880_Z71V] = "z71v",
4308 [ALC880_6ST] = "6stack",
4309 [ALC880_6ST_DIG] = "6stack-digout",
4310 [ALC880_ASUS] = "asus",
4311 [ALC880_ASUS_W1V] = "asus-w1v",
4312 [ALC880_ASUS_DIG] = "asus-dig",
4313 [ALC880_ASUS_DIG2] = "asus-dig2",
4314 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004315 [ALC880_UNIWILL_P53] = "uniwill-p53",
4316 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004317 [ALC880_F1734] = "F1734",
4318 [ALC880_LG] = "lg",
4319 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004320 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004321#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004322 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004324 [ALC880_AUTO] = "auto",
4325};
4326
4327static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004328 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004329 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4330 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4331 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4332 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4333 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4334 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4335 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4336 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004337 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4338 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004339 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4340 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4341 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4342 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4343 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4344 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4345 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4346 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4347 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4348 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004349 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004350 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4351 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4352 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004353 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004354 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004355 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4356 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004357 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4358 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004359 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4360 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4361 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4362 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004363 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4364 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004365 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004366 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004367 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004368 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004369 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4370 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004371 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004372 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004373 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004374 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004375 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004376 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004377 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004378 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004379 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004380 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4381 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004382 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004383 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4384 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4385 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4386 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004387 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4388 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004389 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004390 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004391 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4392 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004393 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4394 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4395 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004396 /* default Intel */
4397 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004398 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4399 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004400 {}
4401};
4402
Takashi Iwai16ded522005-06-10 19:58:24 +02004403/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004404 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004405 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004406static struct alc_config_preset alc880_presets[] = {
4407 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004408 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004409 .init_verbs = { alc880_volume_init_verbs,
4410 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004411 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004412 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004413 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4414 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004415 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004416 .input_mux = &alc880_capture_source,
4417 },
4418 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004419 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004420 .init_verbs = { alc880_volume_init_verbs,
4421 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004422 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004423 .dac_nids = alc880_dac_nids,
4424 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004425 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4426 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004427 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004428 .input_mux = &alc880_capture_source,
4429 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004430 [ALC880_TCL_S700] = {
4431 .mixers = { alc880_tcl_s700_mixer },
4432 .init_verbs = { alc880_volume_init_verbs,
4433 alc880_pin_tcl_S700_init_verbs,
4434 alc880_gpio2_init_verbs },
4435 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4436 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004437 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4438 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004439 .hp_nid = 0x03,
4440 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4441 .channel_mode = alc880_2_jack_modes,
4442 .input_mux = &alc880_capture_source,
4443 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004444 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004445 .mixers = { alc880_three_stack_mixer,
4446 alc880_five_stack_mixer},
4447 .init_verbs = { alc880_volume_init_verbs,
4448 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004449 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4450 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004451 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4452 .channel_mode = alc880_fivestack_modes,
4453 .input_mux = &alc880_capture_source,
4454 },
4455 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004456 .mixers = { alc880_three_stack_mixer,
4457 alc880_five_stack_mixer },
4458 .init_verbs = { alc880_volume_init_verbs,
4459 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004460 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4461 .dac_nids = alc880_dac_nids,
4462 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004463 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4464 .channel_mode = alc880_fivestack_modes,
4465 .input_mux = &alc880_capture_source,
4466 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004467 [ALC880_6ST] = {
4468 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004469 .init_verbs = { alc880_volume_init_verbs,
4470 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004471 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4472 .dac_nids = alc880_6st_dac_nids,
4473 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4474 .channel_mode = alc880_sixstack_modes,
4475 .input_mux = &alc880_6stack_capture_source,
4476 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004477 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004478 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 .init_verbs = { alc880_volume_init_verbs,
4480 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004481 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4482 .dac_nids = alc880_6st_dac_nids,
4483 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004484 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4485 .channel_mode = alc880_sixstack_modes,
4486 .input_mux = &alc880_6stack_capture_source,
4487 },
4488 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004490 .init_verbs = { alc880_volume_init_verbs,
4491 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004492 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004493 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4494 .dac_nids = alc880_w810_dac_nids,
4495 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004496 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4497 .channel_mode = alc880_w810_modes,
4498 .input_mux = &alc880_capture_source,
4499 },
4500 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004501 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004502 .init_verbs = { alc880_volume_init_verbs,
4503 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004504 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4505 .dac_nids = alc880_z71v_dac_nids,
4506 .dig_out_nid = ALC880_DIGOUT_NID,
4507 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004508 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4509 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004510 .input_mux = &alc880_capture_source,
4511 },
4512 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004513 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004514 .init_verbs = { alc880_volume_init_verbs,
4515 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004516 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4517 .dac_nids = alc880_f1734_dac_nids,
4518 .hp_nid = 0x02,
4519 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4520 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004521 .input_mux = &alc880_f1734_capture_source,
4522 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004523 .setup = alc880_uniwill_p53_setup,
4524 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004525 },
4526 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004527 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004528 .init_verbs = { alc880_volume_init_verbs,
4529 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004530 alc880_gpio1_init_verbs },
4531 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4532 .dac_nids = alc880_asus_dac_nids,
4533 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4534 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004535 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004536 .input_mux = &alc880_capture_source,
4537 },
4538 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004539 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004540 .init_verbs = { alc880_volume_init_verbs,
4541 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004542 alc880_gpio1_init_verbs },
4543 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4544 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004545 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4547 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004548 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004549 .input_mux = &alc880_capture_source,
4550 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004551 [ALC880_ASUS_DIG2] = {
4552 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004553 .init_verbs = { alc880_volume_init_verbs,
4554 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004555 alc880_gpio2_init_verbs }, /* use GPIO2 */
4556 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4557 .dac_nids = alc880_asus_dac_nids,
4558 .dig_out_nid = ALC880_DIGOUT_NID,
4559 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4560 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004561 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004562 .input_mux = &alc880_capture_source,
4563 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004564 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004565 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004566 .init_verbs = { alc880_volume_init_verbs,
4567 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004568 alc880_gpio1_init_verbs },
4569 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4570 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004571 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004572 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4573 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004574 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004575 .input_mux = &alc880_capture_source,
4576 },
4577 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004578 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004579 .init_verbs = { alc880_volume_init_verbs,
4580 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004581 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4582 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004583 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004584 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4585 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004586 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004587 .input_mux = &alc880_capture_source,
4588 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004589 [ALC880_UNIWILL] = {
4590 .mixers = { alc880_uniwill_mixer },
4591 .init_verbs = { alc880_volume_init_verbs,
4592 alc880_uniwill_init_verbs },
4593 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4594 .dac_nids = alc880_asus_dac_nids,
4595 .dig_out_nid = ALC880_DIGOUT_NID,
4596 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4597 .channel_mode = alc880_threestack_modes,
4598 .need_dac_fix = 1,
4599 .input_mux = &alc880_capture_source,
4600 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004601 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004602 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004603 },
4604 [ALC880_UNIWILL_P53] = {
4605 .mixers = { alc880_uniwill_p53_mixer },
4606 .init_verbs = { alc880_volume_init_verbs,
4607 alc880_uniwill_p53_init_verbs },
4608 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4609 .dac_nids = alc880_asus_dac_nids,
4610 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004611 .channel_mode = alc880_threestack_modes,
4612 .input_mux = &alc880_capture_source,
4613 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004614 .setup = alc880_uniwill_p53_setup,
4615 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004616 },
4617 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004618 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004619 .init_verbs = { alc880_volume_init_verbs,
4620 alc880_uniwill_p53_init_verbs,
4621 alc880_beep_init_verbs },
4622 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4623 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004624 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004625 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4626 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004627 .input_mux = &alc880_capture_source,
4628 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004629 .setup = alc880_uniwill_p53_setup,
4630 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004631 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004632 [ALC880_CLEVO] = {
4633 .mixers = { alc880_three_stack_mixer },
4634 .init_verbs = { alc880_volume_init_verbs,
4635 alc880_pin_clevo_init_verbs },
4636 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4637 .dac_nids = alc880_dac_nids,
4638 .hp_nid = 0x03,
4639 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4640 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004641 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004642 .input_mux = &alc880_capture_source,
4643 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004644 [ALC880_LG] = {
4645 .mixers = { alc880_lg_mixer },
4646 .init_verbs = { alc880_volume_init_verbs,
4647 alc880_lg_init_verbs },
4648 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4649 .dac_nids = alc880_lg_dac_nids,
4650 .dig_out_nid = ALC880_DIGOUT_NID,
4651 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4652 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004653 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004654 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004655 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004656 .setup = alc880_lg_setup,
4657 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004658#ifdef CONFIG_SND_HDA_POWER_SAVE
4659 .loopbacks = alc880_lg_loopbacks,
4660#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004661 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004662 [ALC880_LG_LW] = {
4663 .mixers = { alc880_lg_lw_mixer },
4664 .init_verbs = { alc880_volume_init_verbs,
4665 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004666 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004667 .dac_nids = alc880_dac_nids,
4668 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004669 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4670 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004671 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004672 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004673 .setup = alc880_lg_lw_setup,
4674 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004675 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004676 [ALC880_MEDION_RIM] = {
4677 .mixers = { alc880_medion_rim_mixer },
4678 .init_verbs = { alc880_volume_init_verbs,
4679 alc880_medion_rim_init_verbs,
4680 alc_gpio2_init_verbs },
4681 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4682 .dac_nids = alc880_dac_nids,
4683 .dig_out_nid = ALC880_DIGOUT_NID,
4684 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4685 .channel_mode = alc880_2_jack_modes,
4686 .input_mux = &alc880_medion_rim_capture_source,
4687 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004688 .setup = alc880_medion_rim_setup,
4689 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004690 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004691#ifdef CONFIG_SND_DEBUG
4692 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004693 .mixers = { alc880_test_mixer },
4694 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4696 .dac_nids = alc880_test_dac_nids,
4697 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004698 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4699 .channel_mode = alc880_test_modes,
4700 .input_mux = &alc880_test_capture_source,
4701 },
4702#endif
4703};
4704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004705/*
4706 * Automatic parse of I/O pins from the BIOS configuration
4707 */
4708
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004709enum {
4710 ALC_CTL_WIDGET_VOL,
4711 ALC_CTL_WIDGET_MUTE,
4712 ALC_CTL_BIND_MUTE,
4713};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004714static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4716 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004717 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004718};
4719
4720/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004721static int add_control(struct alc_spec *spec, int type, const char *name,
4722 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004723{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004724 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004725
Takashi Iwai603c4012008-07-30 15:01:44 +02004726 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4727 knew = snd_array_new(&spec->kctls);
4728 if (!knew)
4729 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004730 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004731 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004732 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004733 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004734 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004735 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004736 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004737 return 0;
4738}
4739
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004740static int add_control_with_pfx(struct alc_spec *spec, int type,
4741 const char *pfx, const char *dir,
4742 const char *sfx, unsigned long val)
4743{
4744 char name[32];
4745 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4746 return add_control(spec, type, name, val);
4747}
4748
4749#define add_pb_vol_ctrl(spec, type, pfx, val) \
4750 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4751#define add_pb_sw_ctrl(spec, type, pfx, val) \
4752 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004754#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4755#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4756#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4757#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004758#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4759#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4760#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4761#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4762#define ALC880_PIN_CD_NID 0x1c
4763
4764/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004765static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4766 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004767{
4768 hda_nid_t nid;
4769 int assigned[4];
4770 int i, j;
4771
4772 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004773 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774
4775 /* check the pins hardwired to audio widget */
4776 for (i = 0; i < cfg->line_outs; i++) {
4777 nid = cfg->line_out_pins[i];
4778 if (alc880_is_fixed_pin(nid)) {
4779 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004780 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004781 assigned[idx] = 1;
4782 }
4783 }
4784 /* left pins can be connect to any audio widget */
4785 for (i = 0; i < cfg->line_outs; i++) {
4786 nid = cfg->line_out_pins[i];
4787 if (alc880_is_fixed_pin(nid))
4788 continue;
4789 /* search for an empty channel */
4790 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004791 if (!assigned[j]) {
4792 spec->multiout.dac_nids[i] =
4793 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004794 assigned[j] = 1;
4795 break;
4796 }
4797 }
4798 }
4799 spec->multiout.num_dacs = cfg->line_outs;
4800 return 0;
4801}
4802
4803/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004804static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4805 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004806{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004807 static const char *chname[4] = {
4808 "Front", "Surround", NULL /*CLFE*/, "Side"
4809 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004810 hda_nid_t nid;
4811 int i, err;
4812
4813 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004814 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004815 continue;
4816 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4817 if (i == 2) {
4818 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004819 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4820 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004821 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4822 HDA_OUTPUT));
4823 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004824 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004825 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4826 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004827 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4828 HDA_OUTPUT));
4829 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004830 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004831 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4832 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004833 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4834 HDA_INPUT));
4835 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004836 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004837 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4838 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004839 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4840 HDA_INPUT));
4841 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004842 return err;
4843 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004844 const char *pfx;
4845 if (cfg->line_outs == 1 &&
4846 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4847 pfx = "Speaker";
4848 else
4849 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004850 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004851 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4852 HDA_OUTPUT));
4853 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004855 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004856 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4857 HDA_INPUT));
4858 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004859 return err;
4860 }
4861 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004862 return 0;
4863}
4864
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004865/* add playback controls for speaker and HP outputs */
4866static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4867 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868{
4869 hda_nid_t nid;
4870 int err;
4871
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004872 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 return 0;
4874
4875 if (alc880_is_fixed_pin(pin)) {
4876 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004877 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004878 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004880 else
4881 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004882 /* control HP volume/switch on the output mixer amp */
4883 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004884 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004885 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4886 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004887 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004888 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004889 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4890 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004891 return err;
4892 } else if (alc880_is_multi_pin(pin)) {
4893 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004894 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004895 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004896 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4897 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004898 return err;
4899 }
4900 return 0;
4901}
4902
4903/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004904static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4905 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004906 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004907{
Kailang Yangdf694da2005-12-05 19:42:22 +01004908 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004909
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004910 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004911 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4912 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004913 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004914 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004915 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4916 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004917 return err;
4918 return 0;
4919}
4920
Takashi Iwai05f5f472009-08-25 13:10:18 +02004921static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004922{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004923 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4924 return (pincap & AC_PINCAP_IN) != 0;
4925}
4926
4927/* create playback/capture controls for input pins */
4928static int alc_auto_create_input_ctls(struct hda_codec *codec,
4929 const struct auto_pin_cfg *cfg,
4930 hda_nid_t mixer,
4931 hda_nid_t cap1, hda_nid_t cap2)
4932{
4933 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004934 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004935 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004936
4937 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004938 hda_nid_t pin;
4939
4940 pin = cfg->input_pins[i];
4941 if (!alc_is_input_pin(codec, pin))
4942 continue;
4943
4944 if (mixer) {
4945 idx = get_connection_index(codec, mixer, pin);
4946 if (idx >= 0) {
4947 err = new_analog_input(spec, pin,
4948 auto_pin_cfg_labels[i],
4949 idx, mixer);
4950 if (err < 0)
4951 return err;
4952 }
4953 }
4954
4955 if (!cap1)
4956 continue;
4957 idx = get_connection_index(codec, cap1, pin);
4958 if (idx < 0 && cap2)
4959 idx = get_connection_index(codec, cap2, pin);
4960 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004961 imux->items[imux->num_items].label =
4962 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004963 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004964 imux->num_items++;
4965 }
4966 }
4967 return 0;
4968}
4969
Takashi Iwai05f5f472009-08-25 13:10:18 +02004970static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4971 const struct auto_pin_cfg *cfg)
4972{
4973 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4974}
4975
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004976static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4977 unsigned int pin_type)
4978{
4979 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4980 pin_type);
4981 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004982 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4983 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004984}
4985
Kailang Yangdf694da2005-12-05 19:42:22 +01004986static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4987 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988 int dac_idx)
4989{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004990 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004991 /* need the manual connection? */
4992 if (alc880_is_multi_pin(nid)) {
4993 struct alc_spec *spec = codec->spec;
4994 int idx = alc880_multi_pin_idx(nid);
4995 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4996 AC_VERB_SET_CONNECT_SEL,
4997 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4998 }
4999}
5000
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005001static int get_pin_type(int line_out_type)
5002{
5003 if (line_out_type == AUTO_PIN_HP_OUT)
5004 return PIN_HP;
5005 else
5006 return PIN_OUT;
5007}
5008
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009static void alc880_auto_init_multi_out(struct hda_codec *codec)
5010{
5011 struct alc_spec *spec = codec->spec;
5012 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005013
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005014 for (i = 0; i < spec->autocfg.line_outs; i++) {
5015 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005016 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5017 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005018 }
5019}
5020
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005021static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005022{
5023 struct alc_spec *spec = codec->spec;
5024 hda_nid_t pin;
5025
Takashi Iwai82bc9552006-03-21 11:24:42 +01005026 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005027 if (pin) /* connect to front */
5028 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005029 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030 if (pin) /* connect to front */
5031 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5032}
5033
5034static void alc880_auto_init_analog_input(struct hda_codec *codec)
5035{
5036 struct alc_spec *spec = codec->spec;
5037 int i;
5038
5039 for (i = 0; i < AUTO_PIN_LAST; i++) {
5040 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02005041 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005042 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005043 if (nid != ALC880_PIN_CD_NID &&
5044 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005045 snd_hda_codec_write(codec, nid, 0,
5046 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005047 AMP_OUT_MUTE);
5048 }
5049 }
5050}
5051
Takashi Iwai7f311a42010-04-09 17:32:23 +02005052static void alc880_auto_init_input_src(struct hda_codec *codec)
5053{
5054 struct alc_spec *spec = codec->spec;
5055 int c;
5056
5057 for (c = 0; c < spec->num_adc_nids; c++) {
5058 unsigned int mux_idx;
5059 const struct hda_input_mux *imux;
5060 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5061 imux = &spec->input_mux[mux_idx];
5062 if (!imux->num_items && mux_idx > 0)
5063 imux = &spec->input_mux[0];
5064 if (imux)
5065 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5066 AC_VERB_SET_CONNECT_SEL,
5067 imux->items[0].index);
5068 }
5069}
5070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005071/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005072/* return 1 if successful, 0 if the proper config is not found,
5073 * or a negative error code
5074 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005075static int alc880_parse_auto_config(struct hda_codec *codec)
5076{
5077 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005078 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005079 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005080
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005081 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5082 alc880_ignore);
5083 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005084 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005085 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005086 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005087
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005088 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5089 if (err < 0)
5090 return err;
5091 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5092 if (err < 0)
5093 return err;
5094 err = alc880_auto_create_extra_out(spec,
5095 spec->autocfg.speaker_pins[0],
5096 "Speaker");
5097 if (err < 0)
5098 return err;
5099 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5100 "Headphone");
5101 if (err < 0)
5102 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005103 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005104 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005105 return err;
5106
5107 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5108
Takashi Iwai757899a2010-07-30 10:48:14 +02005109 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110
Takashi Iwai603c4012008-07-30 15:01:44 +02005111 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005112 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005113
Takashi Iwaid88897e2008-10-31 15:01:37 +01005114 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005115
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005116 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005117 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005118
Kailang Yang6227cdc2010-02-25 08:36:52 +01005119 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005120
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005121 return 1;
5122}
5123
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005124/* additional initialization for auto-configuration model */
5125static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005126{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005127 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005128 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005129 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005131 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005132 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005133 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005134 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005135}
5136
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005137/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5138 * one of two digital mic pins, e.g. on ALC272
5139 */
5140static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005141{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005142 struct alc_spec *spec = codec->spec;
5143 int i;
5144
5145 for (i = 0; i < spec->num_adc_nids; i++) {
5146 hda_nid_t cap = spec->capsrc_nids ?
5147 spec->capsrc_nids[i] : spec->adc_nids[i];
5148 int iidx, eidx;
5149
5150 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5151 if (iidx < 0)
5152 continue;
5153 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5154 if (eidx < 0)
5155 continue;
5156 spec->int_mic.mux_idx = iidx;
5157 spec->ext_mic.mux_idx = eidx;
5158 if (spec->capsrc_nids)
5159 spec->capsrc_nids += i;
5160 spec->adc_nids += i;
5161 spec->num_adc_nids = 1;
5162 return;
5163 }
5164 snd_printd(KERN_INFO "hda_codec: %s: "
5165 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5166 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5167 spec->auto_mic = 0; /* disable auto-mic to be sure */
5168}
5169
Takashi Iwai748cce42010-08-04 07:37:39 +02005170/* select or unmute the given capsrc route */
5171static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5172 int idx)
5173{
5174 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5175 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5176 HDA_AMP_MUTE, 0);
5177 } else {
5178 snd_hda_codec_write_cache(codec, cap, 0,
5179 AC_VERB_SET_CONNECT_SEL, idx);
5180 }
5181}
5182
Takashi Iwai840b64c2010-07-13 22:49:01 +02005183/* set the default connection to that pin */
5184static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5185{
5186 struct alc_spec *spec = codec->spec;
5187 int i;
5188
5189 for (i = 0; i < spec->num_adc_nids; i++) {
5190 hda_nid_t cap = spec->capsrc_nids ?
5191 spec->capsrc_nids[i] : spec->adc_nids[i];
5192 int idx;
5193
5194 idx = get_connection_index(codec, cap, pin);
5195 if (idx < 0)
5196 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005197 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005198 return i; /* return the found index */
5199 }
5200 return -1; /* not found */
5201}
5202
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005203/* choose the ADC/MUX containing the input pin and initialize the setup */
5204static void fixup_single_adc(struct hda_codec *codec)
5205{
5206 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01005207 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005208 int i;
5209
5210 /* search for the input pin; there must be only one */
5211 for (i = 0; i < AUTO_PIN_LAST; i++) {
5212 if (spec->autocfg.input_pins[i]) {
5213 pin = spec->autocfg.input_pins[i];
5214 break;
5215 }
5216 }
5217 if (!pin)
5218 return;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005219 i = init_capsrc_for_pin(codec, pin);
5220 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005221 /* use only this ADC */
5222 if (spec->capsrc_nids)
5223 spec->capsrc_nids += i;
5224 spec->adc_nids += i;
5225 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005226 }
5227}
5228
Takashi Iwai840b64c2010-07-13 22:49:01 +02005229/* initialize dual adcs */
5230static void fixup_dual_adc_switch(struct hda_codec *codec)
5231{
5232 struct alc_spec *spec = codec->spec;
5233 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5234 init_capsrc_for_pin(codec, spec->int_mic.pin);
5235}
5236
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005237static void set_capture_mixer(struct hda_codec *codec)
5238{
5239 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005240 static struct snd_kcontrol_new *caps[2][3] = {
5241 { alc_capture_mixer_nosrc1,
5242 alc_capture_mixer_nosrc2,
5243 alc_capture_mixer_nosrc3 },
5244 { alc_capture_mixer1,
5245 alc_capture_mixer2,
5246 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005247 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005248 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005249 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005250 int num_adcs = spec->num_adc_nids;
5251 if (spec->dual_adc_switch)
5252 fixup_dual_adc_switch(codec);
5253 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005254 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005255 else if (spec->input_mux) {
5256 if (spec->input_mux->num_items > 1)
5257 mux = 1;
5258 else if (spec->input_mux->num_items == 1)
5259 fixup_single_adc(codec);
5260 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005261 if (spec->dual_adc_switch)
5262 num_adcs = 1;
5263 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005264 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005265}
5266
Takashi Iwai66946352010-03-29 17:21:45 +02005267/* fill adc_nids (and capsrc_nids) containing all active input pins */
5268static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5269 int num_nids)
5270{
5271 struct alc_spec *spec = codec->spec;
5272 int n;
5273 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5274
5275 for (n = 0; n < num_nids; n++) {
5276 hda_nid_t adc, cap;
5277 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5278 int nconns, i, j;
5279
5280 adc = nids[n];
5281 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5282 continue;
5283 cap = adc;
5284 nconns = snd_hda_get_connections(codec, cap, conn,
5285 ARRAY_SIZE(conn));
5286 if (nconns == 1) {
5287 cap = conn[0];
5288 nconns = snd_hda_get_connections(codec, cap, conn,
5289 ARRAY_SIZE(conn));
5290 }
5291 if (nconns <= 0)
5292 continue;
5293 if (!fallback_adc) {
5294 fallback_adc = adc;
5295 fallback_cap = cap;
5296 }
5297 for (i = 0; i < AUTO_PIN_LAST; i++) {
5298 hda_nid_t nid = spec->autocfg.input_pins[i];
5299 if (!nid)
5300 continue;
5301 for (j = 0; j < nconns; j++) {
5302 if (conn[j] == nid)
5303 break;
5304 }
5305 if (j >= nconns)
5306 break;
5307 }
5308 if (i >= AUTO_PIN_LAST) {
5309 int num_adcs = spec->num_adc_nids;
5310 spec->private_adc_nids[num_adcs] = adc;
5311 spec->private_capsrc_nids[num_adcs] = cap;
5312 spec->num_adc_nids++;
5313 spec->adc_nids = spec->private_adc_nids;
5314 if (adc != cap)
5315 spec->capsrc_nids = spec->private_capsrc_nids;
5316 }
5317 }
5318 if (!spec->num_adc_nids) {
5319 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005320 " using fallback 0x%x\n",
5321 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005322 spec->private_adc_nids[0] = fallback_adc;
5323 spec->adc_nids = spec->private_adc_nids;
5324 if (fallback_adc != fallback_cap) {
5325 spec->private_capsrc_nids[0] = fallback_cap;
5326 spec->capsrc_nids = spec->private_adc_nids;
5327 }
5328 }
5329}
5330
Takashi Iwai67d634c2009-11-16 15:35:59 +01005331#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005332#define set_beep_amp(spec, nid, idx, dir) \
5333 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005334
5335static struct snd_pci_quirk beep_white_list[] = {
5336 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005337 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005338 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005339 {}
5340};
5341
5342static inline int has_cdefine_beep(struct hda_codec *codec)
5343{
5344 struct alc_spec *spec = codec->spec;
5345 const struct snd_pci_quirk *q;
5346 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5347 if (q)
5348 return q->value;
5349 return spec->cdefine.enable_pcbeep;
5350}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005351#else
5352#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005353#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005354#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005355
5356/*
5357 * OK, here we have finally the patch for ALC880
5358 */
5359
Linus Torvalds1da177e2005-04-16 15:20:36 -07005360static int patch_alc880(struct hda_codec *codec)
5361{
5362 struct alc_spec *spec;
5363 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005364 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005365
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005366 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005367 if (spec == NULL)
5368 return -ENOMEM;
5369
5370 codec->spec = spec;
5371
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005372 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5373 alc880_models,
5374 alc880_cfg_tbl);
5375 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005376 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5377 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005378 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005379 }
5380
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005381 if (board_config == ALC880_AUTO) {
5382 /* automatic parse from the BIOS config */
5383 err = alc880_parse_auto_config(codec);
5384 if (err < 0) {
5385 alc_free(codec);
5386 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005387 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005388 printk(KERN_INFO
5389 "hda_codec: Cannot set up configuration "
5390 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005391 board_config = ALC880_3ST;
5392 }
5393 }
5394
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005395 err = snd_hda_attach_beep_device(codec, 0x1);
5396 if (err < 0) {
5397 alc_free(codec);
5398 return err;
5399 }
5400
Kailang Yangdf694da2005-12-05 19:42:22 +01005401 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005402 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005403
Linus Torvalds1da177e2005-04-16 15:20:36 -07005404 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5405 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005406 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005407
Linus Torvalds1da177e2005-04-16 15:20:36 -07005408 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5409 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5410
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005411 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005412 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005413 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005414 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005415 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005416 if (wcap != AC_WID_AUD_IN) {
5417 spec->adc_nids = alc880_adc_nids_alt;
5418 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005419 } else {
5420 spec->adc_nids = alc880_adc_nids;
5421 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005422 }
5423 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005424 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005425 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005426
Takashi Iwai2134ea42008-01-10 16:53:55 +01005427 spec->vmaster_nid = 0x0c;
5428
Linus Torvalds1da177e2005-04-16 15:20:36 -07005429 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005430 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005431 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005432#ifdef CONFIG_SND_HDA_POWER_SAVE
5433 if (!spec->loopback.amplist)
5434 spec->loopback.amplist = alc880_loopbacks;
5435#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005436
5437 return 0;
5438}
5439
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005440
Linus Torvalds1da177e2005-04-16 15:20:36 -07005441/*
5442 * ALC260 support
5443 */
5444
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005445static hda_nid_t alc260_dac_nids[1] = {
5446 /* front */
5447 0x02,
5448};
5449
5450static hda_nid_t alc260_adc_nids[1] = {
5451 /* ADC0 */
5452 0x04,
5453};
5454
Kailang Yangdf694da2005-12-05 19:42:22 +01005455static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005456 /* ADC1 */
5457 0x05,
5458};
5459
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005460/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5461 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5462 */
5463static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005464 /* ADC0, ADC1 */
5465 0x04, 0x05
5466};
5467
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005468#define ALC260_DIGOUT_NID 0x03
5469#define ALC260_DIGIN_NID 0x06
5470
5471static struct hda_input_mux alc260_capture_source = {
5472 .num_items = 4,
5473 .items = {
5474 { "Mic", 0x0 },
5475 { "Front Mic", 0x1 },
5476 { "Line", 0x2 },
5477 { "CD", 0x4 },
5478 },
5479};
5480
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005481/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005482 * headphone jack and the internal CD lines since these are the only pins at
5483 * which audio can appear. For flexibility, also allow the option of
5484 * recording the mixer output on the second ADC (ADC0 doesn't have a
5485 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005486 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005487static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5488 {
5489 .num_items = 3,
5490 .items = {
5491 { "Mic/Line", 0x0 },
5492 { "CD", 0x4 },
5493 { "Headphone", 0x2 },
5494 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005495 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005496 {
5497 .num_items = 4,
5498 .items = {
5499 { "Mic/Line", 0x0 },
5500 { "CD", 0x4 },
5501 { "Headphone", 0x2 },
5502 { "Mixer", 0x5 },
5503 },
5504 },
5505
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005506};
5507
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005508/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5509 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005510 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005511static struct hda_input_mux alc260_acer_capture_sources[2] = {
5512 {
5513 .num_items = 4,
5514 .items = {
5515 { "Mic", 0x0 },
5516 { "Line", 0x2 },
5517 { "CD", 0x4 },
5518 { "Headphone", 0x5 },
5519 },
5520 },
5521 {
5522 .num_items = 5,
5523 .items = {
5524 { "Mic", 0x0 },
5525 { "Line", 0x2 },
5526 { "CD", 0x4 },
5527 { "Headphone", 0x6 },
5528 { "Mixer", 0x5 },
5529 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005530 },
5531};
Michael Schwingencc959482009-02-22 18:58:45 +01005532
5533/* Maxdata Favorit 100XS */
5534static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5535 {
5536 .num_items = 2,
5537 .items = {
5538 { "Line/Mic", 0x0 },
5539 { "CD", 0x4 },
5540 },
5541 },
5542 {
5543 .num_items = 3,
5544 .items = {
5545 { "Line/Mic", 0x0 },
5546 { "CD", 0x4 },
5547 { "Mixer", 0x5 },
5548 },
5549 },
5550};
5551
Linus Torvalds1da177e2005-04-16 15:20:36 -07005552/*
5553 * This is just place-holder, so there's something for alc_build_pcms to look
5554 * at when it calculates the maximum number of channels. ALC260 has no mixer
5555 * element which allows changing the channel mode, so the verb list is
5556 * never used.
5557 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005558static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005559 { 2, NULL },
5560};
5561
Kailang Yangdf694da2005-12-05 19:42:22 +01005562
5563/* Mixer combinations
5564 *
5565 * basic: base_output + input + pc_beep + capture
5566 * HP: base_output + input + capture_alt
5567 * HP_3013: hp_3013 + input + capture
5568 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005569 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005570 */
5571
5572static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005573 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005574 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005575 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5576 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5577 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5578 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5579 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005580};
Kailang Yangdf694da2005-12-05 19:42:22 +01005581
5582static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005583 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5584 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5585 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5586 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5588 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5589 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5590 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005591 { } /* end */
5592};
5593
Takashi Iwaibec15c32008-01-28 18:16:30 +01005594/* update HP, line and mono out pins according to the master switch */
5595static void alc260_hp_master_update(struct hda_codec *codec,
5596 hda_nid_t hp, hda_nid_t line,
5597 hda_nid_t mono)
5598{
5599 struct alc_spec *spec = codec->spec;
5600 unsigned int val = spec->master_sw ? PIN_HP : 0;
5601 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005602 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005603 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005604 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005605 val);
5606 /* mono (speaker) depending on the HP jack sense */
5607 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005608 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005609 val);
5610}
5611
5612static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5613 struct snd_ctl_elem_value *ucontrol)
5614{
5615 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5616 struct alc_spec *spec = codec->spec;
5617 *ucontrol->value.integer.value = spec->master_sw;
5618 return 0;
5619}
5620
5621static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5622 struct snd_ctl_elem_value *ucontrol)
5623{
5624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5625 struct alc_spec *spec = codec->spec;
5626 int val = !!*ucontrol->value.integer.value;
5627 hda_nid_t hp, line, mono;
5628
5629 if (val == spec->master_sw)
5630 return 0;
5631 spec->master_sw = val;
5632 hp = (kcontrol->private_value >> 16) & 0xff;
5633 line = (kcontrol->private_value >> 8) & 0xff;
5634 mono = kcontrol->private_value & 0xff;
5635 alc260_hp_master_update(codec, hp, line, mono);
5636 return 1;
5637}
5638
5639static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5640 {
5641 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5642 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005643 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005644 .info = snd_ctl_boolean_mono_info,
5645 .get = alc260_hp_master_sw_get,
5646 .put = alc260_hp_master_sw_put,
5647 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5648 },
5649 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5650 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5651 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5652 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5653 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5654 HDA_OUTPUT),
5655 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5656 { } /* end */
5657};
5658
5659static struct hda_verb alc260_hp_unsol_verbs[] = {
5660 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5661 {},
5662};
5663
5664static void alc260_hp_automute(struct hda_codec *codec)
5665{
5666 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005667
Wu Fengguang864f92b2009-11-18 12:38:02 +08005668 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005669 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5670}
5671
5672static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5673{
5674 if ((res >> 26) == ALC880_HP_EVENT)
5675 alc260_hp_automute(codec);
5676}
5677
Kailang Yangdf694da2005-12-05 19:42:22 +01005678static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005679 {
5680 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5681 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005682 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005683 .info = snd_ctl_boolean_mono_info,
5684 .get = alc260_hp_master_sw_get,
5685 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005686 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005687 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005688 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5689 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5690 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5691 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5692 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5693 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005694 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5695 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005696 { } /* end */
5697};
5698
Kailang Yang3f878302008-08-26 13:02:23 +02005699static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5700 .ops = &snd_hda_bind_vol,
5701 .values = {
5702 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5703 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5704 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5705 0
5706 },
5707};
5708
5709static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5710 .ops = &snd_hda_bind_sw,
5711 .values = {
5712 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5713 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5714 0
5715 },
5716};
5717
5718static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5719 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5720 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5721 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5723 { } /* end */
5724};
5725
Takashi Iwaibec15c32008-01-28 18:16:30 +01005726static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5727 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5728 {},
5729};
5730
5731static void alc260_hp_3013_automute(struct hda_codec *codec)
5732{
5733 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005734
Wu Fengguang864f92b2009-11-18 12:38:02 +08005735 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005736 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005737}
5738
5739static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5740 unsigned int res)
5741{
5742 if ((res >> 26) == ALC880_HP_EVENT)
5743 alc260_hp_3013_automute(codec);
5744}
5745
Kailang Yang3f878302008-08-26 13:02:23 +02005746static void alc260_hp_3012_automute(struct hda_codec *codec)
5747{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005748 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005749
Kailang Yang3f878302008-08-26 13:02:23 +02005750 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5751 bits);
5752 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5753 bits);
5754 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5755 bits);
5756}
5757
5758static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5759 unsigned int res)
5760{
5761 if ((res >> 26) == ALC880_HP_EVENT)
5762 alc260_hp_3012_automute(codec);
5763}
5764
5765/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005766 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5767 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005768static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005769 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005770 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005771 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005772 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5773 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5774 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5775 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005776 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005777 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5778 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005779 { } /* end */
5780};
5781
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005782/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5783 * versions of the ALC260 don't act on requests to enable mic bias from NID
5784 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5785 * datasheet doesn't mention this restriction. At this stage it's not clear
5786 * whether this behaviour is intentional or is a hardware bug in chip
5787 * revisions available in early 2006. Therefore for now allow the
5788 * "Headphone Jack Mode" control to span all choices, but if it turns out
5789 * that the lack of mic bias for this NID is intentional we could change the
5790 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5791 *
5792 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5793 * don't appear to make the mic bias available from the "line" jack, even
5794 * though the NID used for this jack (0x14) can supply it. The theory is
5795 * that perhaps Acer have included blocking capacitors between the ALC260
5796 * and the output jack. If this turns out to be the case for all such
5797 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5798 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005799 *
5800 * The C20x Tablet series have a mono internal speaker which is controlled
5801 * via the chip's Mono sum widget and pin complex, so include the necessary
5802 * controls for such models. On models without a "mono speaker" the control
5803 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005804 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005805static struct snd_kcontrol_new alc260_acer_mixer[] = {
5806 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5807 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005808 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005809 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005810 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005811 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005812 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005813 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5814 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5816 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5817 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5818 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5819 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5820 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005821 { } /* end */
5822};
5823
Michael Schwingencc959482009-02-22 18:58:45 +01005824/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5825 */
5826static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5827 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5828 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5829 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5830 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5831 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5832 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5833 { } /* end */
5834};
5835
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005836/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5837 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5838 */
5839static struct snd_kcontrol_new alc260_will_mixer[] = {
5840 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5841 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5843 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5844 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5845 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5846 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5847 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5848 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5849 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005850 { } /* end */
5851};
5852
5853/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5854 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5855 */
5856static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5857 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5858 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5860 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5861 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5862 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5863 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5864 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5865 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5866 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5867 { } /* end */
5868};
5869
Kailang Yangdf694da2005-12-05 19:42:22 +01005870/*
5871 * initialization verbs
5872 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005873static struct hda_verb alc260_init_verbs[] = {
5874 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005875 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005876 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005877 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005878 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005879 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005880 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005881 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005882 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005884 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005885 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005886 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005887 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005888 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005889 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005890 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005891 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5892 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005893 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005894 /* set connection select to line in (default select for this ADC) */
5895 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005896 /* mute capture amp left and right */
5897 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5898 /* set connection select to line in (default select for this ADC) */
5899 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005900 /* set vol=0 Line-Out mixer amp left and right */
5901 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5902 /* unmute pin widget amp left and right (no gain on this amp) */
5903 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5904 /* set vol=0 HP mixer amp left and right */
5905 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5906 /* unmute pin widget amp left and right (no gain on this amp) */
5907 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5908 /* set vol=0 Mono mixer amp left and right */
5909 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5910 /* unmute pin widget amp left and right (no gain on this amp) */
5911 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5912 /* unmute LINE-2 out pin */
5913 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005914 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5915 * Line In 2 = 0x03
5916 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005917 /* mute analog inputs */
5918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5922 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005923 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005924 /* mute Front out path */
5925 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5926 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5927 /* mute Headphone out path */
5928 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5930 /* mute Mono out path */
5931 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5932 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005933 { }
5934};
5935
Takashi Iwai474167d2006-05-17 17:17:43 +02005936#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005937static struct hda_verb alc260_hp_init_verbs[] = {
5938 /* Headphone and output */
5939 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5940 /* mono output */
5941 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5942 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5943 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5944 /* Mic2 (front panel) pin widget for input and vref at 80% */
5945 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5946 /* Line In pin widget for input */
5947 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5948 /* Line-2 pin widget for output */
5949 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5950 /* CD pin widget for input */
5951 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5952 /* unmute amp left and right */
5953 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5954 /* set connection select to line in (default select for this ADC) */
5955 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5956 /* unmute Line-Out mixer amp left and right (volume = 0) */
5957 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5958 /* mute pin widget amp left and right (no gain on this amp) */
5959 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5960 /* unmute HP mixer amp left and right (volume = 0) */
5961 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5962 /* mute pin widget amp left and right (no gain on this amp) */
5963 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005964 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5965 * Line In 2 = 0x03
5966 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005967 /* mute analog inputs */
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5972 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005973 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5974 /* Unmute Front out path */
5975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5976 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5977 /* Unmute Headphone out path */
5978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5979 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5980 /* Unmute Mono out path */
5981 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5982 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5983 { }
5984};
Takashi Iwai474167d2006-05-17 17:17:43 +02005985#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005986
5987static struct hda_verb alc260_hp_3013_init_verbs[] = {
5988 /* Line out and output */
5989 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5990 /* mono output */
5991 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5992 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5993 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5994 /* Mic2 (front panel) pin widget for input and vref at 80% */
5995 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5996 /* Line In pin widget for input */
5997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5998 /* Headphone pin widget for output */
5999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6000 /* CD pin widget for input */
6001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6002 /* unmute amp left and right */
6003 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6004 /* set connection select to line in (default select for this ADC) */
6005 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6006 /* unmute Line-Out mixer amp left and right (volume = 0) */
6007 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6008 /* mute pin widget amp left and right (no gain on this amp) */
6009 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6010 /* unmute HP mixer amp left and right (volume = 0) */
6011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6012 /* mute pin widget amp left and right (no gain on this amp) */
6013 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006014 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6015 * Line In 2 = 0x03
6016 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006017 /* mute analog inputs */
6018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6022 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006023 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6024 /* Unmute Front out path */
6025 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6026 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6027 /* Unmute Headphone out path */
6028 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6029 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6030 /* Unmute Mono out path */
6031 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6032 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6033 { }
6034};
6035
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006036/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006037 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6038 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006039 */
6040static struct hda_verb alc260_fujitsu_init_verbs[] = {
6041 /* Disable all GPIOs */
6042 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6043 /* Internal speaker is connected to headphone pin */
6044 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6045 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006047 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6048 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6049 /* Ensure all other unused pins are disabled and muted. */
6050 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6051 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006052 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006053 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006054 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006055 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6056 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6057 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006058
Jonathan Woithef7ace402006-02-28 11:46:14 +01006059 /* Disable digital (SPDIF) pins */
6060 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6061 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006062
Kailang Yangea1fb292008-08-26 12:58:38 +02006063 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006064 * when acting as an output.
6065 */
6066 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6067
6068 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6074 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6075 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6076 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6077 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006078
Jonathan Woithef7ace402006-02-28 11:46:14 +01006079 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6080 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6081 /* Unmute Line1 pin widget output buffer since it starts as an output.
6082 * If the pin mode is changed by the user the pin mode control will
6083 * take care of enabling the pin's input/output buffers as needed.
6084 * Therefore there's no need to enable the input buffer at this
6085 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006086 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006087 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006088 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006089 * mixer ctrl)
6090 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006091 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006092
Jonathan Woithef7ace402006-02-28 11:46:14 +01006093 /* Mute capture amp left and right */
6094 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006095 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006096 * in (on mic1 pin)
6097 */
6098 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006099
Jonathan Woithef7ace402006-02-28 11:46:14 +01006100 /* Do the same for the second ADC: mute capture input amp and
6101 * set ADC connection to line in (on mic1 pin)
6102 */
6103 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6104 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006105
Jonathan Woithef7ace402006-02-28 11:46:14 +01006106 /* Mute all inputs to mixer widget (even unconnected ones) */
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006115
6116 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006117};
6118
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006119/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6120 * similar laptops (adapted from Fujitsu init verbs).
6121 */
6122static struct hda_verb alc260_acer_init_verbs[] = {
6123 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6124 * the headphone jack. Turn this on and rely on the standard mute
6125 * methods whenever the user wants to turn these outputs off.
6126 */
6127 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6128 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6129 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6130 /* Internal speaker/Headphone jack is connected to Line-out pin */
6131 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6132 /* Internal microphone/Mic jack is connected to Mic1 pin */
6133 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6134 /* Line In jack is connected to Line1 pin */
6135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006136 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6137 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006138 /* Ensure all other unused pins are disabled and muted. */
6139 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6140 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006141 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6142 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6143 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6144 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6145 /* Disable digital (SPDIF) pins */
6146 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6147 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6148
Kailang Yangea1fb292008-08-26 12:58:38 +02006149 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006150 * bus when acting as outputs.
6151 */
6152 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6153 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6154
6155 /* Start with output sum widgets muted and their output gains at min */
6156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6158 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6160 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6162 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6163 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6164 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6165
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006166 /* Unmute Line-out pin widget amp left and right
6167 * (no equiv mixer ctrl)
6168 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006169 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006170 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6171 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006172 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6173 * inputs. If the pin mode is changed by the user the pin mode control
6174 * will take care of enabling the pin's input/output buffers as needed.
6175 * Therefore there's no need to enable the input buffer at this
6176 * stage.
6177 */
6178 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6179 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6180
6181 /* Mute capture amp left and right */
6182 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6183 /* Set ADC connection select to match default mixer setting - mic
6184 * (on mic1 pin)
6185 */
6186 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6187
6188 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006189 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006190 */
6191 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006192 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006193
6194 /* Mute all inputs to mixer widget (even unconnected ones) */
6195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6202 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6203
6204 { }
6205};
6206
Michael Schwingencc959482009-02-22 18:58:45 +01006207/* Initialisation sequence for Maxdata Favorit 100XS
6208 * (adapted from Acer init verbs).
6209 */
6210static struct hda_verb alc260_favorit100_init_verbs[] = {
6211 /* GPIO 0 enables the output jack.
6212 * Turn this on and rely on the standard mute
6213 * methods whenever the user wants to turn these outputs off.
6214 */
6215 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6216 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6217 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6218 /* Line/Mic input jack is connected to Mic1 pin */
6219 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6220 /* Ensure all other unused pins are disabled and muted. */
6221 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6222 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6223 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6224 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6225 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6226 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6227 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6229 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6230 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6231 /* Disable digital (SPDIF) pins */
6232 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6233 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6234
6235 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6236 * bus when acting as outputs.
6237 */
6238 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6239 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6240
6241 /* Start with output sum widgets muted and their output gains at min */
6242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6243 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6244 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6246 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6248 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6249 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6250 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6251
6252 /* Unmute Line-out pin widget amp left and right
6253 * (no equiv mixer ctrl)
6254 */
6255 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6256 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6257 * inputs. If the pin mode is changed by the user the pin mode control
6258 * will take care of enabling the pin's input/output buffers as needed.
6259 * Therefore there's no need to enable the input buffer at this
6260 * stage.
6261 */
6262 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6263
6264 /* Mute capture amp left and right */
6265 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6266 /* Set ADC connection select to match default mixer setting - mic
6267 * (on mic1 pin)
6268 */
6269 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6270
6271 /* Do similar with the second ADC: mute capture input amp and
6272 * set ADC connection to mic to match ALSA's default state.
6273 */
6274 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6275 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6276
6277 /* Mute all inputs to mixer widget (even unconnected ones) */
6278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6286
6287 { }
6288};
6289
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006290static struct hda_verb alc260_will_verbs[] = {
6291 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6292 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6293 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6294 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6295 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6296 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6297 {}
6298};
6299
6300static struct hda_verb alc260_replacer_672v_verbs[] = {
6301 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6302 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6303 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6304
6305 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6306 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6307 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6308
6309 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6310 {}
6311};
6312
6313/* toggle speaker-output according to the hp-jack state */
6314static void alc260_replacer_672v_automute(struct hda_codec *codec)
6315{
6316 unsigned int present;
6317
6318 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006319 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006320 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006321 snd_hda_codec_write_cache(codec, 0x01, 0,
6322 AC_VERB_SET_GPIO_DATA, 1);
6323 snd_hda_codec_write_cache(codec, 0x0f, 0,
6324 AC_VERB_SET_PIN_WIDGET_CONTROL,
6325 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006326 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006327 snd_hda_codec_write_cache(codec, 0x01, 0,
6328 AC_VERB_SET_GPIO_DATA, 0);
6329 snd_hda_codec_write_cache(codec, 0x0f, 0,
6330 AC_VERB_SET_PIN_WIDGET_CONTROL,
6331 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006332 }
6333}
6334
6335static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6336 unsigned int res)
6337{
6338 if ((res >> 26) == ALC880_HP_EVENT)
6339 alc260_replacer_672v_automute(codec);
6340}
6341
Kailang Yang3f878302008-08-26 13:02:23 +02006342static struct hda_verb alc260_hp_dc7600_verbs[] = {
6343 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6344 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6345 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6346 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6347 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6349 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6350 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6351 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6353 {}
6354};
6355
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006356/* Test configuration for debugging, modelled after the ALC880 test
6357 * configuration.
6358 */
6359#ifdef CONFIG_SND_DEBUG
6360static hda_nid_t alc260_test_dac_nids[1] = {
6361 0x02,
6362};
6363static hda_nid_t alc260_test_adc_nids[2] = {
6364 0x04, 0x05,
6365};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006366/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006367 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006368 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006369 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006370static struct hda_input_mux alc260_test_capture_sources[2] = {
6371 {
6372 .num_items = 7,
6373 .items = {
6374 { "MIC1 pin", 0x0 },
6375 { "MIC2 pin", 0x1 },
6376 { "LINE1 pin", 0x2 },
6377 { "LINE2 pin", 0x3 },
6378 { "CD pin", 0x4 },
6379 { "LINE-OUT pin", 0x5 },
6380 { "HP-OUT pin", 0x6 },
6381 },
6382 },
6383 {
6384 .num_items = 8,
6385 .items = {
6386 { "MIC1 pin", 0x0 },
6387 { "MIC2 pin", 0x1 },
6388 { "LINE1 pin", 0x2 },
6389 { "LINE2 pin", 0x3 },
6390 { "CD pin", 0x4 },
6391 { "Mixer", 0x5 },
6392 { "LINE-OUT pin", 0x6 },
6393 { "HP-OUT pin", 0x7 },
6394 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006395 },
6396};
6397static struct snd_kcontrol_new alc260_test_mixer[] = {
6398 /* Output driver widgets */
6399 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6400 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6401 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6402 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6403 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6404 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6405
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006406 /* Modes for retasking pin widgets
6407 * Note: the ALC260 doesn't seem to act on requests to enable mic
6408 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6409 * mention this restriction. At this stage it's not clear whether
6410 * this behaviour is intentional or is a hardware bug in chip
6411 * revisions available at least up until early 2006. Therefore for
6412 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6413 * choices, but if it turns out that the lack of mic bias for these
6414 * NIDs is intentional we could change their modes from
6415 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6416 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006417 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6418 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6419 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6420 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6421 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6422 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6423
6424 /* Loopback mixer controls */
6425 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6426 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6427 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6428 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6429 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6430 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6431 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6432 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6433 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6434 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006435 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6436 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6437 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6438 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006439
6440 /* Controls for GPIO pins, assuming they are configured as outputs */
6441 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6442 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6443 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6444 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6445
Jonathan Woithe92621f12006-02-28 11:47:47 +01006446 /* Switches to allow the digital IO pins to be enabled. The datasheet
6447 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006448 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006449 */
6450 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6451 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6452
Jonathan Woithef8225f62008-01-08 12:16:54 +01006453 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6454 * this output to turn on an external amplifier.
6455 */
6456 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6457 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6458
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006459 { } /* end */
6460};
6461static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006462 /* Enable all GPIOs as outputs with an initial value of 0 */
6463 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6464 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6465 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6466
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006467 /* Enable retasking pins as output, initially without power amp */
6468 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6469 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6470 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6472 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6473 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6474
Jonathan Woithe92621f12006-02-28 11:47:47 +01006475 /* Disable digital (SPDIF) pins initially, but users can enable
6476 * them via a mixer switch. In the case of SPDIF-out, this initverb
6477 * payload also sets the generation to 0, output to be in "consumer"
6478 * PCM format, copyright asserted, no pre-emphasis and no validity
6479 * control.
6480 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006481 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6482 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6483
Kailang Yangea1fb292008-08-26 12:58:38 +02006484 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006485 * OUT1 sum bus when acting as an output.
6486 */
6487 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6488 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6489 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6490 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6491
6492 /* Start with output sum widgets muted and their output gains at min */
6493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6495 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6498 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6499 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6500 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6501 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6502
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006503 /* Unmute retasking pin widget output buffers since the default
6504 * state appears to be output. As the pin mode is changed by the
6505 * user the pin mode control will take care of enabling the pin's
6506 * input/output buffers as needed.
6507 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006508 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6509 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6510 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6512 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6513 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6514 /* Also unmute the mono-out pin widget */
6515 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6516
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006517 /* Mute capture amp left and right */
6518 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006519 /* Set ADC connection select to match default mixer setting (mic1
6520 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006521 */
6522 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6523
6524 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006525 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006526 */
6527 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6528 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6529
6530 /* Mute all inputs to mixer widget (even unconnected ones) */
6531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6533 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6537 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6538 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6539
6540 { }
6541};
6542#endif
6543
Takashi Iwai63300792008-01-24 15:31:36 +01006544#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6545#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006546
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006547#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6548#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6549
Kailang Yangdf694da2005-12-05 19:42:22 +01006550/*
6551 * for BIOS auto-configuration
6552 */
6553
6554static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006555 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006556{
6557 hda_nid_t nid_vol;
6558 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006559 int err;
6560
6561 if (nid >= 0x0f && nid < 0x11) {
6562 nid_vol = nid - 0x7;
6563 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6564 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6565 } else if (nid == 0x11) {
6566 nid_vol = nid - 0x7;
6567 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6568 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6569 } else if (nid >= 0x12 && nid <= 0x15) {
6570 nid_vol = 0x08;
6571 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6572 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6573 } else
6574 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006575
Takashi Iwai863b4512008-10-21 17:01:47 +02006576 if (!(*vol_bits & (1 << nid_vol))) {
6577 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006578 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006579 if (err < 0)
6580 return err;
6581 *vol_bits |= (1 << nid_vol);
6582 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006583 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006584 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006585 return err;
6586 return 1;
6587}
6588
6589/* add playback controls from the parsed DAC table */
6590static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6591 const struct auto_pin_cfg *cfg)
6592{
6593 hda_nid_t nid;
6594 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006595 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006596
6597 spec->multiout.num_dacs = 1;
6598 spec->multiout.dac_nids = spec->private_dac_nids;
6599 spec->multiout.dac_nids[0] = 0x02;
6600
6601 nid = cfg->line_out_pins[0];
6602 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006603 const char *pfx;
6604 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6605 pfx = "Master";
6606 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6607 pfx = "Speaker";
6608 else
6609 pfx = "Front";
6610 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006611 if (err < 0)
6612 return err;
6613 }
6614
Takashi Iwai82bc9552006-03-21 11:24:42 +01006615 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006616 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006617 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006618 if (err < 0)
6619 return err;
6620 }
6621
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006622 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006623 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006624 err = alc260_add_playback_controls(spec, nid, "Headphone",
6625 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 if (err < 0)
6627 return err;
6628 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006629 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006630}
6631
6632/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006633static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006634 const struct auto_pin_cfg *cfg)
6635{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006636 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006637}
6638
6639static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6640 hda_nid_t nid, int pin_type,
6641 int sel_idx)
6642{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006643 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006644 /* need the manual connection? */
6645 if (nid >= 0x12) {
6646 int idx = nid - 0x12;
6647 snd_hda_codec_write(codec, idx + 0x0b, 0,
6648 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006649 }
6650}
6651
6652static void alc260_auto_init_multi_out(struct hda_codec *codec)
6653{
6654 struct alc_spec *spec = codec->spec;
6655 hda_nid_t nid;
6656
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006657 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006658 if (nid) {
6659 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6660 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6661 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006662
Takashi Iwai82bc9552006-03-21 11:24:42 +01006663 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006664 if (nid)
6665 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6666
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006667 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006668 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006669 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006670}
Kailang Yangdf694da2005-12-05 19:42:22 +01006671
6672#define ALC260_PIN_CD_NID 0x16
6673static void alc260_auto_init_analog_input(struct hda_codec *codec)
6674{
6675 struct alc_spec *spec = codec->spec;
6676 int i;
6677
6678 for (i = 0; i < AUTO_PIN_LAST; i++) {
6679 hda_nid_t nid = spec->autocfg.input_pins[i];
6680 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006681 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006682 if (nid != ALC260_PIN_CD_NID &&
6683 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006684 snd_hda_codec_write(codec, nid, 0,
6685 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006686 AMP_OUT_MUTE);
6687 }
6688 }
6689}
6690
Takashi Iwai7f311a42010-04-09 17:32:23 +02006691#define alc260_auto_init_input_src alc880_auto_init_input_src
6692
Kailang Yangdf694da2005-12-05 19:42:22 +01006693/*
6694 * generic initialization of ADC, input mixers and output mixers
6695 */
6696static struct hda_verb alc260_volume_init_verbs[] = {
6697 /*
6698 * Unmute ADC0-1 and set the default input to mic-in
6699 */
6700 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6701 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6702 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6703 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006704
Kailang Yangdf694da2005-12-05 19:42:22 +01006705 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6706 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006707 * Note: PASD motherboards uses the Line In 2 as the input for
6708 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006709 */
6710 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006711 /* mute analog inputs */
6712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6716 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006717
6718 /*
6719 * Set up output mixers (0x08 - 0x0a)
6720 */
6721 /* set vol=0 to output mixers */
6722 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6724 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6725 /* set up input amps for analog loopback */
6726 /* Amp Indices: DAC = 0, mixer = 1 */
6727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6730 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6731 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6732 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006733
Kailang Yangdf694da2005-12-05 19:42:22 +01006734 { }
6735};
6736
6737static int alc260_parse_auto_config(struct hda_codec *codec)
6738{
6739 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006740 int err;
6741 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6742
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006743 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6744 alc260_ignore);
6745 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006746 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006747 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6748 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006749 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006750 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006751 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006752 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006753 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006754 return err;
6755
6756 spec->multiout.max_channels = 2;
6757
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006758 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006759 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006760 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006761 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006762
Takashi Iwaid88897e2008-10-31 15:01:37 +01006763 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006764
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006765 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006766 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006767
Kailang Yang6227cdc2010-02-25 08:36:52 +01006768 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006769
Kailang Yangdf694da2005-12-05 19:42:22 +01006770 return 1;
6771}
6772
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006773/* additional initialization for auto-configuration model */
6774static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006775{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006776 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006777 alc260_auto_init_multi_out(codec);
6778 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006779 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006780 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006781 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006782 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006783}
6784
Takashi Iwaicb53c622007-08-10 17:21:45 +02006785#ifdef CONFIG_SND_HDA_POWER_SAVE
6786static struct hda_amp_list alc260_loopbacks[] = {
6787 { 0x07, HDA_INPUT, 0 },
6788 { 0x07, HDA_INPUT, 1 },
6789 { 0x07, HDA_INPUT, 2 },
6790 { 0x07, HDA_INPUT, 3 },
6791 { 0x07, HDA_INPUT, 4 },
6792 { } /* end */
6793};
6794#endif
6795
Kailang Yangdf694da2005-12-05 19:42:22 +01006796/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006797 * Pin config fixes
6798 */
6799enum {
6800 PINFIX_HP_DC5750,
6801};
6802
6803static struct alc_pincfg alc260_hp_dc5750_pinfix[] = {
6804 { 0x11, 0x90130110 }, /* speaker */
6805 { }
6806};
6807
6808static const struct alc_fixup alc260_fixups[] = {
6809 [PINFIX_HP_DC5750] = {
6810 .pins = alc260_hp_dc5750_pinfix
6811 },
6812};
6813
6814static struct snd_pci_quirk alc260_fixup_tbl[] = {
6815 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6816 {}
6817};
6818
6819/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006820 * ALC260 configurations
6821 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006822static const char *alc260_models[ALC260_MODEL_LAST] = {
6823 [ALC260_BASIC] = "basic",
6824 [ALC260_HP] = "hp",
6825 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006826 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006827 [ALC260_FUJITSU_S702X] = "fujitsu",
6828 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006829 [ALC260_WILL] = "will",
6830 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006831 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006832#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006833 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006834#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006835 [ALC260_AUTO] = "auto",
6836};
6837
6838static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006839 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006840 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006841 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006842 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006843 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006844 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006845 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006846 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006847 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006848 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6849 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6850 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6851 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6852 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6853 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6854 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6855 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6856 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006857 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006858 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006859 {}
6860};
6861
Kailang Yangdf694da2005-12-05 19:42:22 +01006862static struct alc_config_preset alc260_presets[] = {
6863 [ALC260_BASIC] = {
6864 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006865 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006866 .init_verbs = { alc260_init_verbs },
6867 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6868 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006869 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006870 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006871 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6872 .channel_mode = alc260_modes,
6873 .input_mux = &alc260_capture_source,
6874 },
6875 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006876 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006877 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006878 .init_verbs = { alc260_init_verbs,
6879 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006880 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6881 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006882 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6883 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006884 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6885 .channel_mode = alc260_modes,
6886 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006887 .unsol_event = alc260_hp_unsol_event,
6888 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006889 },
Kailang Yang3f878302008-08-26 13:02:23 +02006890 [ALC260_HP_DC7600] = {
6891 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006892 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006893 .init_verbs = { alc260_init_verbs,
6894 alc260_hp_dc7600_verbs },
6895 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6896 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006897 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6898 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006899 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6900 .channel_mode = alc260_modes,
6901 .input_mux = &alc260_capture_source,
6902 .unsol_event = alc260_hp_3012_unsol_event,
6903 .init_hook = alc260_hp_3012_automute,
6904 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006905 [ALC260_HP_3013] = {
6906 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006907 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006908 .init_verbs = { alc260_hp_3013_init_verbs,
6909 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006910 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6911 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006912 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6913 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6915 .channel_mode = alc260_modes,
6916 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006917 .unsol_event = alc260_hp_3013_unsol_event,
6918 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 },
6920 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006921 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006922 .init_verbs = { alc260_fujitsu_init_verbs },
6923 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6924 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006925 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6926 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006927 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6928 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006929 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6930 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006931 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006932 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006933 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006934 .init_verbs = { alc260_acer_init_verbs },
6935 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6936 .dac_nids = alc260_dac_nids,
6937 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6938 .adc_nids = alc260_dual_adc_nids,
6939 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6940 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006941 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6942 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006943 },
Michael Schwingencc959482009-02-22 18:58:45 +01006944 [ALC260_FAVORIT100] = {
6945 .mixers = { alc260_favorit100_mixer },
6946 .init_verbs = { alc260_favorit100_init_verbs },
6947 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6948 .dac_nids = alc260_dac_nids,
6949 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6950 .adc_nids = alc260_dual_adc_nids,
6951 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6952 .channel_mode = alc260_modes,
6953 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6954 .input_mux = alc260_favorit100_capture_sources,
6955 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006956 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006957 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006958 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6959 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6960 .dac_nids = alc260_dac_nids,
6961 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6962 .adc_nids = alc260_adc_nids,
6963 .dig_out_nid = ALC260_DIGOUT_NID,
6964 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6965 .channel_mode = alc260_modes,
6966 .input_mux = &alc260_capture_source,
6967 },
6968 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006969 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006970 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6971 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6972 .dac_nids = alc260_dac_nids,
6973 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6974 .adc_nids = alc260_adc_nids,
6975 .dig_out_nid = ALC260_DIGOUT_NID,
6976 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6977 .channel_mode = alc260_modes,
6978 .input_mux = &alc260_capture_source,
6979 .unsol_event = alc260_replacer_672v_unsol_event,
6980 .init_hook = alc260_replacer_672v_automute,
6981 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006982#ifdef CONFIG_SND_DEBUG
6983 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006984 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006985 .init_verbs = { alc260_test_init_verbs },
6986 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6987 .dac_nids = alc260_test_dac_nids,
6988 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6989 .adc_nids = alc260_test_adc_nids,
6990 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6991 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006992 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6993 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006994 },
6995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006996};
6997
Linus Torvalds1da177e2005-04-16 15:20:36 -07006998static int patch_alc260(struct hda_codec *codec)
6999{
7000 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007001 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007002
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007004 if (spec == NULL)
7005 return -ENOMEM;
7006
7007 codec->spec = spec;
7008
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007009 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7010 alc260_models,
7011 alc260_cfg_tbl);
7012 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007013 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007014 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007015 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007016 }
7017
Takashi Iwaifc091762010-08-04 23:53:36 +02007018 if (board_config == ALC260_AUTO)
7019 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7020
Kailang Yangdf694da2005-12-05 19:42:22 +01007021 if (board_config == ALC260_AUTO) {
7022 /* automatic parse from the BIOS config */
7023 err = alc260_parse_auto_config(codec);
7024 if (err < 0) {
7025 alc_free(codec);
7026 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007027 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007028 printk(KERN_INFO
7029 "hda_codec: Cannot set up configuration "
7030 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007031 board_config = ALC260_BASIC;
7032 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007033 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007034
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007035 err = snd_hda_attach_beep_device(codec, 0x1);
7036 if (err < 0) {
7037 alc_free(codec);
7038 return err;
7039 }
7040
Kailang Yangdf694da2005-12-05 19:42:22 +01007041 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007042 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007043
Linus Torvalds1da177e2005-04-16 15:20:36 -07007044 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7045 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307046 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007047
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007048 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7049 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7050
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007051 if (!spec->adc_nids && spec->input_mux) {
7052 /* check whether NID 0x04 is valid */
7053 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007054 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007055 /* get type */
7056 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7057 spec->adc_nids = alc260_adc_nids_alt;
7058 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7059 } else {
7060 spec->adc_nids = alc260_adc_nids;
7061 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7062 }
7063 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007064 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007065 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007066
Takashi Iwaifc091762010-08-04 23:53:36 +02007067 if (board_config == ALC260_AUTO)
7068 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7069
Takashi Iwai2134ea42008-01-10 16:53:55 +01007070 spec->vmaster_nid = 0x08;
7071
Linus Torvalds1da177e2005-04-16 15:20:36 -07007072 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007073 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007074 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007075#ifdef CONFIG_SND_HDA_POWER_SAVE
7076 if (!spec->loopback.amplist)
7077 spec->loopback.amplist = alc260_loopbacks;
7078#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007079
7080 return 0;
7081}
7082
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007083
Linus Torvalds1da177e2005-04-16 15:20:36 -07007084/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007085 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007086 *
7087 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7088 * configuration. Each pin widget can choose any input DACs and a mixer.
7089 * Each ADC is connected from a mixer of all inputs. This makes possible
7090 * 6-channel independent captures.
7091 *
7092 * In addition, an independent DAC for the multi-playback (not used in this
7093 * driver yet).
7094 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007095#define ALC882_DIGOUT_NID 0x06
7096#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007097#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7098#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7099#define ALC1200_DIGOUT_NID 0x10
7100
Linus Torvalds1da177e2005-04-16 15:20:36 -07007101
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007102static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007103 { 8, NULL }
7104};
7105
Takashi Iwai4953550a2009-06-30 15:28:30 +02007106/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007107static hda_nid_t alc882_dac_nids[4] = {
7108 /* front, rear, clfe, rear_surr */
7109 0x02, 0x03, 0x04, 0x05
7110};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007111#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007112
Takashi Iwai4953550a2009-06-30 15:28:30 +02007113/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007114#define alc882_adc_nids alc880_adc_nids
7115#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007116#define alc883_adc_nids alc882_adc_nids_alt
7117static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7118static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7119#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007120
Takashi Iwaie1406342008-02-11 18:32:32 +01007121static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7122static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007123#define alc883_capsrc_nids alc882_capsrc_nids_alt
7124static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7125#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007126
Linus Torvalds1da177e2005-04-16 15:20:36 -07007127/* input MUX */
7128/* FIXME: should be a matrix-type input source selection */
7129
7130static struct hda_input_mux alc882_capture_source = {
7131 .num_items = 4,
7132 .items = {
7133 { "Mic", 0x0 },
7134 { "Front Mic", 0x1 },
7135 { "Line", 0x2 },
7136 { "CD", 0x4 },
7137 },
7138};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007139
Takashi Iwai4953550a2009-06-30 15:28:30 +02007140#define alc883_capture_source alc882_capture_source
7141
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007142static struct hda_input_mux alc889_capture_source = {
7143 .num_items = 3,
7144 .items = {
7145 { "Front Mic", 0x0 },
7146 { "Mic", 0x3 },
7147 { "Line", 0x2 },
7148 },
7149};
7150
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007151static struct hda_input_mux mb5_capture_source = {
7152 .num_items = 3,
7153 .items = {
7154 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307155 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007156 { "CD", 0x4 },
7157 },
7158};
7159
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007160static struct hda_input_mux macmini3_capture_source = {
7161 .num_items = 2,
7162 .items = {
7163 { "Line", 0x2 },
7164 { "CD", 0x4 },
7165 },
7166};
7167
Takashi Iwai4953550a2009-06-30 15:28:30 +02007168static struct hda_input_mux alc883_3stack_6ch_intel = {
7169 .num_items = 4,
7170 .items = {
7171 { "Mic", 0x1 },
7172 { "Front Mic", 0x0 },
7173 { "Line", 0x2 },
7174 { "CD", 0x4 },
7175 },
7176};
7177
7178static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7179 .num_items = 2,
7180 .items = {
7181 { "Mic", 0x1 },
7182 { "Line", 0x2 },
7183 },
7184};
7185
7186static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7187 .num_items = 4,
7188 .items = {
7189 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007190 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007191 { "Line", 0x2 },
7192 { "CD", 0x4 },
7193 },
7194};
7195
7196static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7197 .num_items = 2,
7198 .items = {
7199 { "Mic", 0x0 },
7200 { "Int Mic", 0x1 },
7201 },
7202};
7203
7204static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7205 .num_items = 3,
7206 .items = {
7207 { "Mic", 0x0 },
7208 { "Front Mic", 0x1 },
7209 { "Line", 0x4 },
7210 },
7211};
7212
7213static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7214 .num_items = 2,
7215 .items = {
7216 { "Mic", 0x0 },
7217 { "Line", 0x2 },
7218 },
7219};
7220
7221static struct hda_input_mux alc889A_mb31_capture_source = {
7222 .num_items = 2,
7223 .items = {
7224 { "Mic", 0x0 },
7225 /* Front Mic (0x01) unused */
7226 { "Line", 0x2 },
7227 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007228 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007229 },
7230};
7231
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007232static struct hda_input_mux alc889A_imac91_capture_source = {
7233 .num_items = 2,
7234 .items = {
7235 { "Mic", 0x01 },
7236 { "Line", 0x2 }, /* Not sure! */
7237 },
7238};
7239
Takashi Iwai4953550a2009-06-30 15:28:30 +02007240/*
7241 * 2ch mode
7242 */
7243static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7244 { 2, NULL }
7245};
7246
Kailang Yangdf694da2005-12-05 19:42:22 +01007247/*
Kailang Yang272a5272007-05-14 11:00:38 +02007248 * 2ch mode
7249 */
7250static struct hda_verb alc882_3ST_ch2_init[] = {
7251 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7252 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7253 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7254 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7255 { } /* end */
7256};
7257
7258/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007259 * 4ch mode
7260 */
7261static struct hda_verb alc882_3ST_ch4_init[] = {
7262 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7263 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7264 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7265 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7266 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7267 { } /* end */
7268};
7269
7270/*
Kailang Yang272a5272007-05-14 11:00:38 +02007271 * 6ch mode
7272 */
7273static struct hda_verb alc882_3ST_ch6_init[] = {
7274 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7275 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7276 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7277 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7278 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7279 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7280 { } /* end */
7281};
7282
Takashi Iwai4953550a2009-06-30 15:28:30 +02007283static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007284 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007285 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007286 { 6, alc882_3ST_ch6_init },
7287};
7288
Takashi Iwai4953550a2009-06-30 15:28:30 +02007289#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7290
Kailang Yang272a5272007-05-14 11:00:38 +02007291/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307292 * 2ch mode
7293 */
7294static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7295 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7296 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7297 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7298 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7299 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7300 { } /* end */
7301};
7302
7303/*
7304 * 4ch mode
7305 */
7306static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7307 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7308 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7309 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7310 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7311 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7312 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7313 { } /* end */
7314};
7315
7316/*
7317 * 6ch mode
7318 */
7319static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7320 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7321 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7322 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7323 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7324 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7325 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7326 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7327 { } /* end */
7328};
7329
7330static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7331 { 2, alc883_3ST_ch2_clevo_init },
7332 { 4, alc883_3ST_ch4_clevo_init },
7333 { 6, alc883_3ST_ch6_clevo_init },
7334};
7335
7336
7337/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007338 * 6ch mode
7339 */
7340static struct hda_verb alc882_sixstack_ch6_init[] = {
7341 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7342 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7343 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7344 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7345 { } /* end */
7346};
7347
7348/*
7349 * 8ch mode
7350 */
7351static struct hda_verb alc882_sixstack_ch8_init[] = {
7352 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7353 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7354 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7355 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7356 { } /* end */
7357};
7358
7359static struct hda_channel_mode alc882_sixstack_modes[2] = {
7360 { 6, alc882_sixstack_ch6_init },
7361 { 8, alc882_sixstack_ch8_init },
7362};
7363
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007364
7365/* Macbook Air 2,1 */
7366
7367static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7368 { 2, NULL },
7369};
7370
Takashi Iwai87350ad2007-08-16 18:19:38 +02007371/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007372 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007373 */
7374
7375/*
7376 * 2ch mode
7377 */
7378static struct hda_verb alc885_mbp_ch2_init[] = {
7379 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7380 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7381 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7382 { } /* end */
7383};
7384
7385/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007386 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007387 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007388static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007389 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7390 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7391 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7392 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7393 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7394 { } /* end */
7395};
7396
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007397static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007398 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007399 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007400};
7401
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007402/*
7403 * 2ch
7404 * Speakers/Woofer/HP = Front
7405 * LineIn = Input
7406 */
7407static struct hda_verb alc885_mb5_ch2_init[] = {
7408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7410 { } /* end */
7411};
7412
7413/*
7414 * 6ch mode
7415 * Speakers/HP = Front
7416 * Woofer = LFE
7417 * LineIn = Surround
7418 */
7419static struct hda_verb alc885_mb5_ch6_init[] = {
7420 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7423 { } /* end */
7424};
7425
7426static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7427 { 2, alc885_mb5_ch2_init },
7428 { 6, alc885_mb5_ch6_init },
7429};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007430
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007431#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007432
7433/*
7434 * 2ch mode
7435 */
7436static struct hda_verb alc883_4ST_ch2_init[] = {
7437 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7438 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7439 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7440 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7441 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7442 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7443 { } /* end */
7444};
7445
7446/*
7447 * 4ch mode
7448 */
7449static struct hda_verb alc883_4ST_ch4_init[] = {
7450 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7451 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7452 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7453 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7454 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7455 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7456 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7457 { } /* end */
7458};
7459
7460/*
7461 * 6ch mode
7462 */
7463static struct hda_verb alc883_4ST_ch6_init[] = {
7464 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7465 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7466 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7467 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7468 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7469 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7470 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7471 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7472 { } /* end */
7473};
7474
7475/*
7476 * 8ch mode
7477 */
7478static struct hda_verb alc883_4ST_ch8_init[] = {
7479 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7480 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7481 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7482 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7483 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7484 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7485 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7486 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7487 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7488 { } /* end */
7489};
7490
7491static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7492 { 2, alc883_4ST_ch2_init },
7493 { 4, alc883_4ST_ch4_init },
7494 { 6, alc883_4ST_ch6_init },
7495 { 8, alc883_4ST_ch8_init },
7496};
7497
7498
7499/*
7500 * 2ch mode
7501 */
7502static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7503 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7504 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7505 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7506 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7507 { } /* end */
7508};
7509
7510/*
7511 * 4ch mode
7512 */
7513static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7514 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7515 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7517 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7518 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7519 { } /* end */
7520};
7521
7522/*
7523 * 6ch mode
7524 */
7525static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7526 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7528 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7529 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7530 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7531 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7532 { } /* end */
7533};
7534
7535static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7536 { 2, alc883_3ST_ch2_intel_init },
7537 { 4, alc883_3ST_ch4_intel_init },
7538 { 6, alc883_3ST_ch6_intel_init },
7539};
7540
7541/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007542 * 2ch mode
7543 */
7544static struct hda_verb alc889_ch2_intel_init[] = {
7545 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7546 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7547 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7548 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7549 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7550 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7551 { } /* end */
7552};
7553
7554/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007555 * 6ch mode
7556 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007557static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007558 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7559 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7560 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7561 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7564 { } /* end */
7565};
7566
7567/*
7568 * 8ch mode
7569 */
7570static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007571 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7572 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7573 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7574 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007576 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7577 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007578 { } /* end */
7579};
7580
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007581static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7582 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007583 { 6, alc889_ch6_intel_init },
7584 { 8, alc889_ch8_intel_init },
7585};
7586
7587/*
7588 * 6ch mode
7589 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007590static struct hda_verb alc883_sixstack_ch6_init[] = {
7591 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7592 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7593 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7594 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7595 { } /* end */
7596};
7597
7598/*
7599 * 8ch mode
7600 */
7601static struct hda_verb alc883_sixstack_ch8_init[] = {
7602 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7605 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7606 { } /* end */
7607};
7608
7609static struct hda_channel_mode alc883_sixstack_modes[2] = {
7610 { 6, alc883_sixstack_ch6_init },
7611 { 8, alc883_sixstack_ch8_init },
7612};
7613
7614
Linus Torvalds1da177e2005-04-16 15:20:36 -07007615/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7616 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7617 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007618static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007619 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007620 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007621 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007622 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007623 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7624 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007625 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7626 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007627 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007628 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007629 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7630 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7631 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7632 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7633 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7634 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007635 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007636 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7637 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007638 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007639 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007640 { } /* end */
7641};
7642
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007643/* Macbook Air 2,1 same control for HP and internal Speaker */
7644
7645static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7646 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7647 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7648 { }
7649};
7650
7651
Takashi Iwai87350ad2007-08-16 18:19:38 +02007652static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007653 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7654 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7656 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7657 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007658 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7659 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007660 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7661 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007662 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007663 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7664 { } /* end */
7665};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007666
7667static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7669 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7670 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7671 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7672 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7673 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307674 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7675 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307676 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7677 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7679 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7680 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7681 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7682 { } /* end */
7683};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007684
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007685static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7686 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7687 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7688 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7689 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7690 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7691 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7692 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7693 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7694 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7695 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7696 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7697 { } /* end */
7698};
7699
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007700static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007701 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7702 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007703 { } /* end */
7704};
7705
7706
Kailang Yangbdd148a2007-05-08 15:19:08 +02007707static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7708 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7709 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7710 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7711 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7712 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7713 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7714 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7715 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7716 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007717 { } /* end */
7718};
7719
Kailang Yang272a5272007-05-14 11:00:38 +02007720static struct snd_kcontrol_new alc882_targa_mixer[] = {
7721 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7722 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7723 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7724 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7725 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7726 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7727 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007730 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007731 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7732 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007733 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007734 { } /* end */
7735};
7736
7737/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7738 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7739 */
7740static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7741 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7742 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7744 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7745 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7746 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7748 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7749 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7750 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7752 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007753 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007754 { } /* end */
7755};
7756
Takashi Iwai914759b2007-09-06 14:52:04 +02007757static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7758 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7759 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7760 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7761 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7762 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7763 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7764 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7765 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007768 { } /* end */
7769};
7770
Kailang Yangdf694da2005-12-05 19:42:22 +01007771static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7772 {
7773 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7774 .name = "Channel Mode",
7775 .info = alc_ch_mode_info,
7776 .get = alc_ch_mode_get,
7777 .put = alc_ch_mode_put,
7778 },
7779 { } /* end */
7780};
7781
Takashi Iwai4953550a2009-06-30 15:28:30 +02007782static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007783 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007784 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7785 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007786 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007787 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7788 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007789 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007790 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7791 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007792 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007793 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7794 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007795
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007796 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007798 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007799 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007800 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007801 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007802 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007804 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007805 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007806 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007807 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007808 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007809 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007810 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007811 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007812 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007813 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007814 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7815 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007816 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007817 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7818 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007819 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007820 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7821 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7822 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7823 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7824 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007825 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007826 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007827
7828 /* FIXME: use matrix-type input source selection */
7829 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007830 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007831 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007832 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007833 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007834 /* ADC2: mute amp left and right */
7835 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007836 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007837 /* ADC3: mute amp left and right */
7838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007839 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007840
7841 { }
7842};
7843
Takashi Iwai4953550a2009-06-30 15:28:30 +02007844static struct hda_verb alc882_adc1_init_verbs[] = {
7845 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7847 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7848 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7849 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7850 /* ADC1: mute amp left and right */
7851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7852 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7853 { }
7854};
7855
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007856static struct hda_verb alc882_eapd_verbs[] = {
7857 /* change to EAPD mode */
7858 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007859 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007860 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007861};
7862
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007863static struct hda_verb alc889_eapd_verbs[] = {
7864 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7865 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7866 { }
7867};
7868
Wu Fengguang6732bd02009-07-30 09:19:14 +02007869static struct hda_verb alc_hp15_unsol_verbs[] = {
7870 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7872 {}
7873};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007874
7875static struct hda_verb alc885_init_verbs[] = {
7876 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007877 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7878 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007879 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007880 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7881 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007882 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007883 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7884 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007885 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007886 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7887 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007888
7889 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007891 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7892 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7893 /* Front Pin: output 0 (0x0c) */
7894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7895 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7896 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7897 /* Rear Pin: output 1 (0x0d) */
7898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7899 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7900 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7901 /* CLFE Pin: output 2 (0x0e) */
7902 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7903 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7904 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7905 /* Side Pin: output 3 (0x0f) */
7906 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7908 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7909 /* Mic (rear) pin: input vref at 80% */
7910 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7911 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7912 /* Front Mic pin: input vref at 80% */
7913 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7914 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7915 /* Line In pin: input */
7916 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7917 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7918
7919 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7920 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007921 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007922 /* Input mixer2 */
7923 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007924 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007925 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007926 /* ADC2: mute amp left and right */
7927 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7928 /* ADC3: mute amp left and right */
7929 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7930
7931 { }
7932};
7933
7934static struct hda_verb alc885_init_input_verbs[] = {
7935 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7936 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7937 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7938 { }
7939};
7940
7941
7942/* Unmute Selector 24h and set the default input to front mic */
7943static struct hda_verb alc889_init_input_verbs[] = {
7944 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7946 { }
7947};
7948
7949
Takashi Iwai4953550a2009-06-30 15:28:30 +02007950#define alc883_init_verbs alc882_base_init_verbs
7951
Tobin Davis9102cd12006-12-15 10:02:12 +01007952/* Mac Pro test */
7953static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7955 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007959 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007960 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7961 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007962 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007963 { } /* end */
7964};
7965
7966static struct hda_verb alc882_macpro_init_verbs[] = {
7967 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7970 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7971 /* Front Pin: output 0 (0x0c) */
7972 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7973 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7974 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7975 /* Front Mic pin: input vref at 80% */
7976 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7977 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7978 /* Speaker: output */
7979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7980 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7981 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7982 /* Headphone output (output 0 - 0x0c) */
7983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7984 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7985 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7986
7987 /* FIXME: use matrix-type input source selection */
7988 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7989 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7994 /* Input mixer2 */
7995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7996 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7997 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7998 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7999 /* Input mixer3 */
8000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8001 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8004 /* ADC1: mute amp left and right */
8005 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8006 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8007 /* ADC2: mute amp left and right */
8008 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8009 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8010 /* ADC3: mute amp left and right */
8011 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8012 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8013
8014 { }
8015};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008016
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008017/* Macbook 5,1 */
8018static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008019 /* DACs */
8020 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8021 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8022 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8023 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008024 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008025 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008028 /* Surround mixer */
8029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8030 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8031 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8032 /* LFE mixer */
8033 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8034 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8036 /* HP mixer */
8037 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8039 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8040 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008041 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8042 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008043 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8044 /* LFE Pin (0x0e) */
8045 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8047 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8048 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8050 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008051 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308052 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008053 /* Front Mic pin: input vref at 80% */
8054 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8055 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8056 /* Line In pin */
8057 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8058 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8059
Alex Murrayb8f171e2010-06-14 12:08:43 +09308060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008063 { }
8064};
8065
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008066/* Macmini 3,1 */
8067static struct hda_verb alc885_macmini3_init_verbs[] = {
8068 /* DACs */
8069 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8070 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8071 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8072 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8073 /* Front mixer */
8074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8077 /* Surround mixer */
8078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8079 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8081 /* LFE mixer */
8082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8083 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8084 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8085 /* HP mixer */
8086 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8087 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8088 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8089 /* Front Pin (0x0c) */
8090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8092 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8093 /* LFE Pin (0x0e) */
8094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8096 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8097 /* HP Pin (0x0f) */
8098 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8099 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8100 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8101 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8102 /* Line In pin */
8103 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8104 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8105
8106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8110 { }
8111};
8112
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008113
8114static struct hda_verb alc885_mba21_init_verbs[] = {
8115 /*Internal and HP Speaker Mixer*/
8116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8117 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8119 /*Internal Speaker Pin (0x0c)*/
8120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8122 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8123 /* HP Pin: output 0 (0x0e) */
8124 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8125 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8126 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8127 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8128 /* Line in (is hp when jack connected)*/
8129 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8130 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8131
8132 { }
8133 };
8134
8135
Takashi Iwai87350ad2007-08-16 18:19:38 +02008136/* Macbook Pro rev3 */
8137static struct hda_verb alc885_mbp3_init_verbs[] = {
8138 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8142 /* Rear mixer */
8143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008146 /* HP mixer */
8147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8149 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008150 /* Front Pin: output 0 (0x0c) */
8151 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8152 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8153 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008154 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8157 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008158 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8159 /* Mic (rear) pin: input vref at 80% */
8160 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8162 /* Front Mic pin: input vref at 80% */
8163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8165 /* Line In pin: use output 1 when in LineOut mode */
8166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8168 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8169
8170 /* FIXME: use matrix-type input source selection */
8171 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8172 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8177 /* Input mixer2 */
8178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8182 /* Input mixer3 */
8183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8187 /* ADC1: mute amp left and right */
8188 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8189 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8190 /* ADC2: mute amp left and right */
8191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8192 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8193 /* ADC3: mute amp left and right */
8194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8195 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8196
8197 { }
8198};
8199
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008200/* iMac 9,1 */
8201static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008202 /* Internal Speaker Pin (0x0c) */
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8204 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8205 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8206 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8207 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8208 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8209 /* HP Pin: Rear */
8210 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8211 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8212 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8213 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8214 /* Line in Rear */
8215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8217 /* Front Mic pin: input vref at 80% */
8218 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8219 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008220 /* Rear mixer */
8221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8223 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008224 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8228 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008233 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008238 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008243 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008244 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8245 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008246 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008247 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8248 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008249 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8251 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008252 { }
8253};
8254
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008255/* iMac 24 mixer. */
8256static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8257 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8258 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8259 { } /* end */
8260};
8261
8262/* iMac 24 init verbs. */
8263static struct hda_verb alc885_imac24_init_verbs[] = {
8264 /* Internal speakers: output 0 (0x0c) */
8265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8267 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8268 /* Internal speakers: output 0 (0x0c) */
8269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8271 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8272 /* Headphone: output 0 (0x0c) */
8273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8275 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8276 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8277 /* Front Mic: input vref at 80% */
8278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8280 { }
8281};
8282
8283/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008284static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008285{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008286 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008287
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008288 spec->autocfg.hp_pins[0] = 0x14;
8289 spec->autocfg.speaker_pins[0] = 0x18;
8290 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008291}
8292
Takashi Iwai9d54f082010-02-22 08:34:40 +01008293#define alc885_mb5_setup alc885_imac24_setup
8294#define alc885_macmini3_setup alc885_imac24_setup
8295
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008296/* Macbook Air 2,1 */
8297static void alc885_mba21_setup(struct hda_codec *codec)
8298{
8299 struct alc_spec *spec = codec->spec;
8300
8301 spec->autocfg.hp_pins[0] = 0x14;
8302 spec->autocfg.speaker_pins[0] = 0x18;
8303}
8304
8305
8306
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008307static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008308{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008309 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008310
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008311 spec->autocfg.hp_pins[0] = 0x15;
8312 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008313}
8314
Takashi Iwai9d54f082010-02-22 08:34:40 +01008315static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308316{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008317 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308318
Takashi Iwai9d54f082010-02-22 08:34:40 +01008319 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008320 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008321 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008322}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008323
Kailang Yang272a5272007-05-14 11:00:38 +02008324static struct hda_verb alc882_targa_verbs[] = {
8325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8327
8328 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008330
Kailang Yang272a5272007-05-14 11:00:38 +02008331 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8332 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8333 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8334
8335 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008336 { } /* end */
8337};
8338
8339/* toggle speaker-output according to the hp-jack state */
8340static void alc882_targa_automute(struct hda_codec *codec)
8341{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008342 struct alc_spec *spec = codec->spec;
8343 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008344 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008345 spec->jack_present ? 1 : 3);
8346}
8347
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008348static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008349{
8350 struct alc_spec *spec = codec->spec;
8351
8352 spec->autocfg.hp_pins[0] = 0x14;
8353 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008354}
8355
8356static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8357{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008358 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008359 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008360}
8361
8362static struct hda_verb alc882_asus_a7j_verbs[] = {
8363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8365
8366 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8367 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8368 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008369
Kailang Yang272a5272007-05-14 11:00:38 +02008370 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8372 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8373
8374 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8375 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8376 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8377 { } /* end */
8378};
8379
Takashi Iwai914759b2007-09-06 14:52:04 +02008380static struct hda_verb alc882_asus_a7m_verbs[] = {
8381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8383
8384 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8386 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008387
Takashi Iwai914759b2007-09-06 14:52:04 +02008388 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8389 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8390 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8391
8392 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8393 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8394 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8395 { } /* end */
8396};
8397
Tobin Davis9102cd12006-12-15 10:02:12 +01008398static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8399{
8400 unsigned int gpiostate, gpiomask, gpiodir;
8401
8402 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8403 AC_VERB_GET_GPIO_DATA, 0);
8404
8405 if (!muted)
8406 gpiostate |= (1 << pin);
8407 else
8408 gpiostate &= ~(1 << pin);
8409
8410 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8411 AC_VERB_GET_GPIO_MASK, 0);
8412 gpiomask |= (1 << pin);
8413
8414 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8415 AC_VERB_GET_GPIO_DIRECTION, 0);
8416 gpiodir |= (1 << pin);
8417
8418
8419 snd_hda_codec_write(codec, codec->afg, 0,
8420 AC_VERB_SET_GPIO_MASK, gpiomask);
8421 snd_hda_codec_write(codec, codec->afg, 0,
8422 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8423
8424 msleep(1);
8425
8426 snd_hda_codec_write(codec, codec->afg, 0,
8427 AC_VERB_SET_GPIO_DATA, gpiostate);
8428}
8429
Takashi Iwai7debbe52007-08-16 15:01:03 +02008430/* set up GPIO at initialization */
8431static void alc885_macpro_init_hook(struct hda_codec *codec)
8432{
8433 alc882_gpio_mute(codec, 0, 0);
8434 alc882_gpio_mute(codec, 1, 0);
8435}
8436
8437/* set up GPIO and update auto-muting at initialization */
8438static void alc885_imac24_init_hook(struct hda_codec *codec)
8439{
8440 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008441 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008442}
8443
Kailang Yangdf694da2005-12-05 19:42:22 +01008444/*
8445 * generic initialization of ADC, input mixers and output mixers
8446 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008447static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008448 /*
8449 * Unmute ADC0-2 and set the default input to mic-in
8450 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008451 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8453 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8455
Kailang Yangdf694da2005-12-05 19:42:22 +01008456 /*
8457 * Set up output mixers (0x0c - 0x0f)
8458 */
8459 /* set vol=0 to output mixers */
8460 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8461 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8462 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8463 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8464 /* set up input amps for analog loopback */
8465 /* Amp Indices: DAC = 0, mixer = 1 */
8466 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8467 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8468 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8469 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8470 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8472 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8474 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8476
8477 /* FIXME: use matrix-type input source selection */
8478 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008479 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008480 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008481 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008483 { }
8484};
8485
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008486/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8487static struct hda_verb alc889A_mb31_ch2_init[] = {
8488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8489 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8490 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8491 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8492 { } /* end */
8493};
8494
8495/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8496static struct hda_verb alc889A_mb31_ch4_init[] = {
8497 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8499 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8500 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8501 { } /* end */
8502};
8503
8504/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8505static struct hda_verb alc889A_mb31_ch5_init[] = {
8506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8510 { } /* end */
8511};
8512
8513/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8514static struct hda_verb alc889A_mb31_ch6_init[] = {
8515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8516 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8519 { } /* end */
8520};
8521
8522static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8523 { 2, alc889A_mb31_ch2_init },
8524 { 4, alc889A_mb31_ch4_init },
8525 { 5, alc889A_mb31_ch5_init },
8526 { 6, alc889A_mb31_ch6_init },
8527};
8528
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008529static struct hda_verb alc883_medion_eapd_verbs[] = {
8530 /* eanable EAPD on medion laptop */
8531 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8532 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8533 { }
8534};
8535
Takashi Iwai4953550a2009-06-30 15:28:30 +02008536#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008537
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008538static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8539 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8540 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8541 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8542 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8543 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8544 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8545 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8548 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8549 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8550 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8551 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008552 { } /* end */
8553};
8554
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008555static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008556 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8557 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8558 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8559 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8560 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8562 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8563 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8564 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8565 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008566 { } /* end */
8567};
8568
Jiang zhefb97dc62008-03-06 11:07:11 +01008569static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8571 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8572 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8573 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8575 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8577 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8578 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8579 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008580 { } /* end */
8581};
8582
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008583static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8584 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8585 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8587 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8588 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8589 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8590 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8591 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008592 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008593 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8594 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008595 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008596 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008597 { } /* end */
8598};
8599
8600static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8602 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8604 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8605 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8606 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8607 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8608 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8609 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8612 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8613 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8614 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008615 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8617 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008618 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008620 { } /* end */
8621};
8622
Jiang zhe17bba1b2008-06-04 12:11:07 +02008623static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8626 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8627 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8628 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8629 HDA_OUTPUT),
8630 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8631 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8632 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8633 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8634 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8635 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8636 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8637 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8639 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8640 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8641 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8642 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8643 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008644 { } /* end */
8645};
8646
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008647static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8649 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8650 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8651 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8652 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8653 HDA_OUTPUT),
8654 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8655 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8656 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8657 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8658 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8659 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8660 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8661 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8663 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8665 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8666 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8667 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8668 { } /* end */
8669};
8670
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008671static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008672 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008673 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008674 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008675 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008676 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8677 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008678 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8679 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008680 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8681 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8682 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8683 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8684 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008686 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8688 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008689 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008690 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008691 { } /* end */
8692};
8693
Sasha Alexandrc2592492009-06-16 14:52:54 -04008694static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008696 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008697 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008698 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008699 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8700 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8701 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8702 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8703 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8704 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8705 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8706 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8707 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8708 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8709 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008710 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008711 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008712 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008713};
Kailang Yangccc656c2006-10-17 12:32:26 +02008714
Sasha Alexandrc2592492009-06-16 14:52:54 -04008715static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008716 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008717 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008718 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008719 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008723 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008724 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008725 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8726 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8727 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008728 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008729};
Kailang Yangccc656c2006-10-17 12:32:26 +02008730
Takashi Iwaib99dba32009-09-17 18:23:00 +02008731static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8732 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8733 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8734 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8735 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8736 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8737 { } /* end */
8738};
8739
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008740static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8741 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8742 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008743 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8744 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008745 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8746 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8747 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8748 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008749 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008750};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008751
Kailang Yang272a5272007-05-14 11:00:38 +02008752static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8753 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8754 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8756 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8757 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8758 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8759 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008760 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8761 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008762 { } /* end */
8763};
8764
8765static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8766 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8767 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8768 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8769 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8770 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8772 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008775 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008776};
Kailang Yang272a5272007-05-14 11:00:38 +02008777
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008778static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8779 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8780 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8781 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8783 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8784 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8785 { } /* end */
8786};
8787
8788static struct hda_verb alc883_medion_wim2160_verbs[] = {
8789 /* Unmute front mixer */
8790 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8791 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8792
8793 /* Set speaker pin to front mixer */
8794 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8795
8796 /* Init headphone pin */
8797 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8798 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8799 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8800 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8801
8802 { } /* end */
8803};
8804
8805/* toggle speaker-output according to the hp-jack state */
8806static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8807{
8808 struct alc_spec *spec = codec->spec;
8809
8810 spec->autocfg.hp_pins[0] = 0x1a;
8811 spec->autocfg.speaker_pins[0] = 0x15;
8812}
8813
Tobin Davis2880a862007-08-07 11:50:26 +02008814static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008815 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8816 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008818 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8819 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008820 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8821 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8822 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008823 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008824};
Tobin Davis2880a862007-08-07 11:50:26 +02008825
Tony Vroond2fd4b02009-06-21 00:40:10 +01008826static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8827 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008828 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008829 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8830 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008831 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8832 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8833 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8835 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8836 { } /* end */
8837};
8838
Kailang Yange2757d52008-08-26 13:17:46 +02008839static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8840 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8841 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8843 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8844 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8845 0x0d, 1, 0x0, HDA_OUTPUT),
8846 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8847 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8848 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8849 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8850 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8854 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8856 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008861 { } /* end */
8862};
8863
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008864static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8865 /* Output mixers */
8866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8867 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8869 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8870 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8871 HDA_OUTPUT),
8872 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8873 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8874 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8875 /* Output switches */
8876 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8877 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8878 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8879 /* Boost mixers */
8880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8881 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8882 /* Input mixers */
8883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8887 { } /* end */
8888};
8889
Guido Günther3e1647c2009-06-05 00:47:26 +02008890static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8891 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8892 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8895 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8897 { } /* end */
8898};
8899
Kailang Yange2757d52008-08-26 13:17:46 +02008900static struct hda_bind_ctls alc883_bind_cap_vol = {
8901 .ops = &snd_hda_bind_vol,
8902 .values = {
8903 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8904 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8905 0
8906 },
8907};
8908
8909static struct hda_bind_ctls alc883_bind_cap_switch = {
8910 .ops = &snd_hda_bind_sw,
8911 .values = {
8912 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8913 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8914 0
8915 },
8916};
8917
8918static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8919 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8920 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8921 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8922 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8923 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8925 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8926 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008927 { } /* end */
8928};
8929
8930static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008931 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8932 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8933 {
8934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8935 /* .name = "Capture Source", */
8936 .name = "Input Source",
8937 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008938 .info = alc_mux_enum_info,
8939 .get = alc_mux_enum_get,
8940 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008941 },
8942 { } /* end */
8943};
8944
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008945static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8946 {
8947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8948 .name = "Channel Mode",
8949 .info = alc_ch_mode_info,
8950 .get = alc_ch_mode_get,
8951 .put = alc_ch_mode_put,
8952 },
8953 { } /* end */
8954};
8955
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008956/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008957static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008958{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008959 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008960
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008961 spec->autocfg.hp_pins[0] = 0x15;
8962 spec->autocfg.speaker_pins[0] = 0x14;
8963 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008964}
8965
8966/* auto-toggle front mic */
8967/*
8968static void alc883_mitac_mic_automute(struct hda_codec *codec)
8969{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008970 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008971
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008972 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8973}
8974*/
8975
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008976static struct hda_verb alc883_mitac_verbs[] = {
8977 /* HP */
8978 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8980 /* Subwoofer */
8981 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8982 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8983
8984 /* enable unsolicited event */
8985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8986 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8987
8988 { } /* end */
8989};
8990
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308991static struct hda_verb alc883_clevo_m540r_verbs[] = {
8992 /* HP */
8993 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8995 /* Int speaker */
8996 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8997
8998 /* enable unsolicited event */
8999 /*
9000 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9001 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9002 */
9003
9004 { } /* end */
9005};
9006
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009007static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009008 /* HP */
9009 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9011 /* Int speaker */
9012 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9014
9015 /* enable unsolicited event */
9016 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009017 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009018
9019 { } /* end */
9020};
9021
Jiang zhefb97dc62008-03-06 11:07:11 +01009022static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9023 /* HP */
9024 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9025 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9026 /* Subwoofer */
9027 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9029
9030 /* enable unsolicited event */
9031 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9032
9033 { } /* end */
9034};
9035
Sasha Alexandrc2592492009-06-16 14:52:54 -04009036static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9039
9040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9041 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009042
David Heidelberger64a8be72009-06-08 16:15:18 +02009043/* Connect Line-Out side jack (SPDIF) to Side */
9044 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9045 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9046 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9047/* Connect Mic jack to CLFE */
9048 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9049 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9050 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9051/* Connect Line-in jack to Surround */
9052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9053 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9054 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9055/* Connect HP out jack to Front */
9056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9057 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9058 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009059
9060 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009061
9062 { } /* end */
9063};
9064
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009065static struct hda_verb alc883_lenovo_101e_verbs[] = {
9066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9067 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9068 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9069 { } /* end */
9070};
9071
Kailang Yang272a5272007-05-14 11:00:38 +02009072static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9073 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9075 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9077 { } /* end */
9078};
9079
9080static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9084 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9085 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9086 { } /* end */
9087};
9088
Kailang Yang189609a2007-08-20 11:31:23 +02009089static struct hda_verb alc883_haier_w66_verbs[] = {
9090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9092
9093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9094
9095 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9097 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9099 { } /* end */
9100};
9101
Kailang Yange2757d52008-08-26 13:17:46 +02009102static struct hda_verb alc888_lenovo_sky_verbs[] = {
9103 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9104 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9105 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9106 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9107 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9109 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9110 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9111 { } /* end */
9112};
9113
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009114static struct hda_verb alc888_6st_dell_verbs[] = {
9115 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9116 { }
9117};
9118
Guido Günther3e1647c2009-06-05 00:47:26 +02009119static struct hda_verb alc883_vaiott_verbs[] = {
9120 /* HP */
9121 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9123
9124 /* enable unsolicited event */
9125 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9126
9127 { } /* end */
9128};
9129
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009130static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009131{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009132 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009133
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009134 spec->autocfg.hp_pins[0] = 0x1b;
9135 spec->autocfg.speaker_pins[0] = 0x14;
9136 spec->autocfg.speaker_pins[1] = 0x16;
9137 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009138}
9139
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009140static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009141 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009142 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9143 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009144 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009145 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009146};
9147
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009148/*
9149 * 2ch mode
9150 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009151static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009152 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9153 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9154 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9155 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009156 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009157};
9158
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009159/*
9160 * 4ch mode
9161 */
9162static struct hda_verb alc888_3st_hp_4ch_init[] = {
9163 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9164 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9165 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9166 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9167 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9168 { } /* end */
9169};
9170
9171/*
9172 * 6ch mode
9173 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009174static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009175 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9176 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009177 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009178 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9179 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009180 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9181 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009182};
9183
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009184static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009185 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009186 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009187 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009188};
9189
Kailang Yang272a5272007-05-14 11:00:38 +02009190/* toggle front-jack and RCA according to the hp-jack state */
9191static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9192{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009193 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009194
Takashi Iwai47fd8302007-08-10 17:11:07 +02009195 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9196 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9197 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9198 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009199}
9200
9201/* toggle RCA according to the front-jack state */
9202static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9203{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009204 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009205
Takashi Iwai47fd8302007-08-10 17:11:07 +02009206 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9207 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009208}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009209
Kailang Yang272a5272007-05-14 11:00:38 +02009210static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9211 unsigned int res)
9212{
9213 if ((res >> 26) == ALC880_HP_EVENT)
9214 alc888_lenovo_ms7195_front_automute(codec);
9215 if ((res >> 26) == ALC880_FRONT_EVENT)
9216 alc888_lenovo_ms7195_rca_automute(codec);
9217}
9218
9219static struct hda_verb alc883_medion_md2_verbs[] = {
9220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9221 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9222
9223 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9224
9225 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9226 { } /* end */
9227};
9228
9229/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009230static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009231{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009232 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009233
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009234 spec->autocfg.hp_pins[0] = 0x14;
9235 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009236}
9237
Kailang Yangccc656c2006-10-17 12:32:26 +02009238/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009239#define alc883_targa_init_hook alc882_targa_init_hook
9240#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009241
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009242static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9243{
9244 unsigned int present;
9245
Takashi Iwaid56757a2009-11-18 08:00:14 +01009246 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009247 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9248 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9249}
9250
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009251static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009252{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009253 struct alc_spec *spec = codec->spec;
9254
9255 spec->autocfg.hp_pins[0] = 0x15;
9256 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009257}
9258
9259static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9260{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009261 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009262 alc883_clevo_m720_mic_automute(codec);
9263}
9264
9265static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009266 unsigned int res)
9267{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009268 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009269 case ALC880_MIC_EVENT:
9270 alc883_clevo_m720_mic_automute(codec);
9271 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009272 default:
9273 alc_automute_amp_unsol_event(codec, res);
9274 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009275 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009276}
9277
Jiang zhefb97dc62008-03-06 11:07:11 +01009278/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009279static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009280{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009281 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009282
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009283 spec->autocfg.hp_pins[0] = 0x14;
9284 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009285}
9286
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009287static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009288{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009289 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009290
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009291 spec->autocfg.hp_pins[0] = 0x1b;
9292 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009293}
9294
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009295static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9296{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009297 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009298
Takashi Iwai47fd8302007-08-10 17:11:07 +02009299 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9300 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009301}
9302
9303static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9304{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009305 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009306
Takashi Iwai47fd8302007-08-10 17:11:07 +02009307 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9308 HDA_AMP_MUTE, bits);
9309 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9310 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009311}
9312
9313static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9314 unsigned int res)
9315{
9316 if ((res >> 26) == ALC880_HP_EVENT)
9317 alc883_lenovo_101e_all_automute(codec);
9318 if ((res >> 26) == ALC880_FRONT_EVENT)
9319 alc883_lenovo_101e_ispeaker_automute(codec);
9320}
9321
Takashi Iwai676a9b52007-08-16 15:23:35 +02009322/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009323static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009324{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009325 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009326
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009327 spec->autocfg.hp_pins[0] = 0x14;
9328 spec->autocfg.speaker_pins[0] = 0x15;
9329 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009330}
9331
Kailang Yangd1a991a2007-08-15 16:21:59 +02009332static struct hda_verb alc883_acer_eapd_verbs[] = {
9333 /* HP Pin: output 0 (0x0c) */
9334 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9335 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9336 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9337 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009338 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009340 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009341 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9342 /* eanable EAPD on medion laptop */
9343 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9344 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009345 /* enable unsolicited event */
9346 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009347 { }
9348};
9349
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009350static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9351 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9352 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9353 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9354 { } /* end */
9355};
9356
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009357static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009358{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009359 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009360
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009361 spec->autocfg.hp_pins[0] = 0x1b;
9362 spec->autocfg.speaker_pins[0] = 0x14;
9363 spec->autocfg.speaker_pins[1] = 0x15;
9364 spec->autocfg.speaker_pins[2] = 0x16;
9365 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009366}
9367
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009368static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009369{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009370 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009371
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009372 spec->autocfg.hp_pins[0] = 0x1b;
9373 spec->autocfg.speaker_pins[0] = 0x14;
9374 spec->autocfg.speaker_pins[1] = 0x15;
9375 spec->autocfg.speaker_pins[2] = 0x16;
9376 spec->autocfg.speaker_pins[3] = 0x17;
9377 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009378}
9379
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009380static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009381{
9382 struct alc_spec *spec = codec->spec;
9383
9384 spec->autocfg.hp_pins[0] = 0x15;
9385 spec->autocfg.speaker_pins[0] = 0x14;
9386 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009387}
9388
Kailang Yange2757d52008-08-26 13:17:46 +02009389static struct hda_verb alc888_asus_m90v_verbs[] = {
9390 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9391 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9392 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9393 /* enable unsolicited event */
9394 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9395 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9396 { } /* end */
9397};
9398
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009399static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009400{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009401 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009402
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009403 spec->autocfg.hp_pins[0] = 0x1b;
9404 spec->autocfg.speaker_pins[0] = 0x14;
9405 spec->autocfg.speaker_pins[1] = 0x15;
9406 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009407 spec->ext_mic.pin = 0x18;
9408 spec->int_mic.pin = 0x19;
9409 spec->ext_mic.mux_idx = 0;
9410 spec->int_mic.mux_idx = 1;
9411 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009412}
9413
9414static struct hda_verb alc888_asus_eee1601_verbs[] = {
9415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9416 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9417 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9420 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9421 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9422 /* enable unsolicited event */
9423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9424 { } /* end */
9425};
9426
Kailang Yange2757d52008-08-26 13:17:46 +02009427static void alc883_eee1601_inithook(struct hda_codec *codec)
9428{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009429 struct alc_spec *spec = codec->spec;
9430
9431 spec->autocfg.hp_pins[0] = 0x14;
9432 spec->autocfg.speaker_pins[0] = 0x1b;
9433 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009434}
9435
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009436static struct hda_verb alc889A_mb31_verbs[] = {
9437 /* Init rear pin (used as headphone output) */
9438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9439 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9440 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9441 /* Init line pin (used as output in 4ch and 6ch mode) */
9442 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9443 /* Init line 2 pin (used as headphone out by default) */
9444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9446 { } /* end */
9447};
9448
9449/* Mute speakers according to the headphone jack state */
9450static void alc889A_mb31_automute(struct hda_codec *codec)
9451{
9452 unsigned int present;
9453
9454 /* Mute only in 2ch or 4ch mode */
9455 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9456 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009457 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009458 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9459 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9460 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9461 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9462 }
9463}
9464
9465static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9466{
9467 if ((res >> 26) == ALC880_HP_EVENT)
9468 alc889A_mb31_automute(codec);
9469}
9470
Takashi Iwai4953550a2009-06-30 15:28:30 +02009471
Takashi Iwaicb53c622007-08-10 17:21:45 +02009472#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009473#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009474#endif
9475
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009476/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009477#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9478#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9479#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9480#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9481
9482static hda_nid_t alc883_slave_dig_outs[] = {
9483 ALC1200_DIGOUT_NID, 0,
9484};
9485
9486static hda_nid_t alc1200_slave_dig_outs[] = {
9487 ALC883_DIGOUT_NID, 0,
9488};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009489
9490/*
9491 * configuration and preset
9492 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009493static const char *alc882_models[ALC882_MODEL_LAST] = {
9494 [ALC882_3ST_DIG] = "3stack-dig",
9495 [ALC882_6ST_DIG] = "6stack-dig",
9496 [ALC882_ARIMA] = "arima",
9497 [ALC882_W2JC] = "w2jc",
9498 [ALC882_TARGA] = "targa",
9499 [ALC882_ASUS_A7J] = "asus-a7j",
9500 [ALC882_ASUS_A7M] = "asus-a7m",
9501 [ALC885_MACPRO] = "macpro",
9502 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009503 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009504 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009505 [ALC885_MBP3] = "mbp3",
9506 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009507 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009508 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009509 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9510 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009511 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009512 [ALC883_TARGA_DIG] = "targa-dig",
9513 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009514 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009515 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009516 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009517 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009518 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009519 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009520 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009521 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009522 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009523 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009524 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009525 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009526 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9527 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009528 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009529 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009530 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009531 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009532 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309533 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009534 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009535 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009536 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009537 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009538 [ALC889A_INTEL] = "intel-alc889a",
9539 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009540 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009541 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009542 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009543 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009544};
9545
Takashi Iwai4953550a2009-06-30 15:28:30 +02009546static struct snd_pci_quirk alc882_cfg_tbl[] = {
9547 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9548
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009549 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009550 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009551 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009552 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9553 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009554 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009555 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9556 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009557 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009558 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009559 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9560 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009561 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9562 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009563 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9564 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009565 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009566 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009567 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009568 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009569 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9570 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009571 /* default Acer -- disabled as it causes more problems.
9572 * model=auto should work fine now
9573 */
9574 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009575
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009576 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009577
Tobin Davisfebe3372007-06-12 11:27:46 +02009578 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009579 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9580 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009581 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009582 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009583 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009584
9585 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9586 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9587 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009588 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009589 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9590 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9591 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009592 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009593 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009594 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009595 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009596
9597 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009598 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009599 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009600 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009601 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9602 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009603 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009604 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009605 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9606
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009607 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9608 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9609 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009610 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009611 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009612 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009613 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009614 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009615 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9616 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9617 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9618 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9619 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9620 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009621 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009622 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9623 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9624 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009625 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009626 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009627 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9628 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009629 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009630 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009631 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009632 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009633 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009634 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009635 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009636 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009637 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009638
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009639 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009640 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009641 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9642 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309643 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009644 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009645 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009646 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009647 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009648 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009649 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009650 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009651 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009652 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009653 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009654 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9655 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009656 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009657 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009658 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009659 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009660 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009661
Jiang zhe17bba1b2008-06-04 12:11:07 +02009662 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9663 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009664 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009665 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9666 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9667 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009668 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009669
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009670 {}
9671};
9672
Takashi Iwai4953550a2009-06-30 15:28:30 +02009673/* codec SSID table for Intel Mac */
9674static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9675 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9676 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9677 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9678 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9679 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9680 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9681 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009682 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009683 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009684 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009685 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009686 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9687 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9688 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009689 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009690 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009691 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009692 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9693 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009694 */
9695 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009696 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009697 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009698 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009699};
9700
Takashi Iwai4953550a2009-06-30 15:28:30 +02009701static struct alc_config_preset alc882_presets[] = {
9702 [ALC882_3ST_DIG] = {
9703 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009704 .init_verbs = { alc882_base_init_verbs,
9705 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009706 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9707 .dac_nids = alc882_dac_nids,
9708 .dig_out_nid = ALC882_DIGOUT_NID,
9709 .dig_in_nid = ALC882_DIGIN_NID,
9710 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9711 .channel_mode = alc882_ch_modes,
9712 .need_dac_fix = 1,
9713 .input_mux = &alc882_capture_source,
9714 },
9715 [ALC882_6ST_DIG] = {
9716 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009717 .init_verbs = { alc882_base_init_verbs,
9718 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009719 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9720 .dac_nids = alc882_dac_nids,
9721 .dig_out_nid = ALC882_DIGOUT_NID,
9722 .dig_in_nid = ALC882_DIGIN_NID,
9723 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9724 .channel_mode = alc882_sixstack_modes,
9725 .input_mux = &alc882_capture_source,
9726 },
9727 [ALC882_ARIMA] = {
9728 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009729 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9730 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009731 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9732 .dac_nids = alc882_dac_nids,
9733 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9734 .channel_mode = alc882_sixstack_modes,
9735 .input_mux = &alc882_capture_source,
9736 },
9737 [ALC882_W2JC] = {
9738 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009739 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9740 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9742 .dac_nids = alc882_dac_nids,
9743 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9744 .channel_mode = alc880_threestack_modes,
9745 .need_dac_fix = 1,
9746 .input_mux = &alc882_capture_source,
9747 .dig_out_nid = ALC882_DIGOUT_NID,
9748 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009749 [ALC885_MBA21] = {
9750 .mixers = { alc885_mba21_mixer },
9751 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9752 .num_dacs = 2,
9753 .dac_nids = alc882_dac_nids,
9754 .channel_mode = alc885_mba21_ch_modes,
9755 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9756 .input_mux = &alc882_capture_source,
9757 .unsol_event = alc_automute_amp_unsol_event,
9758 .setup = alc885_mba21_setup,
9759 .init_hook = alc_automute_amp,
9760 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009761 [ALC885_MBP3] = {
9762 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9763 .init_verbs = { alc885_mbp3_init_verbs,
9764 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009765 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009766 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009767 .hp_nid = 0x04,
9768 .channel_mode = alc885_mbp_4ch_modes,
9769 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770 .input_mux = &alc882_capture_source,
9771 .dig_out_nid = ALC882_DIGOUT_NID,
9772 .dig_in_nid = ALC882_DIGIN_NID,
9773 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009774 .setup = alc885_mbp3_setup,
9775 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776 },
9777 [ALC885_MB5] = {
9778 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9779 .init_verbs = { alc885_mb5_init_verbs,
9780 alc880_gpio1_init_verbs },
9781 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9782 .dac_nids = alc882_dac_nids,
9783 .channel_mode = alc885_mb5_6ch_modes,
9784 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9785 .input_mux = &mb5_capture_source,
9786 .dig_out_nid = ALC882_DIGOUT_NID,
9787 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009788 .unsol_event = alc_automute_amp_unsol_event,
9789 .setup = alc885_mb5_setup,
9790 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009791 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009792 [ALC885_MACMINI3] = {
9793 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9794 .init_verbs = { alc885_macmini3_init_verbs,
9795 alc880_gpio1_init_verbs },
9796 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9797 .dac_nids = alc882_dac_nids,
9798 .channel_mode = alc885_macmini3_6ch_modes,
9799 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9800 .input_mux = &macmini3_capture_source,
9801 .dig_out_nid = ALC882_DIGOUT_NID,
9802 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009803 .unsol_event = alc_automute_amp_unsol_event,
9804 .setup = alc885_macmini3_setup,
9805 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009806 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009807 [ALC885_MACPRO] = {
9808 .mixers = { alc882_macpro_mixer },
9809 .init_verbs = { alc882_macpro_init_verbs },
9810 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9811 .dac_nids = alc882_dac_nids,
9812 .dig_out_nid = ALC882_DIGOUT_NID,
9813 .dig_in_nid = ALC882_DIGIN_NID,
9814 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9815 .channel_mode = alc882_ch_modes,
9816 .input_mux = &alc882_capture_source,
9817 .init_hook = alc885_macpro_init_hook,
9818 },
9819 [ALC885_IMAC24] = {
9820 .mixers = { alc885_imac24_mixer },
9821 .init_verbs = { alc885_imac24_init_verbs },
9822 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9823 .dac_nids = alc882_dac_nids,
9824 .dig_out_nid = ALC882_DIGOUT_NID,
9825 .dig_in_nid = ALC882_DIGIN_NID,
9826 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9827 .channel_mode = alc882_ch_modes,
9828 .input_mux = &alc882_capture_source,
9829 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009830 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009831 .init_hook = alc885_imac24_init_hook,
9832 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009833 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009834 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009835 .init_verbs = { alc885_imac91_init_verbs,
9836 alc880_gpio1_init_verbs },
9837 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9838 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009839 .channel_mode = alc885_mba21_ch_modes,
9840 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9841 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009842 .dig_out_nid = ALC882_DIGOUT_NID,
9843 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009844 .unsol_event = alc_automute_amp_unsol_event,
9845 .setup = alc885_imac91_setup,
9846 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009847 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009848 [ALC882_TARGA] = {
9849 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009850 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009851 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009852 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9853 .dac_nids = alc882_dac_nids,
9854 .dig_out_nid = ALC882_DIGOUT_NID,
9855 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9856 .adc_nids = alc882_adc_nids,
9857 .capsrc_nids = alc882_capsrc_nids,
9858 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9859 .channel_mode = alc882_3ST_6ch_modes,
9860 .need_dac_fix = 1,
9861 .input_mux = &alc882_capture_source,
9862 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009863 .setup = alc882_targa_setup,
9864 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009865 },
9866 [ALC882_ASUS_A7J] = {
9867 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009868 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9869 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009870 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9871 .dac_nids = alc882_dac_nids,
9872 .dig_out_nid = ALC882_DIGOUT_NID,
9873 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9874 .adc_nids = alc882_adc_nids,
9875 .capsrc_nids = alc882_capsrc_nids,
9876 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9877 .channel_mode = alc882_3ST_6ch_modes,
9878 .need_dac_fix = 1,
9879 .input_mux = &alc882_capture_source,
9880 },
9881 [ALC882_ASUS_A7M] = {
9882 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009883 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9884 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009885 alc882_asus_a7m_verbs },
9886 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9887 .dac_nids = alc882_dac_nids,
9888 .dig_out_nid = ALC882_DIGOUT_NID,
9889 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9890 .channel_mode = alc880_threestack_modes,
9891 .need_dac_fix = 1,
9892 .input_mux = &alc882_capture_source,
9893 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009894 [ALC883_3ST_2ch_DIG] = {
9895 .mixers = { alc883_3ST_2ch_mixer },
9896 .init_verbs = { alc883_init_verbs },
9897 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9898 .dac_nids = alc883_dac_nids,
9899 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009900 .dig_in_nid = ALC883_DIGIN_NID,
9901 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9902 .channel_mode = alc883_3ST_2ch_modes,
9903 .input_mux = &alc883_capture_source,
9904 },
9905 [ALC883_3ST_6ch_DIG] = {
9906 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9907 .init_verbs = { alc883_init_verbs },
9908 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9909 .dac_nids = alc883_dac_nids,
9910 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009911 .dig_in_nid = ALC883_DIGIN_NID,
9912 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9913 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009914 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009916 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009917 [ALC883_3ST_6ch] = {
9918 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9919 .init_verbs = { alc883_init_verbs },
9920 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9921 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009922 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9923 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009924 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009925 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009926 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009927 [ALC883_3ST_6ch_INTEL] = {
9928 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9929 .init_verbs = { alc883_init_verbs },
9930 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9931 .dac_nids = alc883_dac_nids,
9932 .dig_out_nid = ALC883_DIGOUT_NID,
9933 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009934 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009935 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9936 .channel_mode = alc883_3ST_6ch_intel_modes,
9937 .need_dac_fix = 1,
9938 .input_mux = &alc883_3stack_6ch_intel,
9939 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009940 [ALC889A_INTEL] = {
9941 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009942 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9943 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009944 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9945 .dac_nids = alc883_dac_nids,
9946 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9947 .adc_nids = alc889_adc_nids,
9948 .dig_out_nid = ALC883_DIGOUT_NID,
9949 .dig_in_nid = ALC883_DIGIN_NID,
9950 .slave_dig_outs = alc883_slave_dig_outs,
9951 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9952 .channel_mode = alc889_8ch_intel_modes,
9953 .capsrc_nids = alc889_capsrc_nids,
9954 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009955 .setup = alc889_automute_setup,
9956 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009957 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009958 .need_dac_fix = 1,
9959 },
9960 [ALC889_INTEL] = {
9961 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9962 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009963 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9965 .dac_nids = alc883_dac_nids,
9966 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9967 .adc_nids = alc889_adc_nids,
9968 .dig_out_nid = ALC883_DIGOUT_NID,
9969 .dig_in_nid = ALC883_DIGIN_NID,
9970 .slave_dig_outs = alc883_slave_dig_outs,
9971 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9972 .channel_mode = alc889_8ch_intel_modes,
9973 .capsrc_nids = alc889_capsrc_nids,
9974 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009975 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009976 .init_hook = alc889_intel_init_hook,
9977 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009978 .need_dac_fix = 1,
9979 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009980 [ALC883_6ST_DIG] = {
9981 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9982 .init_verbs = { alc883_init_verbs },
9983 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9984 .dac_nids = alc883_dac_nids,
9985 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009986 .dig_in_nid = ALC883_DIGIN_NID,
9987 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9988 .channel_mode = alc883_sixstack_modes,
9989 .input_mux = &alc883_capture_source,
9990 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009991 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009992 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009993 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9994 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009995 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9996 .dac_nids = alc883_dac_nids,
9997 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009998 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9999 .channel_mode = alc883_3ST_6ch_modes,
10000 .need_dac_fix = 1,
10001 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010002 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010003 .setup = alc882_targa_setup,
10004 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010005 },
10006 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010007 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010008 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10009 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10011 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010012 .adc_nids = alc883_adc_nids_alt,
10013 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010014 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010015 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010016 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10017 .channel_mode = alc883_3ST_2ch_modes,
10018 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010019 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010020 .setup = alc882_targa_setup,
10021 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010022 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010023 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010024 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10025 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010026 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010027 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010028 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10029 .dac_nids = alc883_dac_nids,
10030 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10031 .adc_nids = alc883_adc_nids_rev,
10032 .capsrc_nids = alc883_capsrc_nids_rev,
10033 .dig_out_nid = ALC883_DIGOUT_NID,
10034 .dig_in_nid = ALC883_DIGIN_NID,
10035 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10036 .channel_mode = alc883_4ST_8ch_modes,
10037 .need_dac_fix = 1,
10038 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010039 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010040 .setup = alc882_targa_setup,
10041 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010042 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010043 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010044 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010045 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10046 * and the headphone jack. Turn this on and rely on the
10047 * standard mute methods whenever the user wants to turn
10048 * these outputs off.
10049 */
10050 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10051 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10052 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010053 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10054 .channel_mode = alc883_3ST_2ch_modes,
10055 .input_mux = &alc883_capture_source,
10056 },
Tobin Davis2880a862007-08-07 11:50:26 +020010057 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010058 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010059 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010060 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10061 .dac_nids = alc883_dac_nids,
10062 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010063 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10064 .channel_mode = alc883_3ST_2ch_modes,
10065 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010066 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010067 .setup = alc883_acer_aspire_setup,
10068 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010069 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010070 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010071 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010072 alc883_chmode_mixer },
10073 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10074 alc888_acer_aspire_4930g_verbs },
10075 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10076 .dac_nids = alc883_dac_nids,
10077 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10078 .adc_nids = alc883_adc_nids_rev,
10079 .capsrc_nids = alc883_capsrc_nids_rev,
10080 .dig_out_nid = ALC883_DIGOUT_NID,
10081 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10082 .channel_mode = alc883_3ST_6ch_modes,
10083 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010084 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010085 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010086 ARRAY_SIZE(alc888_2_capture_sources),
10087 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010088 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010089 .setup = alc888_acer_aspire_4930g_setup,
10090 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010091 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010092 [ALC888_ACER_ASPIRE_6530G] = {
10093 .mixers = { alc888_acer_aspire_6530_mixer },
10094 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10095 alc888_acer_aspire_6530g_verbs },
10096 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10097 .dac_nids = alc883_dac_nids,
10098 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10099 .adc_nids = alc883_adc_nids_rev,
10100 .capsrc_nids = alc883_capsrc_nids_rev,
10101 .dig_out_nid = ALC883_DIGOUT_NID,
10102 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10103 .channel_mode = alc883_3ST_2ch_modes,
10104 .num_mux_defs =
10105 ARRAY_SIZE(alc888_2_capture_sources),
10106 .input_mux = alc888_acer_aspire_6530_sources,
10107 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010108 .setup = alc888_acer_aspire_6530g_setup,
10109 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010110 },
Hector Martin3b315d72009-06-02 10:54:19 +020010111 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010112 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010113 alc883_chmode_mixer },
10114 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010115 alc889_acer_aspire_8930g_verbs,
10116 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010117 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10118 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010119 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10120 .adc_nids = alc889_adc_nids,
10121 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010122 .dig_out_nid = ALC883_DIGOUT_NID,
10123 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10124 .channel_mode = alc883_3ST_6ch_modes,
10125 .need_dac_fix = 1,
10126 .const_channel_count = 6,
10127 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010128 ARRAY_SIZE(alc889_capture_sources),
10129 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010130 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010131 .setup = alc889_acer_aspire_8930g_setup,
10132 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010133#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010134 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010135#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010136 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010137 [ALC888_ACER_ASPIRE_7730G] = {
10138 .mixers = { alc883_3ST_6ch_mixer,
10139 alc883_chmode_mixer },
10140 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10141 alc888_acer_aspire_7730G_verbs },
10142 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10143 .dac_nids = alc883_dac_nids,
10144 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10145 .adc_nids = alc883_adc_nids_rev,
10146 .capsrc_nids = alc883_capsrc_nids_rev,
10147 .dig_out_nid = ALC883_DIGOUT_NID,
10148 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10149 .channel_mode = alc883_3ST_6ch_modes,
10150 .need_dac_fix = 1,
10151 .const_channel_count = 6,
10152 .input_mux = &alc883_capture_source,
10153 .unsol_event = alc_automute_amp_unsol_event,
10154 .setup = alc888_acer_aspire_6530g_setup,
10155 .init_hook = alc_automute_amp,
10156 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010157 [ALC883_MEDION] = {
10158 .mixers = { alc883_fivestack_mixer,
10159 alc883_chmode_mixer },
10160 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010161 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010162 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10163 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010164 .adc_nids = alc883_adc_nids_alt,
10165 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010166 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010167 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10168 .channel_mode = alc883_sixstack_modes,
10169 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010170 },
Kailang Yang272a5272007-05-14 11:00:38 +020010171 [ALC883_MEDION_MD2] = {
10172 .mixers = { alc883_medion_md2_mixer},
10173 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10174 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10175 .dac_nids = alc883_dac_nids,
10176 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010177 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10178 .channel_mode = alc883_3ST_2ch_modes,
10179 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010180 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010181 .setup = alc883_medion_md2_setup,
10182 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010183 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010184 [ALC883_MEDION_WIM2160] = {
10185 .mixers = { alc883_medion_wim2160_mixer },
10186 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10187 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10188 .dac_nids = alc883_dac_nids,
10189 .dig_out_nid = ALC883_DIGOUT_NID,
10190 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10191 .adc_nids = alc883_adc_nids,
10192 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10193 .channel_mode = alc883_3ST_2ch_modes,
10194 .input_mux = &alc883_capture_source,
10195 .unsol_event = alc_automute_amp_unsol_event,
10196 .setup = alc883_medion_wim2160_setup,
10197 .init_hook = alc_automute_amp,
10198 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010199 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010200 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010201 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10202 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10203 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010204 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10205 .channel_mode = alc883_3ST_2ch_modes,
10206 .input_mux = &alc883_capture_source,
10207 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010208 [ALC883_CLEVO_M540R] = {
10209 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10210 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10211 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10212 .dac_nids = alc883_dac_nids,
10213 .dig_out_nid = ALC883_DIGOUT_NID,
10214 .dig_in_nid = ALC883_DIGIN_NID,
10215 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10216 .channel_mode = alc883_3ST_6ch_clevo_modes,
10217 .need_dac_fix = 1,
10218 .input_mux = &alc883_capture_source,
10219 /* This machine has the hardware HP auto-muting, thus
10220 * we need no software mute via unsol event
10221 */
10222 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010223 [ALC883_CLEVO_M720] = {
10224 .mixers = { alc883_clevo_m720_mixer },
10225 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010226 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10227 .dac_nids = alc883_dac_nids,
10228 .dig_out_nid = ALC883_DIGOUT_NID,
10229 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10230 .channel_mode = alc883_3ST_2ch_modes,
10231 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010232 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010233 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010234 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010235 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010236 [ALC883_LENOVO_101E_2ch] = {
10237 .mixers = { alc883_lenovo_101e_2ch_mixer},
10238 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10239 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10240 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010241 .adc_nids = alc883_adc_nids_alt,
10242 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010243 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010244 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10245 .channel_mode = alc883_3ST_2ch_modes,
10246 .input_mux = &alc883_lenovo_101e_capture_source,
10247 .unsol_event = alc883_lenovo_101e_unsol_event,
10248 .init_hook = alc883_lenovo_101e_all_automute,
10249 },
Kailang Yang272a5272007-05-14 11:00:38 +020010250 [ALC883_LENOVO_NB0763] = {
10251 .mixers = { alc883_lenovo_nb0763_mixer },
10252 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10253 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10254 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010255 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10256 .channel_mode = alc883_3ST_2ch_modes,
10257 .need_dac_fix = 1,
10258 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010259 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010260 .setup = alc883_medion_md2_setup,
10261 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010262 },
10263 [ALC888_LENOVO_MS7195_DIG] = {
10264 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10265 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10266 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10267 .dac_nids = alc883_dac_nids,
10268 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010269 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10270 .channel_mode = alc883_3ST_6ch_modes,
10271 .need_dac_fix = 1,
10272 .input_mux = &alc883_capture_source,
10273 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10274 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010275 },
10276 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010277 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010278 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10279 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10280 .dac_nids = alc883_dac_nids,
10281 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010282 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10283 .channel_mode = alc883_3ST_2ch_modes,
10284 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010285 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010286 .setup = alc883_haier_w66_setup,
10287 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010288 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010289 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010290 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010291 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010292 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10293 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010294 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10295 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010296 .need_dac_fix = 1,
10297 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010298 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010299 .setup = alc888_3st_hp_setup,
10300 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010301 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010302 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010303 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010304 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10305 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10306 .dac_nids = alc883_dac_nids,
10307 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010308 .dig_in_nid = ALC883_DIGIN_NID,
10309 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10310 .channel_mode = alc883_sixstack_modes,
10311 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010312 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010313 .setup = alc888_6st_dell_setup,
10314 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010315 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010316 [ALC883_MITAC] = {
10317 .mixers = { alc883_mitac_mixer },
10318 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10319 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10320 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010321 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10322 .channel_mode = alc883_3ST_2ch_modes,
10323 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010324 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010325 .setup = alc883_mitac_setup,
10326 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010327 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010328 [ALC883_FUJITSU_PI2515] = {
10329 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10330 .init_verbs = { alc883_init_verbs,
10331 alc883_2ch_fujitsu_pi2515_verbs},
10332 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10333 .dac_nids = alc883_dac_nids,
10334 .dig_out_nid = ALC883_DIGOUT_NID,
10335 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10336 .channel_mode = alc883_3ST_2ch_modes,
10337 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010338 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010339 .setup = alc883_2ch_fujitsu_pi2515_setup,
10340 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010341 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010342 [ALC888_FUJITSU_XA3530] = {
10343 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10344 .init_verbs = { alc883_init_verbs,
10345 alc888_fujitsu_xa3530_verbs },
10346 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10347 .dac_nids = alc883_dac_nids,
10348 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10349 .adc_nids = alc883_adc_nids_rev,
10350 .capsrc_nids = alc883_capsrc_nids_rev,
10351 .dig_out_nid = ALC883_DIGOUT_NID,
10352 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10353 .channel_mode = alc888_4ST_8ch_intel_modes,
10354 .num_mux_defs =
10355 ARRAY_SIZE(alc888_2_capture_sources),
10356 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010357 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010358 .setup = alc888_fujitsu_xa3530_setup,
10359 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010360 },
Kailang Yange2757d52008-08-26 13:17:46 +020010361 [ALC888_LENOVO_SKY] = {
10362 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10363 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10364 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10365 .dac_nids = alc883_dac_nids,
10366 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010367 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10368 .channel_mode = alc883_sixstack_modes,
10369 .need_dac_fix = 1,
10370 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010371 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010372 .setup = alc888_lenovo_sky_setup,
10373 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010374 },
10375 [ALC888_ASUS_M90V] = {
10376 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10377 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10378 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10379 .dac_nids = alc883_dac_nids,
10380 .dig_out_nid = ALC883_DIGOUT_NID,
10381 .dig_in_nid = ALC883_DIGIN_NID,
10382 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10383 .channel_mode = alc883_3ST_6ch_modes,
10384 .need_dac_fix = 1,
10385 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010386 .unsol_event = alc_sku_unsol_event,
10387 .setup = alc883_mode2_setup,
10388 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010389 },
10390 [ALC888_ASUS_EEE1601] = {
10391 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010392 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010393 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10394 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10395 .dac_nids = alc883_dac_nids,
10396 .dig_out_nid = ALC883_DIGOUT_NID,
10397 .dig_in_nid = ALC883_DIGIN_NID,
10398 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10399 .channel_mode = alc883_3ST_2ch_modes,
10400 .need_dac_fix = 1,
10401 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010402 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010403 .init_hook = alc883_eee1601_inithook,
10404 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010405 [ALC1200_ASUS_P5Q] = {
10406 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10407 .init_verbs = { alc883_init_verbs },
10408 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10409 .dac_nids = alc883_dac_nids,
10410 .dig_out_nid = ALC1200_DIGOUT_NID,
10411 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010412 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010413 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10414 .channel_mode = alc883_sixstack_modes,
10415 .input_mux = &alc883_capture_source,
10416 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010417 [ALC889A_MB31] = {
10418 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10419 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10420 alc880_gpio1_init_verbs },
10421 .adc_nids = alc883_adc_nids,
10422 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010423 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010424 .dac_nids = alc883_dac_nids,
10425 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10426 .channel_mode = alc889A_mb31_6ch_modes,
10427 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10428 .input_mux = &alc889A_mb31_capture_source,
10429 .dig_out_nid = ALC883_DIGOUT_NID,
10430 .unsol_event = alc889A_mb31_unsol_event,
10431 .init_hook = alc889A_mb31_automute,
10432 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010433 [ALC883_SONY_VAIO_TT] = {
10434 .mixers = { alc883_vaiott_mixer },
10435 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10436 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10437 .dac_nids = alc883_dac_nids,
10438 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10439 .channel_mode = alc883_3ST_2ch_modes,
10440 .input_mux = &alc883_capture_source,
10441 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010442 .setup = alc883_vaiott_setup,
10443 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010444 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010445};
10446
10447
10448/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010449 * Pin config fixes
10450 */
10451enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010452 PINFIX_ABIT_AW9D_MAX,
10453 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010454};
10455
10456static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10457 { 0x15, 0x01080104 }, /* side */
10458 { 0x16, 0x01011012 }, /* rear */
10459 { 0x17, 0x01016011 }, /* clfe */
10460 { }
10461};
10462
Takashi Iwai954a29c2010-07-30 10:55:44 +020010463static const struct hda_verb pb_m5210_verbs[] = {
10464 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10465 {}
10466};
10467
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010468static const struct alc_fixup alc882_fixups[] = {
10469 [PINFIX_ABIT_AW9D_MAX] = {
10470 .pins = alc882_abit_aw9d_pinfix
10471 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010472 [PINFIX_PB_M5210] = {
10473 .verbs = pb_m5210_verbs
10474 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010475};
10476
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010477static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010478 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010479 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10480 {}
10481};
10482
10483/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010484 * BIOS auto configuration
10485 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010486static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10487 const struct auto_pin_cfg *cfg)
10488{
10489 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10490}
10491
Takashi Iwai4953550a2009-06-30 15:28:30 +020010492static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010493 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010494 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010495{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010496 int idx;
10497
Takashi Iwai489008c2010-04-07 09:06:00 +020010498 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010499 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010500
Takashi Iwai489008c2010-04-07 09:06:00 +020010501 if (dac == 0x25)
10502 idx = 4;
10503 else if (dac >= 0x02 && dac <= 0x05)
10504 idx = dac - 2;
10505 else
10506 return;
10507 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010508}
10509
Takashi Iwai4953550a2009-06-30 15:28:30 +020010510static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010511{
10512 struct alc_spec *spec = codec->spec;
10513 int i;
10514
10515 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010516 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010517 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010518 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010519 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010520 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521 }
10522}
10523
Takashi Iwai4953550a2009-06-30 15:28:30 +020010524static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010525{
10526 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010527 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010528
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010529 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010530 if (pin) {
10531 dac = spec->multiout.hp_nid;
10532 if (!dac)
10533 dac = spec->multiout.dac_nids[0]; /* to front */
10534 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10535 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010536 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010537 if (pin) {
10538 dac = spec->multiout.extra_out_nid[0];
10539 if (!dac)
10540 dac = spec->multiout.dac_nids[0]; /* to front */
10541 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10542 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010543}
10544
Takashi Iwai4953550a2009-06-30 15:28:30 +020010545static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010546{
10547 struct alc_spec *spec = codec->spec;
10548 int i;
10549
10550 for (i = 0; i < AUTO_PIN_LAST; i++) {
10551 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010552 if (!nid)
10553 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010554 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010555 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10556 snd_hda_codec_write(codec, nid, 0,
10557 AC_VERB_SET_AMP_GAIN_MUTE,
10558 AMP_OUT_MUTE);
10559 }
10560}
10561
10562static void alc882_auto_init_input_src(struct hda_codec *codec)
10563{
10564 struct alc_spec *spec = codec->spec;
10565 int c;
10566
10567 for (c = 0; c < spec->num_adc_nids; c++) {
10568 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10569 hda_nid_t nid = spec->capsrc_nids[c];
10570 unsigned int mux_idx;
10571 const struct hda_input_mux *imux;
10572 int conns, mute, idx, item;
10573
10574 conns = snd_hda_get_connections(codec, nid, conn_list,
10575 ARRAY_SIZE(conn_list));
10576 if (conns < 0)
10577 continue;
10578 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10579 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010580 if (!imux->num_items && mux_idx > 0)
10581 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010582 for (idx = 0; idx < conns; idx++) {
10583 /* if the current connection is the selected one,
10584 * unmute it as default - otherwise mute it
10585 */
10586 mute = AMP_IN_MUTE(idx);
10587 for (item = 0; item < imux->num_items; item++) {
10588 if (imux->items[item].index == idx) {
10589 if (spec->cur_mux[c] == item)
10590 mute = AMP_IN_UNMUTE(idx);
10591 break;
10592 }
10593 }
10594 /* check if we have a selector or mixer
10595 * we could check for the widget type instead, but
10596 * just check for Amp-In presence (in case of mixer
10597 * without amp-in there is something wrong, this
10598 * function shouldn't be used or capsrc nid is wrong)
10599 */
10600 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010601 snd_hda_codec_write(codec, nid, 0,
10602 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010603 mute);
10604 else if (mute != AMP_IN_MUTE(idx))
10605 snd_hda_codec_write(codec, nid, 0,
10606 AC_VERB_SET_CONNECT_SEL,
10607 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010608 }
10609 }
10610}
10611
Takashi Iwai4953550a2009-06-30 15:28:30 +020010612/* add mic boosts if needed */
10613static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010614{
10615 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010616 int err;
10617 hda_nid_t nid;
10618
10619 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10620 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10621 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10622 "Mic Boost",
10623 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10624 if (err < 0)
10625 return err;
10626 }
10627 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10628 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10629 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10630 "Front Mic Boost",
10631 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10632 if (err < 0)
10633 return err;
10634 }
10635 return 0;
10636}
10637
10638/* almost identical with ALC880 parser... */
10639static int alc882_parse_auto_config(struct hda_codec *codec)
10640{
10641 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010642 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010643 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010644
Takashi Iwai05f5f472009-08-25 13:10:18 +020010645 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10646 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010647 if (err < 0)
10648 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010649 if (!spec->autocfg.line_outs)
10650 return 0; /* can't find valid BIOS pin config */
10651
10652 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10653 if (err < 0)
10654 return err;
10655 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10656 if (err < 0)
10657 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010658 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10659 "Headphone");
10660 if (err < 0)
10661 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010662 err = alc880_auto_create_extra_out(spec,
10663 spec->autocfg.speaker_pins[0],
10664 "Speaker");
10665 if (err < 0)
10666 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010667 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10668 if (err < 0)
10669 return err;
10670
10671 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10672
Takashi Iwai757899a2010-07-30 10:48:14 +020010673 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010674
10675 if (spec->kctls.list)
10676 add_mixer(spec, spec->kctls.list);
10677
10678 add_verb(spec, alc883_auto_init_verbs);
10679 /* if ADC 0x07 is available, initialize it, too */
10680 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10681 add_verb(spec, alc882_adc1_init_verbs);
10682
10683 spec->num_mux_defs = 1;
10684 spec->input_mux = &spec->private_imux[0];
10685
Kailang Yang6227cdc2010-02-25 08:36:52 +010010686 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010687
10688 err = alc_auto_add_mic_boost(codec);
10689 if (err < 0)
10690 return err;
10691
Takashi Iwai776e1842007-08-29 15:07:11 +020010692 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010693}
10694
10695/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010696static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010697{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010698 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010699 alc882_auto_init_multi_out(codec);
10700 alc882_auto_init_hp_out(codec);
10701 alc882_auto_init_analog_input(codec);
10702 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010703 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010704 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010705 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010706}
10707
Takashi Iwai4953550a2009-06-30 15:28:30 +020010708static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010709{
10710 struct alc_spec *spec;
10711 int err, board_config;
10712
10713 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10714 if (spec == NULL)
10715 return -ENOMEM;
10716
10717 codec->spec = spec;
10718
Kailang Yangda00c242010-03-19 11:23:45 +010010719 alc_auto_parse_customize_define(codec);
10720
Takashi Iwai4953550a2009-06-30 15:28:30 +020010721 switch (codec->vendor_id) {
10722 case 0x10ec0882:
10723 case 0x10ec0885:
10724 break;
10725 default:
10726 /* ALC883 and variants */
10727 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10728 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010729 }
10730
Takashi Iwai4953550a2009-06-30 15:28:30 +020010731 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10732 alc882_models,
10733 alc882_cfg_tbl);
10734
10735 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10736 board_config = snd_hda_check_board_codec_sid_config(codec,
10737 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10738
10739 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010740 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010741 codec->chip_name);
10742 board_config = ALC882_AUTO;
10743 }
10744
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010745 if (board_config == ALC882_AUTO)
10746 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010747
10748 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010749 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010750 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010751 if (err < 0) {
10752 alc_free(codec);
10753 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010754 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010755 printk(KERN_INFO
10756 "hda_codec: Cannot set up configuration "
10757 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010758 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010759 }
10760 }
10761
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010762 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010763 err = snd_hda_attach_beep_device(codec, 0x1);
10764 if (err < 0) {
10765 alc_free(codec);
10766 return err;
10767 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010768 }
10769
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010771 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010772
Takashi Iwai4953550a2009-06-30 15:28:30 +020010773 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10774 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10775 /* FIXME: setup DAC5 */
10776 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10777 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10778
10779 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10780 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10781
Takashi Iwai4953550a2009-06-30 15:28:30 +020010782 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010783 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010784 spec->num_adc_nids = 0;
10785 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010786 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010787 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010788 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010789 hda_nid_t nid = alc882_adc_nids[i];
10790 unsigned int wcap = get_wcaps(codec, nid);
10791 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010792 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010793 if (wcap != AC_WID_AUD_IN)
10794 continue;
10795 spec->private_adc_nids[spec->num_adc_nids] = nid;
10796 err = snd_hda_get_connections(codec, nid, &cap, 1);
10797 if (err < 0)
10798 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010799 err = snd_hda_get_connections(codec, cap, items,
10800 ARRAY_SIZE(items));
10801 if (err < 0)
10802 continue;
10803 for (j = 0; j < imux->num_items; j++)
10804 if (imux->items[j].index >= err)
10805 break;
10806 if (j < imux->num_items)
10807 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010808 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10809 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010810 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010811 spec->adc_nids = spec->private_adc_nids;
10812 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010813 }
10814
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010815 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010816
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010817 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010818 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010819
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010820 if (board_config == ALC882_AUTO)
10821 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10822
Takashi Iwai2134ea42008-01-10 16:53:55 +010010823 spec->vmaster_nid = 0x0c;
10824
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010825 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010826 if (board_config == ALC882_AUTO)
10827 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010828#ifdef CONFIG_SND_HDA_POWER_SAVE
10829 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010830 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010831#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010832
10833 return 0;
10834}
10835
Takashi Iwai4953550a2009-06-30 15:28:30 +020010836
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010837/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010838 * ALC262 support
10839 */
10840
10841#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10842#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10843
10844#define alc262_dac_nids alc260_dac_nids
10845#define alc262_adc_nids alc882_adc_nids
10846#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010847#define alc262_capsrc_nids alc882_capsrc_nids
10848#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010849
10850#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010851#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010852
Kailang Yang4e555fe2008-08-26 13:05:55 +020010853static hda_nid_t alc262_dmic_adc_nids[1] = {
10854 /* ADC0 */
10855 0x09
10856};
10857
10858static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10859
Kailang Yangdf694da2005-12-05 19:42:22 +010010860static struct snd_kcontrol_new alc262_base_mixer[] = {
10861 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10862 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10863 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10864 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10865 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10866 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10867 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10868 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010869 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010870 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10871 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010872 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010873 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10875 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10876 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010877 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010878};
10879
Takashi Iwaice875f02008-01-28 18:17:43 +010010880/* update HP, line and mono-out pins according to the master switch */
10881static void alc262_hp_master_update(struct hda_codec *codec)
10882{
10883 struct alc_spec *spec = codec->spec;
10884 int val = spec->master_sw;
10885
10886 /* HP & line-out */
10887 snd_hda_codec_write_cache(codec, 0x1b, 0,
10888 AC_VERB_SET_PIN_WIDGET_CONTROL,
10889 val ? PIN_HP : 0);
10890 snd_hda_codec_write_cache(codec, 0x15, 0,
10891 AC_VERB_SET_PIN_WIDGET_CONTROL,
10892 val ? PIN_HP : 0);
10893 /* mono (speaker) depending on the HP jack sense */
10894 val = val && !spec->jack_present;
10895 snd_hda_codec_write_cache(codec, 0x16, 0,
10896 AC_VERB_SET_PIN_WIDGET_CONTROL,
10897 val ? PIN_OUT : 0);
10898}
10899
10900static void alc262_hp_bpc_automute(struct hda_codec *codec)
10901{
10902 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010903
10904 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010905 alc262_hp_master_update(codec);
10906}
10907
10908static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10909{
10910 if ((res >> 26) != ALC880_HP_EVENT)
10911 return;
10912 alc262_hp_bpc_automute(codec);
10913}
10914
10915static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10916{
10917 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010918
10919 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010920 alc262_hp_master_update(codec);
10921}
10922
10923static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10924 unsigned int res)
10925{
10926 if ((res >> 26) != ALC880_HP_EVENT)
10927 return;
10928 alc262_hp_wildwest_automute(codec);
10929}
10930
Takashi Iwaib72519b2009-05-08 14:31:55 +020010931#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010932
10933static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10934 struct snd_ctl_elem_value *ucontrol)
10935{
10936 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10937 struct alc_spec *spec = codec->spec;
10938 int val = !!*ucontrol->value.integer.value;
10939
10940 if (val == spec->master_sw)
10941 return 0;
10942 spec->master_sw = val;
10943 alc262_hp_master_update(codec);
10944 return 1;
10945}
10946
Takashi Iwaib72519b2009-05-08 14:31:55 +020010947#define ALC262_HP_MASTER_SWITCH \
10948 { \
10949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10950 .name = "Master Playback Switch", \
10951 .info = snd_ctl_boolean_mono_info, \
10952 .get = alc262_hp_master_sw_get, \
10953 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010954 }, \
10955 { \
10956 .iface = NID_MAPPING, \
10957 .name = "Master Playback Switch", \
10958 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010959 }
10960
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010961
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010962static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010963 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10965 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010967 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10968 HDA_OUTPUT),
10969 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10970 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010971 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010973 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10975 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010976 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010977 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10978 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10979 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10980 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010981 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10982 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10983 { } /* end */
10984};
10985
Kailang Yangcd7509a2007-01-26 18:33:17 +010010986static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010987 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010988 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10989 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10990 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10991 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010992 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10993 HDA_OUTPUT),
10994 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10995 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010998 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010999 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11000 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011003 { } /* end */
11004};
11005
11006static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11007 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11008 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011009 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011010 { } /* end */
11011};
11012
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011013/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011014static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011015{
11016 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011017
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011018 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011019 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011020}
11021
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011022static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011023 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11024 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011025 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11029 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11030 { } /* end */
11031};
11032
11033static struct hda_verb alc262_hp_t5735_verbs[] = {
11034 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11035 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11036
11037 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11038 { }
11039};
11040
Kailang Yang8c427222008-01-10 13:03:59 +010011041static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011042 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11043 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011044 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11045 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011046 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11047 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11048 { } /* end */
11049};
11050
11051static struct hda_verb alc262_hp_rp5700_verbs[] = {
11052 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11053 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11054 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11056 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11057 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11062 {}
11063};
11064
11065static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11066 .num_items = 1,
11067 .items = {
11068 { "Line", 0x1 },
11069 },
11070};
11071
Takashi Iwai42171c12009-05-08 14:11:43 +020011072/* bind hp and internal speaker mute (with plug check) as master switch */
11073static void alc262_hippo_master_update(struct hda_codec *codec)
11074{
11075 struct alc_spec *spec = codec->spec;
11076 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11077 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11078 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11079 unsigned int mute;
11080
11081 /* HP */
11082 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11083 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11084 HDA_AMP_MUTE, mute);
11085 /* mute internal speaker per jack sense */
11086 if (spec->jack_present)
11087 mute = HDA_AMP_MUTE;
11088 if (line_nid)
11089 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11090 HDA_AMP_MUTE, mute);
11091 if (speaker_nid && speaker_nid != line_nid)
11092 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11093 HDA_AMP_MUTE, mute);
11094}
11095
11096#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11097
11098static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11099 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011100{
11101 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011102 struct alc_spec *spec = codec->spec;
11103 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011104
Takashi Iwai42171c12009-05-08 14:11:43 +020011105 if (val == spec->master_sw)
11106 return 0;
11107 spec->master_sw = val;
11108 alc262_hippo_master_update(codec);
11109 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011110}
Takashi Iwai5b319542007-07-26 11:49:22 +020011111
Takashi Iwai42171c12009-05-08 14:11:43 +020011112#define ALC262_HIPPO_MASTER_SWITCH \
11113 { \
11114 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11115 .name = "Master Playback Switch", \
11116 .info = snd_ctl_boolean_mono_info, \
11117 .get = alc262_hippo_master_sw_get, \
11118 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011119 }, \
11120 { \
11121 .iface = NID_MAPPING, \
11122 .name = "Master Playback Switch", \
11123 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11124 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011125 }
11126
11127static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11128 ALC262_HIPPO_MASTER_SWITCH,
11129 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11130 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11131 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11132 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11133 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11137 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11139 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11141 { } /* end */
11142};
11143
11144static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11145 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11146 ALC262_HIPPO_MASTER_SWITCH,
11147 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11148 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11149 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11150 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11151 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11152 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11153 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11154 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11155 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11156 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11157 { } /* end */
11158};
11159
11160/* mute/unmute internal speaker according to the hp jack and mute state */
11161static void alc262_hippo_automute(struct hda_codec *codec)
11162{
11163 struct alc_spec *spec = codec->spec;
11164 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011165
Wu Fengguang864f92b2009-11-18 12:38:02 +080011166 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011167 alc262_hippo_master_update(codec);
11168}
11169
11170static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11171{
11172 if ((res >> 26) != ALC880_HP_EVENT)
11173 return;
11174 alc262_hippo_automute(codec);
11175}
11176
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011177static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011178{
11179 struct alc_spec *spec = codec->spec;
11180
11181 spec->autocfg.hp_pins[0] = 0x15;
11182 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011183}
11184
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011185static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011186{
11187 struct alc_spec *spec = codec->spec;
11188
11189 spec->autocfg.hp_pins[0] = 0x1b;
11190 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011191}
11192
11193
Kailang Yang272a5272007-05-14 11:00:38 +020011194static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011195 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011196 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11199 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11200 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11201 { } /* end */
11202};
11203
Kailang Yang83c34212007-07-05 11:43:05 +020011204static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011205 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11206 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11210 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11211 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11212 { } /* end */
11213};
Kailang Yang272a5272007-05-14 11:00:38 +020011214
Tony Vroonba340e82009-02-02 19:01:30 +000011215static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11216 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11217 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11218 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11219 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11224 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11225 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11226 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11227 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11228 { } /* end */
11229};
11230
11231static struct hda_verb alc262_tyan_verbs[] = {
11232 /* Headphone automute */
11233 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11234 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11235 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11236
11237 /* P11 AUX_IN, white 4-pin connector */
11238 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11239 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11240 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11241 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11242
11243 {}
11244};
11245
11246/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011247static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011248{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011249 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011250
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011251 spec->autocfg.hp_pins[0] = 0x1b;
11252 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011253}
11254
Tony Vroonba340e82009-02-02 19:01:30 +000011255
Kailang Yangdf694da2005-12-05 19:42:22 +010011256#define alc262_capture_mixer alc882_capture_mixer
11257#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11258
11259/*
11260 * generic initialization of ADC, input mixers and output mixers
11261 */
11262static struct hda_verb alc262_init_verbs[] = {
11263 /*
11264 * Unmute ADC0-2 and set the default input to mic-in
11265 */
11266 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11268 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11269 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11270 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11272
Takashi Iwaicb53c622007-08-10 17:21:45 +020011273 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011274 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011275 * Note: PASD motherboards uses the Line In 2 as the input for
11276 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011277 */
11278 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11280 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11281 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011284
11285 /*
11286 * Set up output mixers (0x0c - 0x0e)
11287 */
11288 /* set vol=0 to output mixers */
11289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11292 /* set up input amps for analog loopback */
11293 /* Amp Indices: DAC = 0, mixer = 1 */
11294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11300
11301 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11302 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11303 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11304 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11306 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11307
11308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11310 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11311 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11312 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011313
Kailang Yangdf694da2005-12-05 19:42:22 +010011314 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11315 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011316
Kailang Yangdf694da2005-12-05 19:42:22 +010011317 /* FIXME: use matrix-type input source selection */
11318 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11319 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11324 /* Input mixer2 */
11325 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11329 /* Input mixer3 */
11330 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11331 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11332 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011334
11335 { }
11336};
11337
Kailang Yang4e555fe2008-08-26 13:05:55 +020011338static struct hda_verb alc262_eapd_verbs[] = {
11339 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11340 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11341 { }
11342};
11343
Kailang Yangccc656c2006-10-17 12:32:26 +020011344static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11345 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11348
11349 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11350 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11351 {}
11352};
11353
Kailang Yang272a5272007-05-14 11:00:38 +020011354static struct hda_verb alc262_sony_unsol_verbs[] = {
11355 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11356 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11357 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11358
11359 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011361 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011362};
11363
Kailang Yang4e555fe2008-08-26 13:05:55 +020011364static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11365 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11366 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011370 { } /* end */
11371};
11372
11373static struct hda_verb alc262_toshiba_s06_verbs[] = {
11374 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11377 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11378 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11379 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11380 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11381 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11382 {}
11383};
11384
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011385static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011386{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011387 struct alc_spec *spec = codec->spec;
11388
11389 spec->autocfg.hp_pins[0] = 0x15;
11390 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011391 spec->ext_mic.pin = 0x18;
11392 spec->ext_mic.mux_idx = 0;
11393 spec->int_mic.pin = 0x12;
11394 spec->int_mic.mux_idx = 9;
11395 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011396}
11397
Takashi Iwai834be882006-03-01 14:16:17 +010011398/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011399 * nec model
11400 * 0x15 = headphone
11401 * 0x16 = internal speaker
11402 * 0x18 = external mic
11403 */
11404
11405static struct snd_kcontrol_new alc262_nec_mixer[] = {
11406 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11408
11409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11411 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11412
11413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11415 { } /* end */
11416};
11417
11418static struct hda_verb alc262_nec_verbs[] = {
11419 /* Unmute Speaker */
11420 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11421
11422 /* Headphone */
11423 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11424 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11425
11426 /* External mic to headphone */
11427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11428 /* External mic to speaker */
11429 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11430 {}
11431};
11432
11433/*
Takashi Iwai834be882006-03-01 14:16:17 +010011434 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011435 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11436 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011437 */
11438
11439#define ALC_HP_EVENT 0x37
11440
11441static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11442 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11443 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011444 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11445 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011446 {}
11447};
11448
Jiang zhe0e31daf2008-03-20 12:12:39 +010011449static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11450 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11452 {}
11453};
11454
Daniel T Chene2595322009-12-19 18:19:02 -050011455static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11456 /* Front Mic pin: input vref at 50% */
11457 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11458 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11459 {}
11460};
11461
Takashi Iwai834be882006-03-01 14:16:17 +010011462static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011463 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011464 .items = {
11465 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011466 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011467 { "CD", 0x4 },
11468 },
11469};
11470
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011471static struct hda_input_mux alc262_HP_capture_source = {
11472 .num_items = 5,
11473 .items = {
11474 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011475 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011476 { "Line", 0x2 },
11477 { "CD", 0x4 },
11478 { "AUX IN", 0x6 },
11479 },
11480};
11481
zhejiangaccbe492007-08-31 12:36:05 +020011482static struct hda_input_mux alc262_HP_D7000_capture_source = {
11483 .num_items = 4,
11484 .items = {
11485 { "Mic", 0x0 },
11486 { "Front Mic", 0x2 },
11487 { "Line", 0x1 },
11488 { "CD", 0x4 },
11489 },
11490};
11491
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011492/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011493static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11494{
11495 struct alc_spec *spec = codec->spec;
11496 unsigned int mute;
11497
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011498 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011499 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11500 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011501 spec->sense_updated = 1;
11502 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011503 /* unmute internal speaker only if both HPs are unplugged and
11504 * master switch is on
11505 */
11506 if (spec->jack_present)
11507 mute = HDA_AMP_MUTE;
11508 else
Takashi Iwai834be882006-03-01 14:16:17 +010011509 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011510 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11511 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011512}
11513
11514/* unsolicited event for HP jack sensing */
11515static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11516 unsigned int res)
11517{
11518 if ((res >> 26) != ALC_HP_EVENT)
11519 return;
11520 alc262_fujitsu_automute(codec, 1);
11521}
11522
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011523static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11524{
11525 alc262_fujitsu_automute(codec, 1);
11526}
11527
Takashi Iwai834be882006-03-01 14:16:17 +010011528/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011529static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11530 .ops = &snd_hda_bind_vol,
11531 .values = {
11532 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11533 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11534 0
11535 },
11536};
Takashi Iwai834be882006-03-01 14:16:17 +010011537
Jiang zhe0e31daf2008-03-20 12:12:39 +010011538/* mute/unmute internal speaker according to the hp jack and mute state */
11539static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11540{
11541 struct alc_spec *spec = codec->spec;
11542 unsigned int mute;
11543
11544 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011545 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011546 spec->sense_updated = 1;
11547 }
11548 if (spec->jack_present) {
11549 /* mute internal speaker */
11550 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11551 HDA_AMP_MUTE, HDA_AMP_MUTE);
11552 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11553 HDA_AMP_MUTE, HDA_AMP_MUTE);
11554 } else {
11555 /* unmute internal speaker if necessary */
11556 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11557 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11558 HDA_AMP_MUTE, mute);
11559 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11560 HDA_AMP_MUTE, mute);
11561 }
11562}
11563
11564/* unsolicited event for HP jack sensing */
11565static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11566 unsigned int res)
11567{
11568 if ((res >> 26) != ALC_HP_EVENT)
11569 return;
11570 alc262_lenovo_3000_automute(codec, 1);
11571}
11572
Takashi Iwai8de56b72009-07-24 16:51:47 +020011573static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11574 int dir, int idx, long *valp)
11575{
11576 int i, change = 0;
11577
11578 for (i = 0; i < 2; i++, valp++)
11579 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11580 HDA_AMP_MUTE,
11581 *valp ? 0 : HDA_AMP_MUTE);
11582 return change;
11583}
11584
Takashi Iwai834be882006-03-01 14:16:17 +010011585/* bind hp and internal speaker mute (with plug check) */
11586static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11587 struct snd_ctl_elem_value *ucontrol)
11588{
11589 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11590 long *valp = ucontrol->value.integer.value;
11591 int change;
11592
Takashi Iwai8de56b72009-07-24 16:51:47 +020011593 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11594 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011595 if (change)
11596 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011597 return change;
11598}
11599
11600static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011601 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011602 {
11603 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11604 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011605 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011606 .info = snd_hda_mixer_amp_switch_info,
11607 .get = snd_hda_mixer_amp_switch_get,
11608 .put = alc262_fujitsu_master_sw_put,
11609 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11610 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011611 {
11612 .iface = NID_MAPPING,
11613 .name = "Master Playback Switch",
11614 .private_value = 0x1b,
11615 },
Takashi Iwai834be882006-03-01 14:16:17 +010011616 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11617 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11618 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11619 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11620 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011621 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11622 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11623 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011624 { } /* end */
11625};
11626
Jiang zhe0e31daf2008-03-20 12:12:39 +010011627/* bind hp and internal speaker mute (with plug check) */
11628static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11629 struct snd_ctl_elem_value *ucontrol)
11630{
11631 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11632 long *valp = ucontrol->value.integer.value;
11633 int change;
11634
Takashi Iwai8de56b72009-07-24 16:51:47 +020011635 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011636 if (change)
11637 alc262_lenovo_3000_automute(codec, 0);
11638 return change;
11639}
11640
11641static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11642 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11643 {
11644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11645 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011646 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011647 .info = snd_hda_mixer_amp_switch_info,
11648 .get = snd_hda_mixer_amp_switch_get,
11649 .put = alc262_lenovo_3000_master_sw_put,
11650 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11651 },
11652 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11653 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11654 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11655 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11656 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11657 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11658 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11659 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11660 { } /* end */
11661};
11662
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011663static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11664 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011665 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011666 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11667 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11669 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11671 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11672 { } /* end */
11673};
11674
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011675/* additional init verbs for Benq laptops */
11676static struct hda_verb alc262_EAPD_verbs[] = {
11677 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11678 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11679 {}
11680};
11681
Kailang Yang83c34212007-07-05 11:43:05 +020011682static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11683 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11684 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11685
11686 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11687 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11688 {}
11689};
11690
Tobin Davisf651b502007-10-26 12:40:47 +020011691/* Samsung Q1 Ultra Vista model setup */
11692static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011693 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11694 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11697 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011698 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011699 { } /* end */
11700};
11701
11702static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011703 /* output mixer */
11704 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11705 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11706 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11707 /* speaker */
11708 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11709 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11710 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11711 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11712 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011713 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11716 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11717 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11718 /* internal mic */
11719 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11720 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11721 /* ADC, choose mic */
11722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11723 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11725 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011732 {}
11733};
11734
Tobin Davisf651b502007-10-26 12:40:47 +020011735/* mute/unmute internal speaker according to the hp jack and mute state */
11736static void alc262_ultra_automute(struct hda_codec *codec)
11737{
11738 struct alc_spec *spec = codec->spec;
11739 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011740
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011741 mute = 0;
11742 /* auto-mute only when HP is used as HP */
11743 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011744 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011745 if (spec->jack_present)
11746 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011747 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011748 /* mute/unmute internal speaker */
11749 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11750 HDA_AMP_MUTE, mute);
11751 /* mute/unmute HP */
11752 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11753 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011754}
11755
11756/* unsolicited event for HP jack sensing */
11757static void alc262_ultra_unsol_event(struct hda_codec *codec,
11758 unsigned int res)
11759{
11760 if ((res >> 26) != ALC880_HP_EVENT)
11761 return;
11762 alc262_ultra_automute(codec);
11763}
11764
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011765static struct hda_input_mux alc262_ultra_capture_source = {
11766 .num_items = 2,
11767 .items = {
11768 { "Mic", 0x1 },
11769 { "Headphone", 0x7 },
11770 },
11771};
11772
11773static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11774 struct snd_ctl_elem_value *ucontrol)
11775{
11776 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11777 struct alc_spec *spec = codec->spec;
11778 int ret;
11779
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011780 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011781 if (!ret)
11782 return 0;
11783 /* reprogram the HP pin as mic or HP according to the input source */
11784 snd_hda_codec_write_cache(codec, 0x15, 0,
11785 AC_VERB_SET_PIN_WIDGET_CONTROL,
11786 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11787 alc262_ultra_automute(codec); /* mute/unmute HP */
11788 return ret;
11789}
11790
11791static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11792 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11793 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11794 {
11795 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11796 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011797 .info = alc_mux_enum_info,
11798 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011799 .put = alc262_ultra_mux_enum_put,
11800 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011801 {
11802 .iface = NID_MAPPING,
11803 .name = "Capture Source",
11804 .private_value = 0x15,
11805 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011806 { } /* end */
11807};
11808
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011809/* We use two mixers depending on the output pin; 0x16 is a mono output
11810 * and thus it's bound with a different mixer.
11811 * This function returns which mixer amp should be used.
11812 */
11813static int alc262_check_volbit(hda_nid_t nid)
11814{
11815 if (!nid)
11816 return 0;
11817 else if (nid == 0x16)
11818 return 2;
11819 else
11820 return 1;
11821}
11822
11823static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11824 const char *pfx, int *vbits)
11825{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011826 unsigned long val;
11827 int vbit;
11828
11829 vbit = alc262_check_volbit(nid);
11830 if (!vbit)
11831 return 0;
11832 if (*vbits & vbit) /* a volume control for this mixer already there */
11833 return 0;
11834 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011835 if (vbit == 2)
11836 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11837 else
11838 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011839 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011840}
11841
11842static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11843 const char *pfx)
11844{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011845 unsigned long val;
11846
11847 if (!nid)
11848 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011849 if (nid == 0x16)
11850 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11851 else
11852 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011853 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011854}
11855
Kailang Yangdf694da2005-12-05 19:42:22 +010011856/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011857static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11858 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011859{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011860 const char *pfx;
11861 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011862 int err;
11863
11864 spec->multiout.num_dacs = 1; /* only use one dac */
11865 spec->multiout.dac_nids = spec->private_dac_nids;
11866 spec->multiout.dac_nids[0] = 2;
11867
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011868 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11869 pfx = "Master";
11870 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11871 pfx = "Speaker";
11872 else
11873 pfx = "Front";
11874 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11875 if (err < 0)
11876 return err;
11877 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11878 if (err < 0)
11879 return err;
11880 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11881 if (err < 0)
11882 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011883
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011884 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11885 alc262_check_volbit(cfg->speaker_pins[0]) |
11886 alc262_check_volbit(cfg->hp_pins[0]);
11887 if (vbits == 1 || vbits == 2)
11888 pfx = "Master"; /* only one mixer is used */
11889 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11890 pfx = "Speaker";
11891 else
11892 pfx = "Front";
11893 vbits = 0;
11894 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11895 if (err < 0)
11896 return err;
11897 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11898 &vbits);
11899 if (err < 0)
11900 return err;
11901 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11902 &vbits);
11903 if (err < 0)
11904 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011905 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011906}
11907
Takashi Iwai05f5f472009-08-25 13:10:18 +020011908#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011909 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011910
11911/*
11912 * generic initialization of ADC, input mixers and output mixers
11913 */
11914static struct hda_verb alc262_volume_init_verbs[] = {
11915 /*
11916 * Unmute ADC0-2 and set the default input to mic-in
11917 */
11918 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11920 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11921 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11922 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11923 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11924
Takashi Iwaicb53c622007-08-10 17:21:45 +020011925 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011926 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011927 * Note: PASD motherboards uses the Line In 2 as the input for
11928 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011929 */
11930 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011931 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11932 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11933 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11934 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11935 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011936
11937 /*
11938 * Set up output mixers (0x0c - 0x0f)
11939 */
11940 /* set vol=0 to output mixers */
11941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11943 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011944
Kailang Yangdf694da2005-12-05 19:42:22 +010011945 /* set up input amps for analog loopback */
11946 /* Amp Indices: DAC = 0, mixer = 1 */
11947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11948 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11949 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11950 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11951 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11952 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11953
11954 /* FIXME: use matrix-type input source selection */
11955 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11956 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11957 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11958 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11961 /* Input mixer2 */
11962 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11963 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11964 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11966 /* Input mixer3 */
11967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11968 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11969 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11971
11972 { }
11973};
11974
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011975static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11976 /*
11977 * Unmute ADC0-2 and set the default input to mic-in
11978 */
11979 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11981 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11982 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11983 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11984 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11985
Takashi Iwaicb53c622007-08-10 17:21:45 +020011986 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011987 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011988 * Note: PASD motherboards uses the Line In 2 as the input for
11989 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011990 */
11991 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011992 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11993 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11994 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11995 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11996 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11997 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11998 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011999
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012000 /*
12001 * Set up output mixers (0x0c - 0x0e)
12002 */
12003 /* set vol=0 to output mixers */
12004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12005 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12006 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12007
12008 /* set up input amps for analog loopback */
12009 /* Amp Indices: DAC = 0, mixer = 1 */
12010 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12011 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12012 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12013 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12014 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12015 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12016
Takashi Iwaice875f02008-01-28 18:17:43 +010012017 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012018 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12019 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12020
12021 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12022 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12023
12024 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12025 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12026
12027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12028 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12029 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12030 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12031 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12032
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012033 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012034 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12035 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012036 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012037 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12038 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12039
12040
12041 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012042 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12043 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12051 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012053 /* Input mixer2 */
12054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012055 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12056 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12057 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12058 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12059 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12061 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12062 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012063 /* Input mixer3 */
12064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12069 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12070 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12071 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012073
Takashi Iwaice875f02008-01-28 18:17:43 +010012074 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12075
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012076 { }
12077};
12078
Kailang Yangcd7509a2007-01-26 18:33:17 +010012079static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12080 /*
12081 * Unmute ADC0-2 and set the default input to mic-in
12082 */
12083 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12085 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12088 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12089
Takashi Iwaicb53c622007-08-10 17:21:45 +020012090 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012091 * mixer widget
12092 * Note: PASD motherboards uses the Line In 2 as the input for front
12093 * panel mic (mic 2)
12094 */
12095 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012104 /*
12105 * Set up output mixers (0x0c - 0x0e)
12106 */
12107 /* set vol=0 to output mixers */
12108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12111
12112 /* set up input amps for analog loopback */
12113 /* Amp Indices: DAC = 0, mixer = 1 */
12114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12120
12121
12122 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12123 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12124 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12125 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12126 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12127 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12128 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12129
12130 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12132
12133 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12134 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12135
12136 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12137 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12138 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12140 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12141 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12142
12143 /* FIXME: use matrix-type input source selection */
12144 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12145 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12146 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12147 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12148 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12149 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12150 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12151 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12152 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12153 /* Input mixer2 */
12154 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12157 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12158 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12159 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12160 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12161 /* Input mixer3 */
12162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12165 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12167 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12168 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12169
Takashi Iwaice875f02008-01-28 18:17:43 +010012170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12171
Kailang Yangcd7509a2007-01-26 18:33:17 +010012172 { }
12173};
12174
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012175static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12176
12177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12178 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12179 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12180
12181 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12185
12186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12187 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12188 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12189 {}
12190};
12191
12192
Takashi Iwaicb53c622007-08-10 17:21:45 +020012193#ifdef CONFIG_SND_HDA_POWER_SAVE
12194#define alc262_loopbacks alc880_loopbacks
12195#endif
12196
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012197/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012198#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12199#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12200#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12201#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12202
12203/*
12204 * BIOS auto configuration
12205 */
12206static int alc262_parse_auto_config(struct hda_codec *codec)
12207{
12208 struct alc_spec *spec = codec->spec;
12209 int err;
12210 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12211
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012212 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12213 alc262_ignore);
12214 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012215 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012216 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012217 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012218 spec->multiout.max_channels = 2;
12219 spec->no_analog = 1;
12220 goto dig_only;
12221 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012222 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012223 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012224 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12225 if (err < 0)
12226 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012227 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012228 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012229 return err;
12230
12231 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12232
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012233 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012234 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012235
Takashi Iwai603c4012008-07-30 15:01:44 +020012236 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012237 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012238
Takashi Iwaid88897e2008-10-31 15:01:37 +010012239 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012240 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012241 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012242
Takashi Iwai776e1842007-08-29 15:07:11 +020012243 err = alc_auto_add_mic_boost(codec);
12244 if (err < 0)
12245 return err;
12246
Kailang Yang6227cdc2010-02-25 08:36:52 +010012247 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012248
Kailang Yangdf694da2005-12-05 19:42:22 +010012249 return 1;
12250}
12251
12252#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12253#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12254#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012255#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012256
12257
12258/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012259static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012260{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012261 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012262 alc262_auto_init_multi_out(codec);
12263 alc262_auto_init_hp_out(codec);
12264 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012265 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012266 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012267 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012268 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012269}
12270
12271/*
12272 * configuration and preset
12273 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012274static const char *alc262_models[ALC262_MODEL_LAST] = {
12275 [ALC262_BASIC] = "basic",
12276 [ALC262_HIPPO] = "hippo",
12277 [ALC262_HIPPO_1] = "hippo_1",
12278 [ALC262_FUJITSU] = "fujitsu",
12279 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012280 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012281 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012282 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012283 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012284 [ALC262_BENQ_T31] = "benq-t31",
12285 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012286 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012287 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012288 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012289 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012290 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012291 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012292 [ALC262_AUTO] = "auto",
12293};
12294
12295static struct snd_pci_quirk alc262_cfg_tbl[] = {
12296 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012297 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012298 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12299 ALC262_HP_BPC),
12300 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12301 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012302 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12303 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012304 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012305 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012306 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012307 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012308 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012309 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012310 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012311 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012312 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12313 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12314 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012315 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12316 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012317 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012318 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012319 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012320 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012321 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012322 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012323 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012324 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012325#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012326 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12327 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012328#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012329 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012330 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012331 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012332 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012333 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012334 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012335 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12336 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012337 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012338 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012339 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012340 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012341 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012342 {}
12343};
12344
12345static struct alc_config_preset alc262_presets[] = {
12346 [ALC262_BASIC] = {
12347 .mixers = { alc262_base_mixer },
12348 .init_verbs = { alc262_init_verbs },
12349 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12350 .dac_nids = alc262_dac_nids,
12351 .hp_nid = 0x03,
12352 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12353 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012354 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012355 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012356 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012357 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012358 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12360 .dac_nids = alc262_dac_nids,
12361 .hp_nid = 0x03,
12362 .dig_out_nid = ALC262_DIGOUT_NID,
12363 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12364 .channel_mode = alc262_modes,
12365 .input_mux = &alc262_capture_source,
12366 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012367 .setup = alc262_hippo_setup,
12368 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012369 },
12370 [ALC262_HIPPO_1] = {
12371 .mixers = { alc262_hippo1_mixer },
12372 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12373 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12374 .dac_nids = alc262_dac_nids,
12375 .hp_nid = 0x02,
12376 .dig_out_nid = ALC262_DIGOUT_NID,
12377 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12378 .channel_mode = alc262_modes,
12379 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012380 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012381 .setup = alc262_hippo1_setup,
12382 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012383 },
Takashi Iwai834be882006-03-01 14:16:17 +010012384 [ALC262_FUJITSU] = {
12385 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012386 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12387 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012388 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12389 .dac_nids = alc262_dac_nids,
12390 .hp_nid = 0x03,
12391 .dig_out_nid = ALC262_DIGOUT_NID,
12392 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12393 .channel_mode = alc262_modes,
12394 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012395 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012396 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012397 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012398 [ALC262_HP_BPC] = {
12399 .mixers = { alc262_HP_BPC_mixer },
12400 .init_verbs = { alc262_HP_BPC_init_verbs },
12401 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12402 .dac_nids = alc262_dac_nids,
12403 .hp_nid = 0x03,
12404 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12405 .channel_mode = alc262_modes,
12406 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012407 .unsol_event = alc262_hp_bpc_unsol_event,
12408 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012409 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012410 [ALC262_HP_BPC_D7000_WF] = {
12411 .mixers = { alc262_HP_BPC_WildWest_mixer },
12412 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12413 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12414 .dac_nids = alc262_dac_nids,
12415 .hp_nid = 0x03,
12416 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12417 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012418 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012419 .unsol_event = alc262_hp_wildwest_unsol_event,
12420 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012421 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012422 [ALC262_HP_BPC_D7000_WL] = {
12423 .mixers = { alc262_HP_BPC_WildWest_mixer,
12424 alc262_HP_BPC_WildWest_option_mixer },
12425 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12426 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12427 .dac_nids = alc262_dac_nids,
12428 .hp_nid = 0x03,
12429 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12430 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012431 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012432 .unsol_event = alc262_hp_wildwest_unsol_event,
12433 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012434 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012435 [ALC262_HP_TC_T5735] = {
12436 .mixers = { alc262_hp_t5735_mixer },
12437 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12438 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12439 .dac_nids = alc262_dac_nids,
12440 .hp_nid = 0x03,
12441 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12442 .channel_mode = alc262_modes,
12443 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012444 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012445 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012446 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012447 },
12448 [ALC262_HP_RP5700] = {
12449 .mixers = { alc262_hp_rp5700_mixer },
12450 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12451 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12452 .dac_nids = alc262_dac_nids,
12453 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12454 .channel_mode = alc262_modes,
12455 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012456 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012457 [ALC262_BENQ_ED8] = {
12458 .mixers = { alc262_base_mixer },
12459 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12460 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12461 .dac_nids = alc262_dac_nids,
12462 .hp_nid = 0x03,
12463 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12464 .channel_mode = alc262_modes,
12465 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012466 },
Kailang Yang272a5272007-05-14 11:00:38 +020012467 [ALC262_SONY_ASSAMD] = {
12468 .mixers = { alc262_sony_mixer },
12469 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12470 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12471 .dac_nids = alc262_dac_nids,
12472 .hp_nid = 0x02,
12473 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12474 .channel_mode = alc262_modes,
12475 .input_mux = &alc262_capture_source,
12476 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012477 .setup = alc262_hippo_setup,
12478 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012479 },
12480 [ALC262_BENQ_T31] = {
12481 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012482 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12483 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012484 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12485 .dac_nids = alc262_dac_nids,
12486 .hp_nid = 0x03,
12487 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12488 .channel_mode = alc262_modes,
12489 .input_mux = &alc262_capture_source,
12490 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012491 .setup = alc262_hippo_setup,
12492 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012493 },
Tobin Davisf651b502007-10-26 12:40:47 +020012494 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012495 .mixers = { alc262_ultra_mixer },
12496 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012497 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012498 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12499 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012500 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12501 .channel_mode = alc262_modes,
12502 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012503 .adc_nids = alc262_adc_nids, /* ADC0 */
12504 .capsrc_nids = alc262_capsrc_nids,
12505 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012506 .unsol_event = alc262_ultra_unsol_event,
12507 .init_hook = alc262_ultra_automute,
12508 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012509 [ALC262_LENOVO_3000] = {
12510 .mixers = { alc262_lenovo_3000_mixer },
12511 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012512 alc262_lenovo_3000_unsol_verbs,
12513 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012514 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12515 .dac_nids = alc262_dac_nids,
12516 .hp_nid = 0x03,
12517 .dig_out_nid = ALC262_DIGOUT_NID,
12518 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12519 .channel_mode = alc262_modes,
12520 .input_mux = &alc262_fujitsu_capture_source,
12521 .unsol_event = alc262_lenovo_3000_unsol_event,
12522 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012523 [ALC262_NEC] = {
12524 .mixers = { alc262_nec_mixer },
12525 .init_verbs = { alc262_nec_verbs },
12526 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12527 .dac_nids = alc262_dac_nids,
12528 .hp_nid = 0x03,
12529 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12530 .channel_mode = alc262_modes,
12531 .input_mux = &alc262_capture_source,
12532 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012533 [ALC262_TOSHIBA_S06] = {
12534 .mixers = { alc262_toshiba_s06_mixer },
12535 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12536 alc262_eapd_verbs },
12537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12538 .capsrc_nids = alc262_dmic_capsrc_nids,
12539 .dac_nids = alc262_dac_nids,
12540 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012541 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012542 .dig_out_nid = ALC262_DIGOUT_NID,
12543 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12544 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012545 .unsol_event = alc_sku_unsol_event,
12546 .setup = alc262_toshiba_s06_setup,
12547 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012548 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012549 [ALC262_TOSHIBA_RX1] = {
12550 .mixers = { alc262_toshiba_rx1_mixer },
12551 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12552 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12553 .dac_nids = alc262_dac_nids,
12554 .hp_nid = 0x03,
12555 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12556 .channel_mode = alc262_modes,
12557 .input_mux = &alc262_capture_source,
12558 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012559 .setup = alc262_hippo_setup,
12560 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012561 },
Tony Vroonba340e82009-02-02 19:01:30 +000012562 [ALC262_TYAN] = {
12563 .mixers = { alc262_tyan_mixer },
12564 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12565 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12566 .dac_nids = alc262_dac_nids,
12567 .hp_nid = 0x02,
12568 .dig_out_nid = ALC262_DIGOUT_NID,
12569 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12570 .channel_mode = alc262_modes,
12571 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012572 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012573 .setup = alc262_tyan_setup,
12574 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012575 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012576};
12577
12578static int patch_alc262(struct hda_codec *codec)
12579{
12580 struct alc_spec *spec;
12581 int board_config;
12582 int err;
12583
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012584 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012585 if (spec == NULL)
12586 return -ENOMEM;
12587
12588 codec->spec = spec;
12589#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012590 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12591 * under-run
12592 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012593 {
12594 int tmp;
12595 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12596 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12597 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12598 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12599 }
12600#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012601 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012602
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012603 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12604
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012605 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12606 alc262_models,
12607 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012608
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012609 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012610 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12611 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012612 board_config = ALC262_AUTO;
12613 }
12614
12615 if (board_config == ALC262_AUTO) {
12616 /* automatic parse from the BIOS config */
12617 err = alc262_parse_auto_config(codec);
12618 if (err < 0) {
12619 alc_free(codec);
12620 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012621 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012622 printk(KERN_INFO
12623 "hda_codec: Cannot set up configuration "
12624 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012625 board_config = ALC262_BASIC;
12626 }
12627 }
12628
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012629 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012630 err = snd_hda_attach_beep_device(codec, 0x1);
12631 if (err < 0) {
12632 alc_free(codec);
12633 return err;
12634 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012635 }
12636
Kailang Yangdf694da2005-12-05 19:42:22 +010012637 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012638 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012639
Kailang Yangdf694da2005-12-05 19:42:22 +010012640 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12641 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012642
Kailang Yangdf694da2005-12-05 19:42:22 +010012643 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12644 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012646 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012647 int i;
12648 /* check whether the digital-mic has to be supported */
12649 for (i = 0; i < spec->input_mux->num_items; i++) {
12650 if (spec->input_mux->items[i].index >= 9)
12651 break;
12652 }
12653 if (i < spec->input_mux->num_items) {
12654 /* use only ADC0 */
12655 spec->adc_nids = alc262_dmic_adc_nids;
12656 spec->num_adc_nids = 1;
12657 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012658 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012659 /* all analog inputs */
12660 /* check whether NID 0x07 is valid */
12661 unsigned int wcap = get_wcaps(codec, 0x07);
12662
12663 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012664 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012665 if (wcap != AC_WID_AUD_IN) {
12666 spec->adc_nids = alc262_adc_nids_alt;
12667 spec->num_adc_nids =
12668 ARRAY_SIZE(alc262_adc_nids_alt);
12669 spec->capsrc_nids = alc262_capsrc_nids_alt;
12670 } else {
12671 spec->adc_nids = alc262_adc_nids;
12672 spec->num_adc_nids =
12673 ARRAY_SIZE(alc262_adc_nids);
12674 spec->capsrc_nids = alc262_capsrc_nids;
12675 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012676 }
12677 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012678 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012679 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012680 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012681 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012682
Takashi Iwai2134ea42008-01-10 16:53:55 +010012683 spec->vmaster_nid = 0x0c;
12684
Kailang Yangdf694da2005-12-05 19:42:22 +010012685 codec->patch_ops = alc_patch_ops;
12686 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012687 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012688#ifdef CONFIG_SND_HDA_POWER_SAVE
12689 if (!spec->loopback.amplist)
12690 spec->loopback.amplist = alc262_loopbacks;
12691#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012692
Kailang Yangdf694da2005-12-05 19:42:22 +010012693 return 0;
12694}
12695
Kailang Yangdf694da2005-12-05 19:42:22 +010012696/*
Kailang Yanga361d842007-06-05 12:30:55 +020012697 * ALC268 channel source setting (2 channel)
12698 */
12699#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12700#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012701
Kailang Yanga361d842007-06-05 12:30:55 +020012702static hda_nid_t alc268_dac_nids[2] = {
12703 /* front, hp */
12704 0x02, 0x03
12705};
12706
12707static hda_nid_t alc268_adc_nids[2] = {
12708 /* ADC0-1 */
12709 0x08, 0x07
12710};
12711
12712static hda_nid_t alc268_adc_nids_alt[1] = {
12713 /* ADC0 */
12714 0x08
12715};
12716
Takashi Iwaie1406342008-02-11 18:32:32 +010012717static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12718
Kailang Yanga361d842007-06-05 12:30:55 +020012719static struct snd_kcontrol_new alc268_base_mixer[] = {
12720 /* output mixer control */
12721 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12722 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12726 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12727 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012728 { }
12729};
12730
Takashi Iwai42171c12009-05-08 14:11:43 +020012731static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12732 /* output mixer control */
12733 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12734 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12735 ALC262_HIPPO_MASTER_SWITCH,
12736 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12737 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12738 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12739 { }
12740};
12741
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012742/* bind Beep switches of both NID 0x0f and 0x10 */
12743static struct hda_bind_ctls alc268_bind_beep_sw = {
12744 .ops = &snd_hda_bind_sw,
12745 .values = {
12746 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12747 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12748 0
12749 },
12750};
12751
12752static struct snd_kcontrol_new alc268_beep_mixer[] = {
12753 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12754 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12755 { }
12756};
12757
Kailang Yangd1a991a2007-08-15 16:21:59 +020012758static struct hda_verb alc268_eapd_verbs[] = {
12759 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12760 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12761 { }
12762};
12763
Takashi Iwaid2738092007-08-16 14:59:45 +020012764/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012765static struct hda_verb alc268_toshiba_verbs[] = {
12766 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12767 { } /* end */
12768};
12769
12770/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012771/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012772static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12773 .ops = &snd_hda_bind_vol,
12774 .values = {
12775 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12776 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12777 0
12778 },
12779};
12780
Takashi Iwai889c4392007-08-23 18:56:52 +020012781/* mute/unmute internal speaker according to the hp jack and mute state */
12782static void alc268_acer_automute(struct hda_codec *codec, int force)
12783{
12784 struct alc_spec *spec = codec->spec;
12785 unsigned int mute;
12786
12787 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012788 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012789 spec->sense_updated = 1;
12790 }
12791 if (spec->jack_present)
12792 mute = HDA_AMP_MUTE; /* mute internal speaker */
12793 else /* unmute internal speaker if necessary */
12794 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12795 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12796 HDA_AMP_MUTE, mute);
12797}
12798
12799
12800/* bind hp and internal speaker mute (with plug check) */
12801static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12802 struct snd_ctl_elem_value *ucontrol)
12803{
12804 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12805 long *valp = ucontrol->value.integer.value;
12806 int change;
12807
Takashi Iwai8de56b72009-07-24 16:51:47 +020012808 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012809 if (change)
12810 alc268_acer_automute(codec, 0);
12811 return change;
12812}
Takashi Iwaid2738092007-08-16 14:59:45 +020012813
Kailang Yang8ef355d2008-08-26 13:10:22 +020012814static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12815 /* output mixer control */
12816 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12817 {
12818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12819 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012820 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012821 .info = snd_hda_mixer_amp_switch_info,
12822 .get = snd_hda_mixer_amp_switch_get,
12823 .put = alc268_acer_master_sw_put,
12824 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12825 },
12826 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12827 { }
12828};
12829
Takashi Iwaid2738092007-08-16 14:59:45 +020012830static struct snd_kcontrol_new alc268_acer_mixer[] = {
12831 /* output mixer control */
12832 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12833 {
12834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12835 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012836 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012837 .info = snd_hda_mixer_amp_switch_info,
12838 .get = snd_hda_mixer_amp_switch_get,
12839 .put = alc268_acer_master_sw_put,
12840 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12841 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012842 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12843 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12844 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012845 { }
12846};
12847
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012848static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12849 /* output mixer control */
12850 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12851 {
12852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12853 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012854 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012855 .info = snd_hda_mixer_amp_switch_info,
12856 .get = snd_hda_mixer_amp_switch_get,
12857 .put = alc268_acer_master_sw_put,
12858 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12859 },
12860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12861 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12862 { }
12863};
12864
Kailang Yang8ef355d2008-08-26 13:10:22 +020012865static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12866 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12868 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12870 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12872 { }
12873};
12874
Takashi Iwaid2738092007-08-16 14:59:45 +020012875static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12877 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012878 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12879 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012880 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12881 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012882 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12883 { }
12884};
12885
12886/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012887#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012888#define alc268_toshiba_setup alc262_hippo_setup
12889#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012890
12891static void alc268_acer_unsol_event(struct hda_codec *codec,
12892 unsigned int res)
12893{
Takashi Iwai889c4392007-08-23 18:56:52 +020012894 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012895 return;
12896 alc268_acer_automute(codec, 1);
12897}
12898
Takashi Iwai889c4392007-08-23 18:56:52 +020012899static void alc268_acer_init_hook(struct hda_codec *codec)
12900{
12901 alc268_acer_automute(codec, 1);
12902}
12903
Kailang Yang8ef355d2008-08-26 13:10:22 +020012904/* toggle speaker-output according to the hp-jack state */
12905static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12906{
12907 unsigned int present;
12908 unsigned char bits;
12909
Wu Fengguang864f92b2009-11-18 12:38:02 +080012910 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012911 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012912 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012913 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012914 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012915 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012916}
12917
Kailang Yang8ef355d2008-08-26 13:10:22 +020012918static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12919 unsigned int res)
12920{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012921 switch (res >> 26) {
12922 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012923 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012924 break;
12925 case ALC880_MIC_EVENT:
12926 alc_mic_automute(codec);
12927 break;
12928 }
12929}
12930
12931static void alc268_acer_lc_setup(struct hda_codec *codec)
12932{
12933 struct alc_spec *spec = codec->spec;
12934 spec->ext_mic.pin = 0x18;
12935 spec->ext_mic.mux_idx = 0;
12936 spec->int_mic.pin = 0x12;
12937 spec->int_mic.mux_idx = 6;
12938 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012939}
12940
12941static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12942{
12943 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012944 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012945}
12946
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012947static struct snd_kcontrol_new alc268_dell_mixer[] = {
12948 /* output mixer control */
12949 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12950 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12951 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12952 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12953 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12954 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12955 { }
12956};
12957
12958static struct hda_verb alc268_dell_verbs[] = {
12959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12961 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012962 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012963 { }
12964};
12965
12966/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012967static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012968{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012969 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012970
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012971 spec->autocfg.hp_pins[0] = 0x15;
12972 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012973 spec->ext_mic.pin = 0x18;
12974 spec->ext_mic.mux_idx = 0;
12975 spec->int_mic.pin = 0x19;
12976 spec->int_mic.mux_idx = 1;
12977 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012978}
12979
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012980static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12981 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12982 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12983 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12985 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12986 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12987 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12988 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12989 { }
12990};
12991
12992static struct hda_verb alc267_quanta_il1_verbs[] = {
12993 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12994 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12995 { }
12996};
12997
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012998static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012999{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013000 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013001 spec->autocfg.hp_pins[0] = 0x15;
13002 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013003 spec->ext_mic.pin = 0x18;
13004 spec->ext_mic.mux_idx = 0;
13005 spec->int_mic.pin = 0x19;
13006 spec->int_mic.mux_idx = 1;
13007 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013008}
13009
Kailang Yanga361d842007-06-05 12:30:55 +020013010/*
13011 * generic initialization of ADC, input mixers and output mixers
13012 */
13013static struct hda_verb alc268_base_init_verbs[] = {
13014 /* Unmute DAC0-1 and set vol = 0 */
13015 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013016 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013017
13018 /*
13019 * Set up output mixers (0x0c - 0x0e)
13020 */
13021 /* set vol=0 to output mixers */
13022 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013023 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13024
13025 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13026 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13027
13028 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13030 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13031 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13032 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13033 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13034 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13035 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13036
13037 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13039 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13040 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013041 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013042
13043 /* set PCBEEP vol = 0, mute connections */
13044 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13045 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13046 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013047
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013048 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013049
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013050 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13052 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13053 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013054
Kailang Yanga361d842007-06-05 12:30:55 +020013055 { }
13056};
13057
13058/*
13059 * generic initialization of ADC, input mixers and output mixers
13060 */
13061static struct hda_verb alc268_volume_init_verbs[] = {
13062 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013063 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13064 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013065
13066 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13067 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13068 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13069 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13070 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13071
Kailang Yanga361d842007-06-05 12:30:55 +020013072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013073 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13074 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13075
13076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013077 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013078
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013079 /* set PCBEEP vol = 0, mute connections */
13080 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13082 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013083
13084 { }
13085};
13086
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013087static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13088 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13089 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13090 { } /* end */
13091};
13092
Kailang Yanga361d842007-06-05 12:30:55 +020013093static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13094 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13095 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013096 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013097 { } /* end */
13098};
13099
13100static struct snd_kcontrol_new alc268_capture_mixer[] = {
13101 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13102 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13103 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13104 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013105 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013106 { } /* end */
13107};
13108
13109static struct hda_input_mux alc268_capture_source = {
13110 .num_items = 4,
13111 .items = {
13112 { "Mic", 0x0 },
13113 { "Front Mic", 0x1 },
13114 { "Line", 0x2 },
13115 { "CD", 0x3 },
13116 },
13117};
13118
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013119static struct hda_input_mux alc268_acer_capture_source = {
13120 .num_items = 3,
13121 .items = {
13122 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013123 { "Internal Mic", 0x1 },
13124 { "Line", 0x2 },
13125 },
13126};
13127
13128static struct hda_input_mux alc268_acer_dmic_capture_source = {
13129 .num_items = 3,
13130 .items = {
13131 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013132 { "Internal Mic", 0x6 },
13133 { "Line", 0x2 },
13134 },
13135};
13136
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013137#ifdef CONFIG_SND_DEBUG
13138static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013139 /* Volume widgets */
13140 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13141 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13142 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13143 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13144 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13145 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13146 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13147 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13148 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13149 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13150 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13151 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13152 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013153 /* The below appears problematic on some hardwares */
13154 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013155 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13156 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13157 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13158 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13159
13160 /* Modes for retasking pin widgets */
13161 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13162 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13163 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13164 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13165
13166 /* Controls for GPIO pins, assuming they are configured as outputs */
13167 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13168 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13169 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13170 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13171
13172 /* Switches to allow the digital SPDIF output pin to be enabled.
13173 * The ALC268 does not have an SPDIF input.
13174 */
13175 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13176
13177 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13178 * this output to turn on an external amplifier.
13179 */
13180 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13181 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13182
13183 { } /* end */
13184};
13185#endif
13186
Kailang Yanga361d842007-06-05 12:30:55 +020013187/* create input playback/capture controls for the given pin */
13188static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13189 const char *ctlname, int idx)
13190{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013191 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013192 int err;
13193
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013194 switch (nid) {
13195 case 0x14:
13196 case 0x16:
13197 dac = 0x02;
13198 break;
13199 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013200 case 0x1a: /* ALC259/269 only */
13201 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013202 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013203 dac = 0x03;
13204 break;
13205 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013206 snd_printd(KERN_WARNING "hda_codec: "
13207 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013208 return 0;
13209 }
13210 if (spec->multiout.dac_nids[0] != dac &&
13211 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013212 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013213 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013214 HDA_OUTPUT));
13215 if (err < 0)
13216 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013217 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13218 }
13219
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013220 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013221 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013222 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013223 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013224 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013225 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013226 if (err < 0)
13227 return err;
13228 return 0;
13229}
13230
13231/* add playback controls from the parsed DAC table */
13232static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13233 const struct auto_pin_cfg *cfg)
13234{
13235 hda_nid_t nid;
13236 int err;
13237
Kailang Yanga361d842007-06-05 12:30:55 +020013238 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013239
13240 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013241 if (nid) {
13242 const char *name;
13243 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13244 name = "Speaker";
13245 else
13246 name = "Front";
13247 err = alc268_new_analog_output(spec, nid, name, 0);
13248 if (err < 0)
13249 return err;
13250 }
Kailang Yanga361d842007-06-05 12:30:55 +020013251
13252 nid = cfg->speaker_pins[0];
13253 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013254 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013255 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13256 if (err < 0)
13257 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013258 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013259 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13260 if (err < 0)
13261 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013262 }
13263 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013264 if (nid) {
13265 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13266 if (err < 0)
13267 return err;
13268 }
Kailang Yanga361d842007-06-05 12:30:55 +020013269
13270 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13271 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013272 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013273 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013274 if (err < 0)
13275 return err;
13276 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013277 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013278}
13279
13280/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013281static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013282 const struct auto_pin_cfg *cfg)
13283{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013284 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013285}
13286
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013287static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13288 hda_nid_t nid, int pin_type)
13289{
13290 int idx;
13291
13292 alc_set_pin_output(codec, nid, pin_type);
13293 if (nid == 0x14 || nid == 0x16)
13294 idx = 0;
13295 else
13296 idx = 1;
13297 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13298}
13299
13300static void alc268_auto_init_multi_out(struct hda_codec *codec)
13301{
13302 struct alc_spec *spec = codec->spec;
13303 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13304 if (nid) {
13305 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13306 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13307 }
13308}
13309
13310static void alc268_auto_init_hp_out(struct hda_codec *codec)
13311{
13312 struct alc_spec *spec = codec->spec;
13313 hda_nid_t pin;
13314
13315 pin = spec->autocfg.hp_pins[0];
13316 if (pin)
13317 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13318 pin = spec->autocfg.speaker_pins[0];
13319 if (pin)
13320 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13321}
13322
Kailang Yanga361d842007-06-05 12:30:55 +020013323static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13324{
13325 struct alc_spec *spec = codec->spec;
13326 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13327 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13328 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13329 unsigned int dac_vol1, dac_vol2;
13330
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013331 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013332 snd_hda_codec_write(codec, speaker_nid, 0,
13333 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013334 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013335 snd_hda_codec_write(codec, 0x0f, 0,
13336 AC_VERB_SET_AMP_GAIN_MUTE,
13337 AMP_IN_UNMUTE(1));
13338 snd_hda_codec_write(codec, 0x10, 0,
13339 AC_VERB_SET_AMP_GAIN_MUTE,
13340 AMP_IN_UNMUTE(1));
13341 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013342 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013343 snd_hda_codec_write(codec, 0x0f, 0,
13344 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13345 snd_hda_codec_write(codec, 0x10, 0,
13346 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13347 }
13348
13349 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013350 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013351 dac_vol2 = AMP_OUT_ZERO;
13352 else if (line_nid == 0x15)
13353 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013354 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013355 dac_vol2 = AMP_OUT_ZERO;
13356 else if (hp_nid == 0x15)
13357 dac_vol1 = AMP_OUT_ZERO;
13358 if (line_nid != 0x16 || hp_nid != 0x16 ||
13359 spec->autocfg.line_out_pins[1] != 0x16 ||
13360 spec->autocfg.line_out_pins[2] != 0x16)
13361 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13362
13363 snd_hda_codec_write(codec, 0x02, 0,
13364 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13365 snd_hda_codec_write(codec, 0x03, 0,
13366 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13367}
13368
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013369/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013370#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13371#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013372#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013373#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13374
13375/*
13376 * BIOS auto configuration
13377 */
13378static int alc268_parse_auto_config(struct hda_codec *codec)
13379{
13380 struct alc_spec *spec = codec->spec;
13381 int err;
13382 static hda_nid_t alc268_ignore[] = { 0 };
13383
13384 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13385 alc268_ignore);
13386 if (err < 0)
13387 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013388 if (!spec->autocfg.line_outs) {
13389 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13390 spec->multiout.max_channels = 2;
13391 spec->no_analog = 1;
13392 goto dig_only;
13393 }
Kailang Yanga361d842007-06-05 12:30:55 +020013394 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013395 }
Kailang Yanga361d842007-06-05 12:30:55 +020013396 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13397 if (err < 0)
13398 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013399 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013400 if (err < 0)
13401 return err;
13402
13403 spec->multiout.max_channels = 2;
13404
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013405 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013406 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013407 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013408 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013409 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013410
Takashi Iwai892981f2009-03-02 08:04:35 +010013411 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013412 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013413
Takashi Iwaid88897e2008-10-31 15:01:37 +010013414 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013415 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013416 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013417
Takashi Iwai776e1842007-08-29 15:07:11 +020013418 err = alc_auto_add_mic_boost(codec);
13419 if (err < 0)
13420 return err;
13421
Kailang Yang6227cdc2010-02-25 08:36:52 +010013422 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013423
Kailang Yanga361d842007-06-05 12:30:55 +020013424 return 1;
13425}
13426
Kailang Yanga361d842007-06-05 12:30:55 +020013427#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13428
13429/* init callback for auto-configuration model -- overriding the default init */
13430static void alc268_auto_init(struct hda_codec *codec)
13431{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013432 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013433 alc268_auto_init_multi_out(codec);
13434 alc268_auto_init_hp_out(codec);
13435 alc268_auto_init_mono_speaker_out(codec);
13436 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013437 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013438 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013439 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013440}
13441
13442/*
13443 * configuration and preset
13444 */
13445static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013446 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013447 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013448 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013449 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013450 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013451 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013452 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013453 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013454#ifdef CONFIG_SND_DEBUG
13455 [ALC268_TEST] = "test",
13456#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013457 [ALC268_AUTO] = "auto",
13458};
13459
13460static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013461 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013462 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013463 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013464 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013465 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013466 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13467 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013468 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013469 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13470 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013471 /* almost compatible with toshiba but with optional digital outs;
13472 * auto-probing seems working fine
13473 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013474 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013475 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013476 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013477 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013478 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013479 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013480 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013481 {}
13482};
13483
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013484/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13485static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13486 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13487 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13488 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13489 ALC268_TOSHIBA),
13490 {}
13491};
13492
Kailang Yanga361d842007-06-05 12:30:55 +020013493static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013494 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013495 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13496 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013497 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13498 alc267_quanta_il1_verbs },
13499 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13500 .dac_nids = alc268_dac_nids,
13501 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13502 .adc_nids = alc268_adc_nids_alt,
13503 .hp_nid = 0x03,
13504 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13505 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013506 .unsol_event = alc_sku_unsol_event,
13507 .setup = alc267_quanta_il1_setup,
13508 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013509 },
Kailang Yanga361d842007-06-05 12:30:55 +020013510 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013511 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13512 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013513 .init_verbs = { alc268_base_init_verbs },
13514 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13515 .dac_nids = alc268_dac_nids,
13516 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13517 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013518 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013519 .hp_nid = 0x03,
13520 .dig_out_nid = ALC268_DIGOUT_NID,
13521 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13522 .channel_mode = alc268_modes,
13523 .input_mux = &alc268_capture_source,
13524 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013525 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013526 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013527 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013528 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13529 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013530 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13531 .dac_nids = alc268_dac_nids,
13532 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13533 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013534 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013535 .hp_nid = 0x03,
13536 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13537 .channel_mode = alc268_modes,
13538 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013539 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013540 .setup = alc268_toshiba_setup,
13541 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013542 },
13543 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013544 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013545 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013546 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13547 alc268_acer_verbs },
13548 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13549 .dac_nids = alc268_dac_nids,
13550 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13551 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013552 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013553 .hp_nid = 0x02,
13554 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13555 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013556 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013557 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013558 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013559 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013560 [ALC268_ACER_DMIC] = {
13561 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13562 alc268_beep_mixer },
13563 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13564 alc268_acer_verbs },
13565 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13566 .dac_nids = alc268_dac_nids,
13567 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13568 .adc_nids = alc268_adc_nids_alt,
13569 .capsrc_nids = alc268_capsrc_nids,
13570 .hp_nid = 0x02,
13571 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13572 .channel_mode = alc268_modes,
13573 .input_mux = &alc268_acer_dmic_capture_source,
13574 .unsol_event = alc268_acer_unsol_event,
13575 .init_hook = alc268_acer_init_hook,
13576 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013577 [ALC268_ACER_ASPIRE_ONE] = {
13578 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013579 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013580 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013581 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13582 alc268_acer_aspire_one_verbs },
13583 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13584 .dac_nids = alc268_dac_nids,
13585 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13586 .adc_nids = alc268_adc_nids_alt,
13587 .capsrc_nids = alc268_capsrc_nids,
13588 .hp_nid = 0x03,
13589 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13590 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013591 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013592 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013593 .init_hook = alc268_acer_lc_init_hook,
13594 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013595 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013596 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13597 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013598 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13599 alc268_dell_verbs },
13600 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13601 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013602 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13603 .adc_nids = alc268_adc_nids_alt,
13604 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013605 .hp_nid = 0x02,
13606 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13607 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013608 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013609 .setup = alc268_dell_setup,
13610 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013611 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013612 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013613 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13614 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013615 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13616 alc268_toshiba_verbs },
13617 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13618 .dac_nids = alc268_dac_nids,
13619 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13620 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013621 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013622 .hp_nid = 0x03,
13623 .dig_out_nid = ALC268_DIGOUT_NID,
13624 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13625 .channel_mode = alc268_modes,
13626 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013627 .setup = alc268_toshiba_setup,
13628 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013629 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013630#ifdef CONFIG_SND_DEBUG
13631 [ALC268_TEST] = {
13632 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13633 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13634 alc268_volume_init_verbs },
13635 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13636 .dac_nids = alc268_dac_nids,
13637 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13638 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013639 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013640 .hp_nid = 0x03,
13641 .dig_out_nid = ALC268_DIGOUT_NID,
13642 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13643 .channel_mode = alc268_modes,
13644 .input_mux = &alc268_capture_source,
13645 },
13646#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013647};
13648
13649static int patch_alc268(struct hda_codec *codec)
13650{
13651 struct alc_spec *spec;
13652 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013653 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013654
Julia Lawallef86f582009-12-19 08:18:03 +010013655 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013656 if (spec == NULL)
13657 return -ENOMEM;
13658
13659 codec->spec = spec;
13660
13661 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13662 alc268_models,
13663 alc268_cfg_tbl);
13664
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013665 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13666 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013667 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013668
Kailang Yanga361d842007-06-05 12:30:55 +020013669 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013670 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13671 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013672 board_config = ALC268_AUTO;
13673 }
13674
13675 if (board_config == ALC268_AUTO) {
13676 /* automatic parse from the BIOS config */
13677 err = alc268_parse_auto_config(codec);
13678 if (err < 0) {
13679 alc_free(codec);
13680 return err;
13681 } else if (!err) {
13682 printk(KERN_INFO
13683 "hda_codec: Cannot set up configuration "
13684 "from BIOS. Using base mode...\n");
13685 board_config = ALC268_3ST;
13686 }
13687 }
13688
13689 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013690 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013691
Kailang Yanga361d842007-06-05 12:30:55 +020013692 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13693 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013694 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013695
Kailang Yanga361d842007-06-05 12:30:55 +020013696 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13697
Takashi Iwai22971e32009-02-10 11:56:44 +010013698 has_beep = 0;
13699 for (i = 0; i < spec->num_mixers; i++) {
13700 if (spec->mixers[i] == alc268_beep_mixer) {
13701 has_beep = 1;
13702 break;
13703 }
13704 }
13705
13706 if (has_beep) {
13707 err = snd_hda_attach_beep_device(codec, 0x1);
13708 if (err < 0) {
13709 alc_free(codec);
13710 return err;
13711 }
13712 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13713 /* override the amp caps for beep generator */
13714 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013715 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13716 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13717 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13718 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013719 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013720
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013721 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013722 /* check whether NID 0x07 is valid */
13723 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013724 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013725
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013726 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013727 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013728 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013729 if (spec->auto_mic ||
13730 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013731 spec->adc_nids = alc268_adc_nids_alt;
13732 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013733 if (spec->auto_mic)
13734 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013735 if (spec->auto_mic || spec->input_mux->num_items == 1)
13736 add_mixer(spec, alc268_capture_nosrc_mixer);
13737 else
13738 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013739 } else {
13740 spec->adc_nids = alc268_adc_nids;
13741 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013742 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013743 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013744 /* set default input source */
13745 for (i = 0; i < spec->num_adc_nids; i++)
13746 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13747 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013748 i < spec->num_mux_defs ?
13749 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013750 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013751 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013752
13753 spec->vmaster_nid = 0x02;
13754
Kailang Yanga361d842007-06-05 12:30:55 +020013755 codec->patch_ops = alc_patch_ops;
13756 if (board_config == ALC268_AUTO)
13757 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013758
Kailang Yanga361d842007-06-05 12:30:55 +020013759 return 0;
13760}
13761
13762/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013763 * ALC269 channel source setting (2 channel)
13764 */
13765#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13766
13767#define alc269_dac_nids alc260_dac_nids
13768
13769static hda_nid_t alc269_adc_nids[1] = {
13770 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013771 0x08,
13772};
13773
Takashi Iwaie01bf502008-08-21 16:25:07 +020013774static hda_nid_t alc269_capsrc_nids[1] = {
13775 0x23,
13776};
13777
Kailang Yang84898e82010-02-04 14:16:14 +010013778static hda_nid_t alc269vb_adc_nids[1] = {
13779 /* ADC1 */
13780 0x09,
13781};
13782
13783static hda_nid_t alc269vb_capsrc_nids[1] = {
13784 0x22,
13785};
13786
Takashi Iwai66946352010-03-29 17:21:45 +020013787static hda_nid_t alc269_adc_candidates[] = {
13788 0x08, 0x09, 0x07,
13789};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013790
Kailang Yangf6a92242007-12-13 16:52:54 +010013791#define alc269_modes alc260_modes
13792#define alc269_capture_source alc880_lg_lw_capture_source
13793
13794static struct snd_kcontrol_new alc269_base_mixer[] = {
13795 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13796 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13797 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13798 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13801 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13802 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13803 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13804 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13805 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13806 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13807 { } /* end */
13808};
13809
Kailang Yang60db6b52008-08-26 13:13:00 +020013810static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13811 /* output mixer control */
13812 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13813 {
13814 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13815 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013816 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013817 .info = snd_hda_mixer_amp_switch_info,
13818 .get = snd_hda_mixer_amp_switch_get,
13819 .put = alc268_acer_master_sw_put,
13820 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13821 },
13822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13823 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13824 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13825 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13826 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13827 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013828 { }
13829};
13830
Tony Vroon64154832008-11-06 15:08:49 +000013831static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13832 /* output mixer control */
13833 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13834 {
13835 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13836 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013837 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013838 .info = snd_hda_mixer_amp_switch_info,
13839 .get = snd_hda_mixer_amp_switch_get,
13840 .put = alc268_acer_master_sw_put,
13841 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13842 },
13843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13845 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13846 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13847 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13848 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13849 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13850 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13851 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013852 { }
13853};
13854
Kailang Yang84898e82010-02-04 14:16:14 +010013855static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013856 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013857 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013859 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013860 { } /* end */
13861};
13862
Kailang Yang84898e82010-02-04 14:16:14 +010013863static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13864 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13865 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13866 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13867 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13868 { } /* end */
13869};
13870
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020013871static struct snd_kcontrol_new alc269_asus_mixer[] = {
13872 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13873 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
13874 { } /* end */
13875};
13876
Kailang Yangf6a92242007-12-13 16:52:54 +010013877/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013878static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13879 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13880 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13881 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13882 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13883 { } /* end */
13884};
13885
13886static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013887 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13888 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13890 { } /* end */
13891};
13892
Kailang Yang84898e82010-02-04 14:16:14 +010013893static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13894 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13895 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13897 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13898 { } /* end */
13899};
13900
13901static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13902 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13903 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13904 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13905 { } /* end */
13906};
13907
Takashi Iwai26f5df22008-11-03 17:39:46 +010013908/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013909#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013910
Kailang Yang60db6b52008-08-26 13:13:00 +020013911static struct hda_verb alc269_quanta_fl1_verbs[] = {
13912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13916 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13917 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13918 { }
13919};
13920
Tony Vroon64154832008-11-06 15:08:49 +000013921static struct hda_verb alc269_lifebook_verbs[] = {
13922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13923 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13924 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13925 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13926 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13928 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13929 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13930 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13931 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13932 { }
13933};
13934
Kailang Yang60db6b52008-08-26 13:13:00 +020013935/* toggle speaker-output according to the hp-jack state */
13936static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13937{
13938 unsigned int present;
13939 unsigned char bits;
13940
Wu Fengguang864f92b2009-11-18 12:38:02 +080013941 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013942 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013943 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013944 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013945 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013946 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013947
13948 snd_hda_codec_write(codec, 0x20, 0,
13949 AC_VERB_SET_COEF_INDEX, 0x0c);
13950 snd_hda_codec_write(codec, 0x20, 0,
13951 AC_VERB_SET_PROC_COEF, 0x680);
13952
13953 snd_hda_codec_write(codec, 0x20, 0,
13954 AC_VERB_SET_COEF_INDEX, 0x0c);
13955 snd_hda_codec_write(codec, 0x20, 0,
13956 AC_VERB_SET_PROC_COEF, 0x480);
13957}
13958
Tony Vroon64154832008-11-06 15:08:49 +000013959/* toggle speaker-output according to the hp-jacks state */
13960static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13961{
13962 unsigned int present;
13963 unsigned char bits;
13964
13965 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013966 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013967
13968 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013969 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013970
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013971 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013972 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013973 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013974 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013975 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013976
13977 snd_hda_codec_write(codec, 0x20, 0,
13978 AC_VERB_SET_COEF_INDEX, 0x0c);
13979 snd_hda_codec_write(codec, 0x20, 0,
13980 AC_VERB_SET_PROC_COEF, 0x680);
13981
13982 snd_hda_codec_write(codec, 0x20, 0,
13983 AC_VERB_SET_COEF_INDEX, 0x0c);
13984 snd_hda_codec_write(codec, 0x20, 0,
13985 AC_VERB_SET_PROC_COEF, 0x480);
13986}
13987
Tony Vroon64154832008-11-06 15:08:49 +000013988static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13989{
13990 unsigned int present_laptop;
13991 unsigned int present_dock;
13992
Wu Fengguang864f92b2009-11-18 12:38:02 +080013993 present_laptop = snd_hda_jack_detect(codec, 0x18);
13994 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013995
13996 /* Laptop mic port overrides dock mic port, design decision */
13997 if (present_dock)
13998 snd_hda_codec_write(codec, 0x23, 0,
13999 AC_VERB_SET_CONNECT_SEL, 0x3);
14000 if (present_laptop)
14001 snd_hda_codec_write(codec, 0x23, 0,
14002 AC_VERB_SET_CONNECT_SEL, 0x0);
14003 if (!present_dock && !present_laptop)
14004 snd_hda_codec_write(codec, 0x23, 0,
14005 AC_VERB_SET_CONNECT_SEL, 0x1);
14006}
14007
Kailang Yang60db6b52008-08-26 13:13:00 +020014008static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14009 unsigned int res)
14010{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014011 switch (res >> 26) {
14012 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014013 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014014 break;
14015 case ALC880_MIC_EVENT:
14016 alc_mic_automute(codec);
14017 break;
14018 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014019}
14020
Tony Vroon64154832008-11-06 15:08:49 +000014021static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14022 unsigned int res)
14023{
14024 if ((res >> 26) == ALC880_HP_EVENT)
14025 alc269_lifebook_speaker_automute(codec);
14026 if ((res >> 26) == ALC880_MIC_EVENT)
14027 alc269_lifebook_mic_autoswitch(codec);
14028}
14029
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014030static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14031{
14032 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014033 spec->autocfg.hp_pins[0] = 0x15;
14034 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014035 spec->ext_mic.pin = 0x18;
14036 spec->ext_mic.mux_idx = 0;
14037 spec->int_mic.pin = 0x19;
14038 spec->int_mic.mux_idx = 1;
14039 spec->auto_mic = 1;
14040}
14041
Kailang Yang60db6b52008-08-26 13:13:00 +020014042static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14043{
14044 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014045 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014046}
14047
Tony Vroon64154832008-11-06 15:08:49 +000014048static void alc269_lifebook_init_hook(struct hda_codec *codec)
14049{
14050 alc269_lifebook_speaker_automute(codec);
14051 alc269_lifebook_mic_autoswitch(codec);
14052}
14053
Kailang Yang84898e82010-02-04 14:16:14 +010014054static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014055 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14056 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14057 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14058 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14059 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14060 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14061 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14062 {}
14063};
14064
Kailang Yang84898e82010-02-04 14:16:14 +010014065static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014066 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14067 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14068 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14070 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14072 {}
14073};
14074
Kailang Yang84898e82010-02-04 14:16:14 +010014075static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14076 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14077 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14078 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14079 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14080 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14081 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14082 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14083 {}
14084};
14085
14086static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14087 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14088 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14089 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14091 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14092 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14093 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14094 {}
14095};
14096
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014097static struct hda_verb alc271_acer_dmic_verbs[] = {
14098 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14099 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14100 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14101 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14102 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14103 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14104 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14105 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14106 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14107 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14108 { }
14109};
14110
Kailang Yang60db6b52008-08-26 13:13:00 +020014111/* toggle speaker-output according to the hp-jack state */
14112static void alc269_speaker_automute(struct hda_codec *codec)
14113{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014114 struct alc_spec *spec = codec->spec;
14115 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014116 unsigned int present;
14117 unsigned char bits;
14118
Kailang Yangebb83ee2009-12-17 12:23:00 +010014119 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014120 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014121 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014122 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014123 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014124 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014125}
14126
Kailang Yang60db6b52008-08-26 13:13:00 +020014127/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014128static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014129 unsigned int res)
14130{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014131 switch (res >> 26) {
14132 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014133 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014134 break;
14135 case ALC880_MIC_EVENT:
14136 alc_mic_automute(codec);
14137 break;
14138 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014139}
14140
Kailang Yang226b1ec2010-04-09 11:01:20 +020014141static void alc269_laptop_amic_setup(struct hda_codec *codec)
14142{
14143 struct alc_spec *spec = codec->spec;
14144 spec->autocfg.hp_pins[0] = 0x15;
14145 spec->autocfg.speaker_pins[0] = 0x14;
14146 spec->ext_mic.pin = 0x18;
14147 spec->ext_mic.mux_idx = 0;
14148 spec->int_mic.pin = 0x19;
14149 spec->int_mic.mux_idx = 1;
14150 spec->auto_mic = 1;
14151}
14152
Kailang Yang84898e82010-02-04 14:16:14 +010014153static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014154{
14155 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014156 spec->autocfg.hp_pins[0] = 0x15;
14157 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014158 spec->ext_mic.pin = 0x18;
14159 spec->ext_mic.mux_idx = 0;
14160 spec->int_mic.pin = 0x12;
14161 spec->int_mic.mux_idx = 5;
14162 spec->auto_mic = 1;
14163}
14164
Kailang Yang226b1ec2010-04-09 11:01:20 +020014165static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014166{
14167 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014168 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014169 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014170 spec->ext_mic.pin = 0x18;
14171 spec->ext_mic.mux_idx = 0;
14172 spec->int_mic.pin = 0x19;
14173 spec->int_mic.mux_idx = 1;
14174 spec->auto_mic = 1;
14175}
14176
Kailang Yang226b1ec2010-04-09 11:01:20 +020014177static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14178{
14179 struct alc_spec *spec = codec->spec;
14180 spec->autocfg.hp_pins[0] = 0x21;
14181 spec->autocfg.speaker_pins[0] = 0x14;
14182 spec->ext_mic.pin = 0x18;
14183 spec->ext_mic.mux_idx = 0;
14184 spec->int_mic.pin = 0x12;
14185 spec->int_mic.mux_idx = 6;
14186 spec->auto_mic = 1;
14187}
14188
Kailang Yang84898e82010-02-04 14:16:14 +010014189static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014190{
14191 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014192 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014193}
14194
Kailang Yangf6a92242007-12-13 16:52:54 +010014195/*
14196 * generic initialization of ADC, input mixers and output mixers
14197 */
14198static struct hda_verb alc269_init_verbs[] = {
14199 /*
14200 * Unmute ADC0 and set the default input to mic-in
14201 */
Kailang Yang84898e82010-02-04 14:16:14 +010014202 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014203
14204 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014205 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014206 */
14207 /* set vol=0 to output mixers */
14208 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14209 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14210
14211 /* set up input amps for analog loopback */
14212 /* Amp Indices: DAC = 0, mixer = 1 */
14213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14214 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14215 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14217 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14218 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14219
14220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14221 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14222 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14224 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14225 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14226 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14227
14228 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014230
Kailang Yang84898e82010-02-04 14:16:14 +010014231 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014232 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14233 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014234 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014235
14236 /* set EAPD */
14237 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014238 { }
14239};
14240
14241static struct hda_verb alc269vb_init_verbs[] = {
14242 /*
14243 * Unmute ADC0 and set the default input to mic-in
14244 */
14245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14246
14247 /*
14248 * Set up output mixers (0x02 - 0x03)
14249 */
14250 /* set vol=0 to output mixers */
14251 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14252 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14253
14254 /* set up input amps for analog loopback */
14255 /* Amp Indices: DAC = 0, mixer = 1 */
14256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14259 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14260 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14261 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14262
14263 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14264 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14265 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14266 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14270
14271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14272 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14273
14274 /* FIXME: use Mux-type input source selection */
14275 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14276 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14277 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14278
14279 /* set EAPD */
14280 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014281 { }
14282};
14283
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014284#define alc269_auto_create_multi_out_ctls \
14285 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014286#define alc269_auto_create_input_ctls \
14287 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014288
14289#ifdef CONFIG_SND_HDA_POWER_SAVE
14290#define alc269_loopbacks alc880_loopbacks
14291#endif
14292
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014293/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014294#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14295#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14296#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14297#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14298
Takashi Iwaif03d3112009-03-05 14:18:16 +010014299static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14300 .substreams = 1,
14301 .channels_min = 2,
14302 .channels_max = 8,
14303 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14304 /* NID is set in alc_build_pcms */
14305 .ops = {
14306 .open = alc880_playback_pcm_open,
14307 .prepare = alc880_playback_pcm_prepare,
14308 .cleanup = alc880_playback_pcm_cleanup
14309 },
14310};
14311
14312static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14313 .substreams = 1,
14314 .channels_min = 2,
14315 .channels_max = 2,
14316 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14317 /* NID is set in alc_build_pcms */
14318};
14319
Takashi Iwaiad358792010-03-30 18:00:59 +020014320#ifdef CONFIG_SND_HDA_POWER_SAVE
14321static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14322{
14323 switch (codec->subsystem_id) {
14324 case 0x103c1586:
14325 return 1;
14326 }
14327 return 0;
14328}
14329
14330static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14331{
14332 /* update mute-LED according to the speaker mute state */
14333 if (nid == 0x01 || nid == 0x14) {
14334 int pinval;
14335 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14336 HDA_AMP_MUTE)
14337 pinval = 0x24;
14338 else
14339 pinval = 0x20;
14340 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014341 snd_hda_codec_update_cache(codec, 0x19, 0,
14342 AC_VERB_SET_PIN_WIDGET_CONTROL,
14343 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014344 }
14345 return alc_check_power_status(codec, nid);
14346}
14347#endif /* CONFIG_SND_HDA_POWER_SAVE */
14348
Takashi Iwai840b64c2010-07-13 22:49:01 +020014349static int alc275_setup_dual_adc(struct hda_codec *codec)
14350{
14351 struct alc_spec *spec = codec->spec;
14352
14353 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14354 return 0;
14355 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14356 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14357 if (spec->ext_mic.pin <= 0x12) {
14358 spec->private_adc_nids[0] = 0x08;
14359 spec->private_adc_nids[1] = 0x11;
14360 spec->private_capsrc_nids[0] = 0x23;
14361 spec->private_capsrc_nids[1] = 0x22;
14362 } else {
14363 spec->private_adc_nids[0] = 0x11;
14364 spec->private_adc_nids[1] = 0x08;
14365 spec->private_capsrc_nids[0] = 0x22;
14366 spec->private_capsrc_nids[1] = 0x23;
14367 }
14368 spec->adc_nids = spec->private_adc_nids;
14369 spec->capsrc_nids = spec->private_capsrc_nids;
14370 spec->num_adc_nids = 2;
14371 spec->dual_adc_switch = 1;
14372 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14373 spec->adc_nids[0], spec->adc_nids[1]);
14374 return 1;
14375 }
14376 return 0;
14377}
14378
Kailang Yangf6a92242007-12-13 16:52:54 +010014379/*
14380 * BIOS auto configuration
14381 */
14382static int alc269_parse_auto_config(struct hda_codec *codec)
14383{
14384 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014385 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014386 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14387
14388 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14389 alc269_ignore);
14390 if (err < 0)
14391 return err;
14392
14393 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14394 if (err < 0)
14395 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014396 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014397 if (err < 0)
14398 return err;
14399
14400 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14401
Takashi Iwai757899a2010-07-30 10:48:14 +020014402 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014403
Takashi Iwai603c4012008-07-30 15:01:44 +020014404 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014405 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014406
Kailang Yang84898e82010-02-04 14:16:14 +010014407 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14408 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014409 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014410 } else {
14411 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014412 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014413 }
14414
Kailang Yangf6a92242007-12-13 16:52:54 +010014415 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014416 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014417
14418 if (!alc275_setup_dual_adc(codec))
14419 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14420 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014421
Takashi Iwaie01bf502008-08-21 16:25:07 +020014422 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014423 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014424 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14425 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014426
14427 err = alc_auto_add_mic_boost(codec);
14428 if (err < 0)
14429 return err;
14430
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014431 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014432 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014433
Kailang Yangf6a92242007-12-13 16:52:54 +010014434 return 1;
14435}
14436
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014437#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14438#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014439#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14440
14441
14442/* init callback for auto-configuration model -- overriding the default init */
14443static void alc269_auto_init(struct hda_codec *codec)
14444{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014445 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014446 alc269_auto_init_multi_out(codec);
14447 alc269_auto_init_hp_out(codec);
14448 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014449 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014450 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014451 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014452}
14453
Takashi Iwaiff818c22010-04-12 08:59:25 +020014454enum {
14455 ALC269_FIXUP_SONY_VAIO,
14456};
14457
Tobias Klauserfbc25662010-05-20 10:40:55 +020014458static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
Takashi Iwaiff818c22010-04-12 08:59:25 +020014459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14460 {}
14461};
14462
14463static const struct alc_fixup alc269_fixups[] = {
14464 [ALC269_FIXUP_SONY_VAIO] = {
14465 .verbs = alc269_sony_vaio_fixup_verbs
14466 },
14467};
14468
14469static struct snd_pci_quirk alc269_fixup_tbl[] = {
14470 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014471 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014472 {}
14473};
14474
14475
Kailang Yangf6a92242007-12-13 16:52:54 +010014476/*
14477 * configuration and preset
14478 */
14479static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014480 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014481 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014482 [ALC269_AMIC] = "laptop-amic",
14483 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014484 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014485 [ALC269_LIFEBOOK] = "lifebook",
14486 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014487};
14488
14489static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014490 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014491 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014492 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014493 ALC269_AMIC),
14494 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14495 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14496 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14497 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14498 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14499 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14500 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14501 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14502 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14503 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14504 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14505 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14506 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14507 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14508 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14509 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14510 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14511 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14512 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14513 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14514 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14515 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14516 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14517 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14518 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14519 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14520 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14521 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14522 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14523 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14524 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14525 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14526 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14527 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14528 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14529 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014530 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014531 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014532 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014533 ALC269_DMIC),
14534 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14535 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014536 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014537 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014538 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14539 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14540 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14541 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14542 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14543 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014544 {}
14545};
14546
14547static struct alc_config_preset alc269_presets[] = {
14548 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014549 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014550 .init_verbs = { alc269_init_verbs },
14551 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14552 .dac_nids = alc269_dac_nids,
14553 .hp_nid = 0x03,
14554 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14555 .channel_mode = alc269_modes,
14556 .input_mux = &alc269_capture_source,
14557 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014558 [ALC269_QUANTA_FL1] = {
14559 .mixers = { alc269_quanta_fl1_mixer },
14560 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14561 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14562 .dac_nids = alc269_dac_nids,
14563 .hp_nid = 0x03,
14564 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14565 .channel_mode = alc269_modes,
14566 .input_mux = &alc269_capture_source,
14567 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014568 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014569 .init_hook = alc269_quanta_fl1_init_hook,
14570 },
Kailang Yang84898e82010-02-04 14:16:14 +010014571 [ALC269_AMIC] = {
14572 .mixers = { alc269_laptop_mixer },
14573 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014574 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014575 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014576 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14577 .dac_nids = alc269_dac_nids,
14578 .hp_nid = 0x03,
14579 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14580 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014581 .unsol_event = alc269_laptop_unsol_event,
14582 .setup = alc269_laptop_amic_setup,
14583 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014584 },
Kailang Yang84898e82010-02-04 14:16:14 +010014585 [ALC269_DMIC] = {
14586 .mixers = { alc269_laptop_mixer },
14587 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014588 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014589 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014590 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14591 .dac_nids = alc269_dac_nids,
14592 .hp_nid = 0x03,
14593 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14594 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014595 .unsol_event = alc269_laptop_unsol_event,
14596 .setup = alc269_laptop_dmic_setup,
14597 .init_hook = alc269_laptop_inithook,
14598 },
14599 [ALC269VB_AMIC] = {
14600 .mixers = { alc269vb_laptop_mixer },
14601 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14602 .init_verbs = { alc269vb_init_verbs,
14603 alc269vb_laptop_amic_init_verbs },
14604 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14605 .dac_nids = alc269_dac_nids,
14606 .hp_nid = 0x03,
14607 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14608 .channel_mode = alc269_modes,
14609 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014610 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014611 .init_hook = alc269_laptop_inithook,
14612 },
14613 [ALC269VB_DMIC] = {
14614 .mixers = { alc269vb_laptop_mixer },
14615 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14616 .init_verbs = { alc269vb_init_verbs,
14617 alc269vb_laptop_dmic_init_verbs },
14618 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14619 .dac_nids = alc269_dac_nids,
14620 .hp_nid = 0x03,
14621 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14622 .channel_mode = alc269_modes,
14623 .unsol_event = alc269_laptop_unsol_event,
14624 .setup = alc269vb_laptop_dmic_setup,
14625 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014626 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014627 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014628 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014629 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014630 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014631 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014632 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14633 .dac_nids = alc269_dac_nids,
14634 .hp_nid = 0x03,
14635 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14636 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014637 .unsol_event = alc269_laptop_unsol_event,
14638 .setup = alc269_laptop_dmic_setup,
14639 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014640 },
Tony Vroon64154832008-11-06 15:08:49 +000014641 [ALC269_LIFEBOOK] = {
14642 .mixers = { alc269_lifebook_mixer },
14643 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14644 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14645 .dac_nids = alc269_dac_nids,
14646 .hp_nid = 0x03,
14647 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14648 .channel_mode = alc269_modes,
14649 .input_mux = &alc269_capture_source,
14650 .unsol_event = alc269_lifebook_unsol_event,
14651 .init_hook = alc269_lifebook_init_hook,
14652 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014653 [ALC271_ACER] = {
14654 .mixers = { alc269_asus_mixer },
14655 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14656 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14657 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14658 .dac_nids = alc269_dac_nids,
14659 .adc_nids = alc262_dmic_adc_nids,
14660 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14661 .capsrc_nids = alc262_dmic_capsrc_nids,
14662 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14663 .channel_mode = alc269_modes,
14664 .input_mux = &alc269_capture_source,
14665 .dig_out_nid = ALC880_DIGOUT_NID,
14666 .unsol_event = alc_sku_unsol_event,
14667 .setup = alc269vb_laptop_dmic_setup,
14668 .init_hook = alc_inithook,
14669 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014670};
14671
14672static int patch_alc269(struct hda_codec *codec)
14673{
14674 struct alc_spec *spec;
14675 int board_config;
14676 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014677 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014678
14679 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14680 if (spec == NULL)
14681 return -ENOMEM;
14682
14683 codec->spec = spec;
14684
Kailang Yangda00c242010-03-19 11:23:45 +010014685 alc_auto_parse_customize_define(codec);
14686
Kailang Yang274693f2009-12-03 10:07:50 +010014687 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014688 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14689 spec->cdefine.platform_type == 1)
14690 alc_codec_rename(codec, "ALC271X");
14691 else
14692 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014693 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014694 } else
14695 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014696
Kailang Yangf6a92242007-12-13 16:52:54 +010014697 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14698 alc269_models,
14699 alc269_cfg_tbl);
14700
14701 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014702 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14703 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014704 board_config = ALC269_AUTO;
14705 }
14706
Takashi Iwaiff818c22010-04-12 08:59:25 +020014707 if (board_config == ALC269_AUTO)
14708 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14709
Kailang Yangf6a92242007-12-13 16:52:54 +010014710 if (board_config == ALC269_AUTO) {
14711 /* automatic parse from the BIOS config */
14712 err = alc269_parse_auto_config(codec);
14713 if (err < 0) {
14714 alc_free(codec);
14715 return err;
14716 } else if (!err) {
14717 printk(KERN_INFO
14718 "hda_codec: Cannot set up configuration "
14719 "from BIOS. Using base mode...\n");
14720 board_config = ALC269_BASIC;
14721 }
14722 }
14723
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014724 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014725 err = snd_hda_attach_beep_device(codec, 0x1);
14726 if (err < 0) {
14727 alc_free(codec);
14728 return err;
14729 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014730 }
14731
Kailang Yangf6a92242007-12-13 16:52:54 +010014732 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014733 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014734
Kailang Yang84898e82010-02-04 14:16:14 +010014735 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014736 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14737 * fix the sample rate of analog I/O to 44.1kHz
14738 */
14739 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14740 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014741 } else if (spec->dual_adc_switch) {
14742 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14743 /* switch ADC dynamically */
14744 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014745 } else {
14746 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14747 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14748 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014749 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14750 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14751
Takashi Iwai66946352010-03-29 17:21:45 +020014752 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14753 if (!is_alc269vb) {
14754 spec->adc_nids = alc269_adc_nids;
14755 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14756 spec->capsrc_nids = alc269_capsrc_nids;
14757 } else {
14758 spec->adc_nids = alc269vb_adc_nids;
14759 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14760 spec->capsrc_nids = alc269vb_capsrc_nids;
14761 }
Kailang Yang84898e82010-02-04 14:16:14 +010014762 }
14763
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014764 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014765 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014766 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014767 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014768
Takashi Iwaiff818c22010-04-12 08:59:25 +020014769 if (board_config == ALC269_AUTO)
14770 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14771
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014772 spec->vmaster_nid = 0x02;
14773
Kailang Yangf6a92242007-12-13 16:52:54 +010014774 codec->patch_ops = alc_patch_ops;
14775 if (board_config == ALC269_AUTO)
14776 spec->init_hook = alc269_auto_init;
14777#ifdef CONFIG_SND_HDA_POWER_SAVE
14778 if (!spec->loopback.amplist)
14779 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014780 if (alc269_mic2_for_mute_led(codec))
14781 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014782#endif
14783
14784 return 0;
14785}
14786
14787/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014788 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14789 */
14790
14791/*
14792 * set the path ways for 2 channel output
14793 * need to set the codec line out and mic 1 pin widgets to inputs
14794 */
14795static struct hda_verb alc861_threestack_ch2_init[] = {
14796 /* set pin widget 1Ah (line in) for input */
14797 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014798 /* set pin widget 18h (mic1/2) for input, for mic also enable
14799 * the vref
14800 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014801 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14802
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014803 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14804#if 0
14805 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14806 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14807#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014808 { } /* end */
14809};
14810/*
14811 * 6ch mode
14812 * need to set the codec line out and mic 1 pin widgets to outputs
14813 */
14814static struct hda_verb alc861_threestack_ch6_init[] = {
14815 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14816 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14817 /* set pin widget 18h (mic1) for output (CLFE)*/
14818 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14819
14820 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014821 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014822
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014823 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14824#if 0
14825 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14826 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14827#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014828 { } /* end */
14829};
14830
14831static struct hda_channel_mode alc861_threestack_modes[2] = {
14832 { 2, alc861_threestack_ch2_init },
14833 { 6, alc861_threestack_ch6_init },
14834};
Takashi Iwai22309c32006-08-09 16:57:28 +020014835/* Set mic1 as input and unmute the mixer */
14836static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14837 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14838 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14839 { } /* end */
14840};
14841/* Set mic1 as output and mute mixer */
14842static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14843 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14844 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14845 { } /* end */
14846};
14847
14848static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14849 { 2, alc861_uniwill_m31_ch2_init },
14850 { 4, alc861_uniwill_m31_ch4_init },
14851};
Kailang Yangdf694da2005-12-05 19:42:22 +010014852
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014853/* Set mic1 and line-in as input and unmute the mixer */
14854static struct hda_verb alc861_asus_ch2_init[] = {
14855 /* set pin widget 1Ah (line in) for input */
14856 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014857 /* set pin widget 18h (mic1/2) for input, for mic also enable
14858 * the vref
14859 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014860 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14861
14862 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14863#if 0
14864 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14865 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14866#endif
14867 { } /* end */
14868};
14869/* Set mic1 nad line-in as output and mute mixer */
14870static struct hda_verb alc861_asus_ch6_init[] = {
14871 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14872 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14873 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14874 /* set pin widget 18h (mic1) for output (CLFE)*/
14875 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14876 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14877 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14878 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14879
14880 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14881#if 0
14882 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14883 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14884#endif
14885 { } /* end */
14886};
14887
14888static struct hda_channel_mode alc861_asus_modes[2] = {
14889 { 2, alc861_asus_ch2_init },
14890 { 6, alc861_asus_ch6_init },
14891};
14892
Kailang Yangdf694da2005-12-05 19:42:22 +010014893/* patch-ALC861 */
14894
14895static struct snd_kcontrol_new alc861_base_mixer[] = {
14896 /* output mixer control */
14897 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14898 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14899 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14900 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14901 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14902
14903 /*Input mixer control */
14904 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14905 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14906 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14907 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14908 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14909 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14911 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14912 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14913 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014914
Kailang Yangdf694da2005-12-05 19:42:22 +010014915 { } /* end */
14916};
14917
14918static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14919 /* output mixer control */
14920 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14921 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14922 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14923 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14924 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14925
14926 /* Input mixer control */
14927 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14928 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14929 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14930 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14931 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14932 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14934 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14936 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014937
Kailang Yangdf694da2005-12-05 19:42:22 +010014938 {
14939 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14940 .name = "Channel Mode",
14941 .info = alc_ch_mode_info,
14942 .get = alc_ch_mode_get,
14943 .put = alc_ch_mode_put,
14944 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14945 },
14946 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014947};
14948
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014949static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014950 /* output mixer control */
14951 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14952 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14953 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014954
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014955 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014956};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014957
Takashi Iwai22309c32006-08-09 16:57:28 +020014958static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14959 /* output mixer control */
14960 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14961 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14962 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14963 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14964 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14965
14966 /* Input mixer control */
14967 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14968 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14969 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14970 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14971 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14972 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14974 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14975 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014977
Takashi Iwai22309c32006-08-09 16:57:28 +020014978 {
14979 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14980 .name = "Channel Mode",
14981 .info = alc_ch_mode_info,
14982 .get = alc_ch_mode_get,
14983 .put = alc_ch_mode_put,
14984 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14985 },
14986 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014987};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014988
14989static struct snd_kcontrol_new alc861_asus_mixer[] = {
14990 /* output mixer control */
14991 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14992 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14993 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14994 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14995 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14996
14997 /* Input mixer control */
14998 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14999 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15000 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15001 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15002 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15003 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15005 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15006 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15008
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015009 {
15010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15011 .name = "Channel Mode",
15012 .info = alc_ch_mode_info,
15013 .get = alc_ch_mode_get,
15014 .put = alc_ch_mode_put,
15015 .private_value = ARRAY_SIZE(alc861_asus_modes),
15016 },
15017 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015018};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015019
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015020/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015021static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015022 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15023 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015024 { }
15025};
15026
Kailang Yangdf694da2005-12-05 19:42:22 +010015027/*
15028 * generic initialization of ADC, input mixers and output mixers
15029 */
15030static struct hda_verb alc861_base_init_verbs[] = {
15031 /*
15032 * Unmute ADC0 and set the default input to mic-in
15033 */
15034 /* port-A for surround (rear panel) */
15035 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15036 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15037 /* port-B for mic-in (rear panel) with vref */
15038 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15039 /* port-C for line-in (rear panel) */
15040 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15041 /* port-D for Front */
15042 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15043 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15044 /* port-E for HP out (front panel) */
15045 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15046 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015047 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015048 /* port-F for mic-in (front panel) with vref */
15049 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15050 /* port-G for CLFE (rear panel) */
15051 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15052 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15053 /* port-H for side (rear panel) */
15054 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15055 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15056 /* CD-in */
15057 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15058 /* route front mic to ADC1*/
15059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015061
Kailang Yangdf694da2005-12-05 19:42:22 +010015062 /* Unmute DAC0~3 & spdif out*/
15063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15064 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15065 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15066 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15067 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015068
Kailang Yangdf694da2005-12-05 19:42:22 +010015069 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15070 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15071 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15072 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15073 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015074
Kailang Yangdf694da2005-12-05 19:42:22 +010015075 /* Unmute Stereo Mixer 15 */
15076 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15077 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15078 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015079 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015080
15081 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15082 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15083 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15084 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15085 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15086 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15087 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15088 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015089 /* hp used DAC 3 (Front) */
15090 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015091 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15092
15093 { }
15094};
15095
15096static struct hda_verb alc861_threestack_init_verbs[] = {
15097 /*
15098 * Unmute ADC0 and set the default input to mic-in
15099 */
15100 /* port-A for surround (rear panel) */
15101 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15102 /* port-B for mic-in (rear panel) with vref */
15103 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15104 /* port-C for line-in (rear panel) */
15105 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15106 /* port-D for Front */
15107 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15108 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15109 /* port-E for HP out (front panel) */
15110 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15111 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015112 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015113 /* port-F for mic-in (front panel) with vref */
15114 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15115 /* port-G for CLFE (rear panel) */
15116 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15117 /* port-H for side (rear panel) */
15118 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15119 /* CD-in */
15120 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15121 /* route front mic to ADC1*/
15122 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15123 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15124 /* Unmute DAC0~3 & spdif out*/
15125 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15126 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15127 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15128 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015130
Kailang Yangdf694da2005-12-05 19:42:22 +010015131 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15132 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15133 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15134 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15135 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015136
Kailang Yangdf694da2005-12-05 19:42:22 +010015137 /* Unmute Stereo Mixer 15 */
15138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15139 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15140 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015142
15143 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15145 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15146 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15147 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15149 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15150 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015151 /* hp used DAC 3 (Front) */
15152 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15154 { }
15155};
Takashi Iwai22309c32006-08-09 16:57:28 +020015156
15157static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15158 /*
15159 * Unmute ADC0 and set the default input to mic-in
15160 */
15161 /* port-A for surround (rear panel) */
15162 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15163 /* port-B for mic-in (rear panel) with vref */
15164 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15165 /* port-C for line-in (rear panel) */
15166 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15167 /* port-D for Front */
15168 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15169 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15170 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015171 /* this has to be set to VREF80 */
15172 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015173 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015174 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015175 /* port-F for mic-in (front panel) with vref */
15176 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15177 /* port-G for CLFE (rear panel) */
15178 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15179 /* port-H for side (rear panel) */
15180 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15181 /* CD-in */
15182 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15183 /* route front mic to ADC1*/
15184 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15186 /* Unmute DAC0~3 & spdif out*/
15187 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15188 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15189 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15190 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015192
Takashi Iwai22309c32006-08-09 16:57:28 +020015193 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15194 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15195 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15196 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15197 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015198
Takashi Iwai22309c32006-08-09 16:57:28 +020015199 /* Unmute Stereo Mixer 15 */
15200 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15201 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15202 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015203 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015204
15205 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15206 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15207 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15208 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15209 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15211 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15212 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015213 /* hp used DAC 3 (Front) */
15214 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015215 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15216 { }
15217};
15218
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015219static struct hda_verb alc861_asus_init_verbs[] = {
15220 /*
15221 * Unmute ADC0 and set the default input to mic-in
15222 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223 /* port-A for surround (rear panel)
15224 * according to codec#0 this is the HP jack
15225 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015226 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15227 /* route front PCM to HP */
15228 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15229 /* port-B for mic-in (rear panel) with vref */
15230 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15231 /* port-C for line-in (rear panel) */
15232 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15233 /* port-D for Front */
15234 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15235 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15236 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015237 /* this has to be set to VREF80 */
15238 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015239 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015240 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015241 /* port-F for mic-in (front panel) with vref */
15242 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15243 /* port-G for CLFE (rear panel) */
15244 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15245 /* port-H for side (rear panel) */
15246 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15247 /* CD-in */
15248 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15249 /* route front mic to ADC1*/
15250 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15251 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15252 /* Unmute DAC0~3 & spdif out*/
15253 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15254 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15255 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15256 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15257 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15258 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15259 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15260 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15261 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15262 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015263
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015264 /* Unmute Stereo Mixer 15 */
15265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015268 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015269
15270 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15271 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15272 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15274 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15277 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015278 /* hp used DAC 3 (Front) */
15279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015280 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15281 { }
15282};
15283
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015284/* additional init verbs for ASUS laptops */
15285static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15286 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15287 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15288 { }
15289};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015290
Kailang Yangdf694da2005-12-05 19:42:22 +010015291/*
15292 * generic initialization of ADC, input mixers and output mixers
15293 */
15294static struct hda_verb alc861_auto_init_verbs[] = {
15295 /*
15296 * Unmute ADC0 and set the default input to mic-in
15297 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015298 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015299 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015300
Kailang Yangdf694da2005-12-05 19:42:22 +010015301 /* Unmute DAC0~3 & spdif out*/
15302 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15303 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15304 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15305 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015307
Kailang Yangdf694da2005-12-05 19:42:22 +010015308 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15309 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15310 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15311 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15312 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015313
Kailang Yangdf694da2005-12-05 19:42:22 +010015314 /* Unmute Stereo Mixer 15 */
15315 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15318 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15319
Takashi Iwai1c209302009-07-22 15:17:45 +020015320 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15321 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15322 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15323 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15325 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15326 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15327 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015328
15329 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15330 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015331 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015333 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15334 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015335 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15336 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015337
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015338 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015339
15340 { }
15341};
15342
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015343static struct hda_verb alc861_toshiba_init_verbs[] = {
15344 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015345
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015346 { }
15347};
15348
15349/* toggle speaker-output according to the hp-jack state */
15350static void alc861_toshiba_automute(struct hda_codec *codec)
15351{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015352 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015353
Takashi Iwai47fd8302007-08-10 17:11:07 +020015354 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15355 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15356 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15357 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015358}
15359
15360static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15361 unsigned int res)
15362{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015363 if ((res >> 26) == ALC880_HP_EVENT)
15364 alc861_toshiba_automute(codec);
15365}
15366
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015367/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015368#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15369#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15370#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15371#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15372
15373
15374#define ALC861_DIGOUT_NID 0x07
15375
15376static struct hda_channel_mode alc861_8ch_modes[1] = {
15377 { 8, NULL }
15378};
15379
15380static hda_nid_t alc861_dac_nids[4] = {
15381 /* front, surround, clfe, side */
15382 0x03, 0x06, 0x05, 0x04
15383};
15384
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015385static hda_nid_t alc660_dac_nids[3] = {
15386 /* front, clfe, surround */
15387 0x03, 0x05, 0x06
15388};
15389
Kailang Yangdf694da2005-12-05 19:42:22 +010015390static hda_nid_t alc861_adc_nids[1] = {
15391 /* ADC0-2 */
15392 0x08,
15393};
15394
15395static struct hda_input_mux alc861_capture_source = {
15396 .num_items = 5,
15397 .items = {
15398 { "Mic", 0x0 },
15399 { "Front Mic", 0x3 },
15400 { "Line", 0x1 },
15401 { "CD", 0x4 },
15402 { "Mixer", 0x5 },
15403 },
15404};
15405
Takashi Iwai1c209302009-07-22 15:17:45 +020015406static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15407{
15408 struct alc_spec *spec = codec->spec;
15409 hda_nid_t mix, srcs[5];
15410 int i, j, num;
15411
15412 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15413 return 0;
15414 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15415 if (num < 0)
15416 return 0;
15417 for (i = 0; i < num; i++) {
15418 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015419 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015420 if (type != AC_WID_AUD_OUT)
15421 continue;
15422 for (j = 0; j < spec->multiout.num_dacs; j++)
15423 if (spec->multiout.dac_nids[j] == srcs[i])
15424 break;
15425 if (j >= spec->multiout.num_dacs)
15426 return srcs[i];
15427 }
15428 return 0;
15429}
15430
Kailang Yangdf694da2005-12-05 19:42:22 +010015431/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015432static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015433 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015434{
Takashi Iwai1c209302009-07-22 15:17:45 +020015435 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015436 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015437 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015438
15439 spec->multiout.dac_nids = spec->private_dac_nids;
15440 for (i = 0; i < cfg->line_outs; i++) {
15441 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015442 dac = alc861_look_for_dac(codec, nid);
15443 if (!dac)
15444 continue;
15445 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015446 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015447 return 0;
15448}
15449
Takashi Iwai1c209302009-07-22 15:17:45 +020015450static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15451 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015452{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015453 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015454 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15455}
15456
15457/* add playback controls from the parsed DAC table */
15458static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15459 const struct auto_pin_cfg *cfg)
15460{
15461 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015462 static const char *chname[4] = {
15463 "Front", "Surround", NULL /*CLFE*/, "Side"
15464 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015465 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015466 int i, err;
15467
15468 if (cfg->line_outs == 1) {
15469 const char *pfx = NULL;
15470 if (!cfg->hp_outs)
15471 pfx = "Master";
15472 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15473 pfx = "Speaker";
15474 if (pfx) {
15475 nid = spec->multiout.dac_nids[0];
15476 return alc861_create_out_sw(codec, pfx, nid, 3);
15477 }
15478 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015479
15480 for (i = 0; i < cfg->line_outs; i++) {
15481 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015482 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015483 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015484 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015485 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015486 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015487 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015488 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015489 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015490 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015491 return err;
15492 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015493 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015494 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015495 return err;
15496 }
15497 }
15498 return 0;
15499}
15500
Takashi Iwai1c209302009-07-22 15:17:45 +020015501static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015502{
Takashi Iwai1c209302009-07-22 15:17:45 +020015503 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015504 int err;
15505 hda_nid_t nid;
15506
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015507 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015508 return 0;
15509
15510 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015511 nid = alc861_look_for_dac(codec, pin);
15512 if (nid) {
15513 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15514 if (err < 0)
15515 return err;
15516 spec->multiout.hp_nid = nid;
15517 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015518 }
15519 return 0;
15520}
15521
15522/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015523static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015524 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015525{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015526 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015527}
15528
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015529static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15530 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015531 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015532{
Takashi Iwai1c209302009-07-22 15:17:45 +020015533 hda_nid_t mix, srcs[5];
15534 int i, num;
15535
Jacek Luczak564c5be2008-05-03 18:41:23 +020015536 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15537 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015538 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015539 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015540 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15541 return;
15542 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15543 if (num < 0)
15544 return;
15545 for (i = 0; i < num; i++) {
15546 unsigned int mute;
15547 if (srcs[i] == dac || srcs[i] == 0x15)
15548 mute = AMP_IN_UNMUTE(i);
15549 else
15550 mute = AMP_IN_MUTE(i);
15551 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15552 mute);
15553 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015554}
15555
15556static void alc861_auto_init_multi_out(struct hda_codec *codec)
15557{
15558 struct alc_spec *spec = codec->spec;
15559 int i;
15560
15561 for (i = 0; i < spec->autocfg.line_outs; i++) {
15562 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015563 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015564 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015565 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015566 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015567 }
15568}
15569
15570static void alc861_auto_init_hp_out(struct hda_codec *codec)
15571{
15572 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015573
Takashi Iwai15870f02009-10-05 08:25:13 +020015574 if (spec->autocfg.hp_outs)
15575 alc861_auto_set_output_and_unmute(codec,
15576 spec->autocfg.hp_pins[0],
15577 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015578 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015579 if (spec->autocfg.speaker_outs)
15580 alc861_auto_set_output_and_unmute(codec,
15581 spec->autocfg.speaker_pins[0],
15582 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015583 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015584}
15585
15586static void alc861_auto_init_analog_input(struct hda_codec *codec)
15587{
15588 struct alc_spec *spec = codec->spec;
15589 int i;
15590
15591 for (i = 0; i < AUTO_PIN_LAST; i++) {
15592 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015593 if (nid >= 0x0c && nid <= 0x11)
15594 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015595 }
15596}
15597
15598/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015599/* return 1 if successful, 0 if the proper config is not found,
15600 * or a negative error code
15601 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015602static int alc861_parse_auto_config(struct hda_codec *codec)
15603{
15604 struct alc_spec *spec = codec->spec;
15605 int err;
15606 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15607
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015608 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15609 alc861_ignore);
15610 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015611 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015612 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015613 return 0; /* can't find valid BIOS pin config */
15614
Takashi Iwai1c209302009-07-22 15:17:45 +020015615 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015616 if (err < 0)
15617 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015618 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015619 if (err < 0)
15620 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015621 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015622 if (err < 0)
15623 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015624 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015625 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015626 return err;
15627
15628 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15629
Takashi Iwai757899a2010-07-30 10:48:14 +020015630 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015631
Takashi Iwai603c4012008-07-30 15:01:44 +020015632 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015633 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015634
Takashi Iwaid88897e2008-10-31 15:01:37 +010015635 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015636
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015637 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015638 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015639
15640 spec->adc_nids = alc861_adc_nids;
15641 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015642 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015643
Kailang Yang6227cdc2010-02-25 08:36:52 +010015644 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015645
Kailang Yangdf694da2005-12-05 19:42:22 +010015646 return 1;
15647}
15648
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015649/* additional initialization for auto-configuration model */
15650static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015651{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015652 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015653 alc861_auto_init_multi_out(codec);
15654 alc861_auto_init_hp_out(codec);
15655 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015656 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015657 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015658 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015659}
15660
Takashi Iwaicb53c622007-08-10 17:21:45 +020015661#ifdef CONFIG_SND_HDA_POWER_SAVE
15662static struct hda_amp_list alc861_loopbacks[] = {
15663 { 0x15, HDA_INPUT, 0 },
15664 { 0x15, HDA_INPUT, 1 },
15665 { 0x15, HDA_INPUT, 2 },
15666 { 0x15, HDA_INPUT, 3 },
15667 { } /* end */
15668};
15669#endif
15670
Kailang Yangdf694da2005-12-05 19:42:22 +010015671
15672/*
15673 * configuration and preset
15674 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015675static const char *alc861_models[ALC861_MODEL_LAST] = {
15676 [ALC861_3ST] = "3stack",
15677 [ALC660_3ST] = "3stack-660",
15678 [ALC861_3ST_DIG] = "3stack-dig",
15679 [ALC861_6ST_DIG] = "6stack-dig",
15680 [ALC861_UNIWILL_M31] = "uniwill-m31",
15681 [ALC861_TOSHIBA] = "toshiba",
15682 [ALC861_ASUS] = "asus",
15683 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15684 [ALC861_AUTO] = "auto",
15685};
15686
15687static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015688 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015689 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15690 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15691 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015692 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015693 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015694 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015695 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15696 * Any other models that need this preset?
15697 */
15698 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015699 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15700 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015701 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15702 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15703 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15704 /* FIXME: the below seems conflict */
15705 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15706 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15707 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015708 {}
15709};
15710
15711static struct alc_config_preset alc861_presets[] = {
15712 [ALC861_3ST] = {
15713 .mixers = { alc861_3ST_mixer },
15714 .init_verbs = { alc861_threestack_init_verbs },
15715 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15716 .dac_nids = alc861_dac_nids,
15717 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15718 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015719 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015720 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15721 .adc_nids = alc861_adc_nids,
15722 .input_mux = &alc861_capture_source,
15723 },
15724 [ALC861_3ST_DIG] = {
15725 .mixers = { alc861_base_mixer },
15726 .init_verbs = { alc861_threestack_init_verbs },
15727 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15728 .dac_nids = alc861_dac_nids,
15729 .dig_out_nid = ALC861_DIGOUT_NID,
15730 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15731 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015732 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015733 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15734 .adc_nids = alc861_adc_nids,
15735 .input_mux = &alc861_capture_source,
15736 },
15737 [ALC861_6ST_DIG] = {
15738 .mixers = { alc861_base_mixer },
15739 .init_verbs = { alc861_base_init_verbs },
15740 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15741 .dac_nids = alc861_dac_nids,
15742 .dig_out_nid = ALC861_DIGOUT_NID,
15743 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15744 .channel_mode = alc861_8ch_modes,
15745 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15746 .adc_nids = alc861_adc_nids,
15747 .input_mux = &alc861_capture_source,
15748 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015749 [ALC660_3ST] = {
15750 .mixers = { alc861_3ST_mixer },
15751 .init_verbs = { alc861_threestack_init_verbs },
15752 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15753 .dac_nids = alc660_dac_nids,
15754 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15755 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015756 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015757 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15758 .adc_nids = alc861_adc_nids,
15759 .input_mux = &alc861_capture_source,
15760 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015761 [ALC861_UNIWILL_M31] = {
15762 .mixers = { alc861_uniwill_m31_mixer },
15763 .init_verbs = { alc861_uniwill_m31_init_verbs },
15764 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15765 .dac_nids = alc861_dac_nids,
15766 .dig_out_nid = ALC861_DIGOUT_NID,
15767 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15768 .channel_mode = alc861_uniwill_m31_modes,
15769 .need_dac_fix = 1,
15770 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15771 .adc_nids = alc861_adc_nids,
15772 .input_mux = &alc861_capture_source,
15773 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015774 [ALC861_TOSHIBA] = {
15775 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015776 .init_verbs = { alc861_base_init_verbs,
15777 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015778 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15779 .dac_nids = alc861_dac_nids,
15780 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15781 .channel_mode = alc883_3ST_2ch_modes,
15782 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15783 .adc_nids = alc861_adc_nids,
15784 .input_mux = &alc861_capture_source,
15785 .unsol_event = alc861_toshiba_unsol_event,
15786 .init_hook = alc861_toshiba_automute,
15787 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015788 [ALC861_ASUS] = {
15789 .mixers = { alc861_asus_mixer },
15790 .init_verbs = { alc861_asus_init_verbs },
15791 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15792 .dac_nids = alc861_dac_nids,
15793 .dig_out_nid = ALC861_DIGOUT_NID,
15794 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15795 .channel_mode = alc861_asus_modes,
15796 .need_dac_fix = 1,
15797 .hp_nid = 0x06,
15798 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15799 .adc_nids = alc861_adc_nids,
15800 .input_mux = &alc861_capture_source,
15801 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015802 [ALC861_ASUS_LAPTOP] = {
15803 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15804 .init_verbs = { alc861_asus_init_verbs,
15805 alc861_asus_laptop_init_verbs },
15806 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15807 .dac_nids = alc861_dac_nids,
15808 .dig_out_nid = ALC861_DIGOUT_NID,
15809 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15810 .channel_mode = alc883_3ST_2ch_modes,
15811 .need_dac_fix = 1,
15812 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15813 .adc_nids = alc861_adc_nids,
15814 .input_mux = &alc861_capture_source,
15815 },
15816};
Kailang Yangdf694da2005-12-05 19:42:22 +010015817
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015818/* Pin config fixes */
15819enum {
15820 PINFIX_FSC_AMILO_PI1505,
15821};
15822
15823static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15824 { 0x0b, 0x0221101f }, /* HP */
15825 { 0x0f, 0x90170310 }, /* speaker */
15826 { }
15827};
15828
15829static const struct alc_fixup alc861_fixups[] = {
15830 [PINFIX_FSC_AMILO_PI1505] = {
15831 .pins = alc861_fsc_amilo_pi1505_pinfix
15832 },
15833};
15834
15835static struct snd_pci_quirk alc861_fixup_tbl[] = {
15836 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15837 {}
15838};
Kailang Yangdf694da2005-12-05 19:42:22 +010015839
15840static int patch_alc861(struct hda_codec *codec)
15841{
15842 struct alc_spec *spec;
15843 int board_config;
15844 int err;
15845
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015846 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015847 if (spec == NULL)
15848 return -ENOMEM;
15849
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015850 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015851
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015852 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15853 alc861_models,
15854 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015855
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015856 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015857 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15858 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015859 board_config = ALC861_AUTO;
15860 }
15861
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015862 if (board_config == ALC861_AUTO)
15863 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015864
Kailang Yangdf694da2005-12-05 19:42:22 +010015865 if (board_config == ALC861_AUTO) {
15866 /* automatic parse from the BIOS config */
15867 err = alc861_parse_auto_config(codec);
15868 if (err < 0) {
15869 alc_free(codec);
15870 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015871 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015872 printk(KERN_INFO
15873 "hda_codec: Cannot set up configuration "
15874 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015875 board_config = ALC861_3ST_DIG;
15876 }
15877 }
15878
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015879 err = snd_hda_attach_beep_device(codec, 0x23);
15880 if (err < 0) {
15881 alc_free(codec);
15882 return err;
15883 }
15884
Kailang Yangdf694da2005-12-05 19:42:22 +010015885 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015886 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015887
Kailang Yangdf694da2005-12-05 19:42:22 +010015888 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15889 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15890
Kailang Yangdf694da2005-12-05 19:42:22 +010015891 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15892 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15893
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015894 if (!spec->cap_mixer)
15895 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015896 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15897
Takashi Iwai2134ea42008-01-10 16:53:55 +010015898 spec->vmaster_nid = 0x03;
15899
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015900 if (board_config == ALC861_AUTO)
15901 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15902
Kailang Yangdf694da2005-12-05 19:42:22 +010015903 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015904 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015905 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015906#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015907 spec->power_hook = alc_power_eapd;
15908#endif
15909 }
15910#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015911 if (!spec->loopback.amplist)
15912 spec->loopback.amplist = alc861_loopbacks;
15913#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015914
Kailang Yangdf694da2005-12-05 19:42:22 +010015915 return 0;
15916}
15917
15918/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015919 * ALC861-VD support
15920 *
15921 * Based on ALC882
15922 *
15923 * In addition, an independent DAC
15924 */
15925#define ALC861VD_DIGOUT_NID 0x06
15926
15927static hda_nid_t alc861vd_dac_nids[4] = {
15928 /* front, surr, clfe, side surr */
15929 0x02, 0x03, 0x04, 0x05
15930};
15931
15932/* dac_nids for ALC660vd are in a different order - according to
15933 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015934 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015935 * of ALC660vd codecs, but for now there is only 3stack mixer
15936 * - and it is the same as in 861vd.
15937 * adc_nids in ALC660vd are (is) the same as in 861vd
15938 */
15939static hda_nid_t alc660vd_dac_nids[3] = {
15940 /* front, rear, clfe, rear_surr */
15941 0x02, 0x04, 0x03
15942};
15943
15944static hda_nid_t alc861vd_adc_nids[1] = {
15945 /* ADC0 */
15946 0x09,
15947};
15948
Takashi Iwaie1406342008-02-11 18:32:32 +010015949static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15950
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015951/* input MUX */
15952/* FIXME: should be a matrix-type input source selection */
15953static struct hda_input_mux alc861vd_capture_source = {
15954 .num_items = 4,
15955 .items = {
15956 { "Mic", 0x0 },
15957 { "Front Mic", 0x1 },
15958 { "Line", 0x2 },
15959 { "CD", 0x4 },
15960 },
15961};
15962
Kailang Yang272a5272007-05-14 11:00:38 +020015963static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015964 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015965 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015966 { "Ext Mic", 0x0 },
15967 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015968 },
15969};
15970
Kailang Yangd1a991a2007-08-15 16:21:59 +020015971static struct hda_input_mux alc861vd_hp_capture_source = {
15972 .num_items = 2,
15973 .items = {
15974 { "Front Mic", 0x0 },
15975 { "ATAPI Mic", 0x1 },
15976 },
15977};
15978
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015979/*
15980 * 2ch mode
15981 */
15982static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15983 { 2, NULL }
15984};
15985
15986/*
15987 * 6ch mode
15988 */
15989static struct hda_verb alc861vd_6stack_ch6_init[] = {
15990 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15991 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15992 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15993 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15994 { } /* end */
15995};
15996
15997/*
15998 * 8ch mode
15999 */
16000static struct hda_verb alc861vd_6stack_ch8_init[] = {
16001 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16002 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16003 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16004 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16005 { } /* end */
16006};
16007
16008static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16009 { 6, alc861vd_6stack_ch6_init },
16010 { 8, alc861vd_6stack_ch8_init },
16011};
16012
16013static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16014 {
16015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16016 .name = "Channel Mode",
16017 .info = alc_ch_mode_info,
16018 .get = alc_ch_mode_get,
16019 .put = alc_ch_mode_put,
16020 },
16021 { } /* end */
16022};
16023
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016024/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16025 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16026 */
16027static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16028 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16030
16031 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16032 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16033
16034 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16035 HDA_OUTPUT),
16036 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16037 HDA_OUTPUT),
16038 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16039 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16040
16041 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16042 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16043
16044 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16045
16046 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16049
16050 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16051 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16052 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16053
16054 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16055 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16056
16057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16059
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016060 { } /* end */
16061};
16062
16063static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16064 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16065 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16066
16067 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16068
16069 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16070 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16071 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16072
16073 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16074 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16075 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16076
16077 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16078 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16079
16080 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16081 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16082
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016083 { } /* end */
16084};
16085
Kailang Yangbdd148a2007-05-08 15:19:08 +020016086static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16087 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16088 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16089 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16090
16091 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16092
16093 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16094 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16095 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16096
16097 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16098 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16099 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16100
16101 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16102 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16103
16104 { } /* end */
16105};
16106
Tobin Davisb419f342008-03-07 11:57:51 +010016107/* Pin assignment: Speaker=0x14, HP = 0x15,
16108 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016109 */
16110static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016111 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16112 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016113 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16114 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016115 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16116 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16117 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16118 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16119 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16120 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016121 { } /* end */
16122};
16123
Kailang Yangd1a991a2007-08-15 16:21:59 +020016124/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16125 * Front Mic=0x18, ATAPI Mic = 0x19,
16126 */
16127static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16128 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16129 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16130 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16131 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16134 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16135 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016136
Kailang Yangd1a991a2007-08-15 16:21:59 +020016137 { } /* end */
16138};
16139
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016140/*
16141 * generic initialization of ADC, input mixers and output mixers
16142 */
16143static struct hda_verb alc861vd_volume_init_verbs[] = {
16144 /*
16145 * Unmute ADC0 and set the default input to mic-in
16146 */
16147 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16149
16150 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16151 * the analog-loopback mixer widget
16152 */
16153 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016159
16160 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16163 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016164 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016165
16166 /*
16167 * Set up output mixers (0x02 - 0x05)
16168 */
16169 /* set vol=0 to output mixers */
16170 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16171 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16172 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16173 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16174
16175 /* set up input amps for analog loopback */
16176 /* Amp Indices: DAC = 0, mixer = 1 */
16177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16178 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16180 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16184 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16185
16186 { }
16187};
16188
16189/*
16190 * 3-stack pin configuration:
16191 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16192 */
16193static struct hda_verb alc861vd_3stack_init_verbs[] = {
16194 /*
16195 * Set pin mode and muting
16196 */
16197 /* set front pin widgets 0x14 for output */
16198 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16199 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16200 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16201
16202 /* Mic (rear) pin: input vref at 80% */
16203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16204 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16205 /* Front Mic pin: input vref at 80% */
16206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16208 /* Line In pin: input */
16209 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16210 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16211 /* Line-2 In: Headphone output (output 0 - 0x0c) */
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, 0x00},
16215 /* CD pin widget for input */
16216 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16217
16218 { }
16219};
16220
16221/*
16222 * 6-stack pin configuration:
16223 */
16224static struct hda_verb alc861vd_6stack_init_verbs[] = {
16225 /*
16226 * Set pin mode and muting
16227 */
16228 /* set front pin widgets 0x14 for output */
16229 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16230 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16231 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16232
16233 /* Rear Pin: output 1 (0x0d) */
16234 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16235 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16236 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16237 /* CLFE Pin: output 2 (0x0e) */
16238 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16239 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16240 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16241 /* Side Pin: output 3 (0x0f) */
16242 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16243 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16244 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16245
16246 /* Mic (rear) pin: input vref at 80% */
16247 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16249 /* Front Mic pin: input vref at 80% */
16250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16251 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16252 /* Line In pin: input */
16253 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16254 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16255 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16256 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16257 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16258 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16259 /* CD pin widget for input */
16260 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16261
16262 { }
16263};
16264
Kailang Yangbdd148a2007-05-08 15:19:08 +020016265static struct hda_verb alc861vd_eapd_verbs[] = {
16266 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16267 { }
16268};
16269
Kailang Yangf9423e72008-05-27 12:32:25 +020016270static struct hda_verb alc660vd_eapd_verbs[] = {
16271 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16272 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16273 { }
16274};
16275
Kailang Yangbdd148a2007-05-08 15:19:08 +020016276static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16279 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16280 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016281 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016282 {}
16283};
16284
Kailang Yangbdd148a2007-05-08 15:19:08 +020016285static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16286{
16287 unsigned int present;
16288 unsigned char bits;
16289
Wu Fengguang864f92b2009-11-18 12:38:02 +080016290 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016291 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016292
Takashi Iwai47fd8302007-08-10 17:11:07 +020016293 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16294 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016295}
16296
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016297static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016298{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016299 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016300 spec->autocfg.hp_pins[0] = 0x1b;
16301 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016302}
16303
16304static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16305{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016306 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016307 alc861vd_lenovo_mic_automute(codec);
16308}
16309
16310static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16311 unsigned int res)
16312{
16313 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016314 case ALC880_MIC_EVENT:
16315 alc861vd_lenovo_mic_automute(codec);
16316 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016317 default:
16318 alc_automute_amp_unsol_event(codec, res);
16319 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016320 }
16321}
16322
Kailang Yang272a5272007-05-14 11:00:38 +020016323static struct hda_verb alc861vd_dallas_verbs[] = {
16324 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16325 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16326 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16327 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16328
16329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016337
Kailang Yang272a5272007-05-14 11:00:38 +020016338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16340 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16342 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16343 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16344 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16345 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16346
16347 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16349 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16350 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16351 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16352 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16353 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16354 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16355
16356 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16357 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16358 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16359 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16360
16361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016362 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16364
16365 { } /* end */
16366};
16367
16368/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016369static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016370{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016371 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016372
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016373 spec->autocfg.hp_pins[0] = 0x15;
16374 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016375}
16376
Takashi Iwaicb53c622007-08-10 17:21:45 +020016377#ifdef CONFIG_SND_HDA_POWER_SAVE
16378#define alc861vd_loopbacks alc880_loopbacks
16379#endif
16380
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016381/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016382#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16383#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16384#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16385#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16386
16387/*
16388 * configuration and preset
16389 */
16390static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16391 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016392 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016393 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016394 [ALC861VD_3ST] = "3stack",
16395 [ALC861VD_3ST_DIG] = "3stack-digout",
16396 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016397 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016398 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016399 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016400 [ALC861VD_AUTO] = "auto",
16401};
16402
16403static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016404 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16405 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016406 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016407 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016408 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016409 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016410 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016411 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016412 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016413 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016414 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016415 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016416 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016417 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016418 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016419 {}
16420};
16421
16422static struct alc_config_preset alc861vd_presets[] = {
16423 [ALC660VD_3ST] = {
16424 .mixers = { alc861vd_3st_mixer },
16425 .init_verbs = { alc861vd_volume_init_verbs,
16426 alc861vd_3stack_init_verbs },
16427 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16428 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016429 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16430 .channel_mode = alc861vd_3stack_2ch_modes,
16431 .input_mux = &alc861vd_capture_source,
16432 },
Mike Crash6963f842007-06-25 12:12:51 +020016433 [ALC660VD_3ST_DIG] = {
16434 .mixers = { alc861vd_3st_mixer },
16435 .init_verbs = { alc861vd_volume_init_verbs,
16436 alc861vd_3stack_init_verbs },
16437 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16438 .dac_nids = alc660vd_dac_nids,
16439 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016440 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16441 .channel_mode = alc861vd_3stack_2ch_modes,
16442 .input_mux = &alc861vd_capture_source,
16443 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016444 [ALC861VD_3ST] = {
16445 .mixers = { alc861vd_3st_mixer },
16446 .init_verbs = { alc861vd_volume_init_verbs,
16447 alc861vd_3stack_init_verbs },
16448 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16449 .dac_nids = alc861vd_dac_nids,
16450 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16451 .channel_mode = alc861vd_3stack_2ch_modes,
16452 .input_mux = &alc861vd_capture_source,
16453 },
16454 [ALC861VD_3ST_DIG] = {
16455 .mixers = { alc861vd_3st_mixer },
16456 .init_verbs = { alc861vd_volume_init_verbs,
16457 alc861vd_3stack_init_verbs },
16458 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16459 .dac_nids = alc861vd_dac_nids,
16460 .dig_out_nid = ALC861VD_DIGOUT_NID,
16461 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16462 .channel_mode = alc861vd_3stack_2ch_modes,
16463 .input_mux = &alc861vd_capture_source,
16464 },
16465 [ALC861VD_6ST_DIG] = {
16466 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16467 .init_verbs = { alc861vd_volume_init_verbs,
16468 alc861vd_6stack_init_verbs },
16469 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16470 .dac_nids = alc861vd_dac_nids,
16471 .dig_out_nid = ALC861VD_DIGOUT_NID,
16472 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16473 .channel_mode = alc861vd_6stack_modes,
16474 .input_mux = &alc861vd_capture_source,
16475 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016476 [ALC861VD_LENOVO] = {
16477 .mixers = { alc861vd_lenovo_mixer },
16478 .init_verbs = { alc861vd_volume_init_verbs,
16479 alc861vd_3stack_init_verbs,
16480 alc861vd_eapd_verbs,
16481 alc861vd_lenovo_unsol_verbs },
16482 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16483 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016484 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16485 .channel_mode = alc861vd_3stack_2ch_modes,
16486 .input_mux = &alc861vd_capture_source,
16487 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016488 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016489 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016490 },
Kailang Yang272a5272007-05-14 11:00:38 +020016491 [ALC861VD_DALLAS] = {
16492 .mixers = { alc861vd_dallas_mixer },
16493 .init_verbs = { alc861vd_dallas_verbs },
16494 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16495 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016496 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16497 .channel_mode = alc861vd_3stack_2ch_modes,
16498 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016499 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016500 .setup = alc861vd_dallas_setup,
16501 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016502 },
16503 [ALC861VD_HP] = {
16504 .mixers = { alc861vd_hp_mixer },
16505 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16506 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16507 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016508 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016509 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16510 .channel_mode = alc861vd_3stack_2ch_modes,
16511 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016513 .setup = alc861vd_dallas_setup,
16514 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016515 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016516 [ALC660VD_ASUS_V1S] = {
16517 .mixers = { alc861vd_lenovo_mixer },
16518 .init_verbs = { alc861vd_volume_init_verbs,
16519 alc861vd_3stack_init_verbs,
16520 alc861vd_eapd_verbs,
16521 alc861vd_lenovo_unsol_verbs },
16522 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16523 .dac_nids = alc660vd_dac_nids,
16524 .dig_out_nid = ALC861VD_DIGOUT_NID,
16525 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16526 .channel_mode = alc861vd_3stack_2ch_modes,
16527 .input_mux = &alc861vd_capture_source,
16528 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016529 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016530 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016531 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016532};
16533
16534/*
16535 * BIOS auto configuration
16536 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016537static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16538 const struct auto_pin_cfg *cfg)
16539{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016540 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016541}
16542
16543
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016544static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16545 hda_nid_t nid, int pin_type, int dac_idx)
16546{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016547 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016548}
16549
16550static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16551{
16552 struct alc_spec *spec = codec->spec;
16553 int i;
16554
16555 for (i = 0; i <= HDA_SIDE; i++) {
16556 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016557 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016558 if (nid)
16559 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016560 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016561 }
16562}
16563
16564
16565static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16566{
16567 struct alc_spec *spec = codec->spec;
16568 hda_nid_t pin;
16569
16570 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016571 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016572 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016573 pin = spec->autocfg.speaker_pins[0];
16574 if (pin)
16575 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016576}
16577
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016578#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16579
16580static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16581{
16582 struct alc_spec *spec = codec->spec;
16583 int i;
16584
16585 for (i = 0; i < AUTO_PIN_LAST; i++) {
16586 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016587 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016588 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016589 if (nid != ALC861VD_PIN_CD_NID &&
16590 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016591 snd_hda_codec_write(codec, nid, 0,
16592 AC_VERB_SET_AMP_GAIN_MUTE,
16593 AMP_OUT_MUTE);
16594 }
16595 }
16596}
16597
Takashi Iwaif511b012008-08-15 16:46:42 +020016598#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16599
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016600#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16601#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16602
16603/* add playback controls from the parsed DAC table */
16604/* Based on ALC880 version. But ALC861VD has separate,
16605 * different NIDs for mute/unmute switch and volume control */
16606static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16607 const struct auto_pin_cfg *cfg)
16608{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016609 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16610 hda_nid_t nid_v, nid_s;
16611 int i, err;
16612
16613 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016614 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016615 continue;
16616 nid_v = alc861vd_idx_to_mixer_vol(
16617 alc880_dac_to_idx(
16618 spec->multiout.dac_nids[i]));
16619 nid_s = alc861vd_idx_to_mixer_switch(
16620 alc880_dac_to_idx(
16621 spec->multiout.dac_nids[i]));
16622
16623 if (i == 2) {
16624 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016625 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16626 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016627 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16628 HDA_OUTPUT));
16629 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016630 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016631 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16632 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016633 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16634 HDA_OUTPUT));
16635 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016636 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016637 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16638 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016639 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16640 HDA_INPUT));
16641 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016642 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016643 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16644 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016645 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16646 HDA_INPUT));
16647 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016648 return err;
16649 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016650 const char *pfx;
16651 if (cfg->line_outs == 1 &&
16652 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16653 if (!cfg->hp_pins)
16654 pfx = "Speaker";
16655 else
16656 pfx = "PCM";
16657 } else
16658 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016659 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016660 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16661 HDA_OUTPUT));
16662 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016663 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016664 if (cfg->line_outs == 1 &&
16665 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16666 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016667 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016668 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016669 HDA_INPUT));
16670 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016671 return err;
16672 }
16673 }
16674 return 0;
16675}
16676
16677/* add playback controls for speaker and HP outputs */
16678/* Based on ALC880 version. But ALC861VD has separate,
16679 * different NIDs for mute/unmute switch and volume control */
16680static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16681 hda_nid_t pin, const char *pfx)
16682{
16683 hda_nid_t nid_v, nid_s;
16684 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016685
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016686 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016687 return 0;
16688
16689 if (alc880_is_fixed_pin(pin)) {
16690 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16691 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016692 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016693 spec->multiout.hp_nid = nid_v;
16694 else
16695 spec->multiout.extra_out_nid[0] = nid_v;
16696 /* control HP volume/switch on the output mixer amp */
16697 nid_v = alc861vd_idx_to_mixer_vol(
16698 alc880_fixed_pin_idx(pin));
16699 nid_s = alc861vd_idx_to_mixer_switch(
16700 alc880_fixed_pin_idx(pin));
16701
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016702 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016703 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16704 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016705 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016706 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016707 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16708 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016709 return err;
16710 } else if (alc880_is_multi_pin(pin)) {
16711 /* set manual connection */
16712 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016713 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016714 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16715 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016716 return err;
16717 }
16718 return 0;
16719}
16720
16721/* parse the BIOS configuration and set up the alc_spec
16722 * return 1 if successful, 0 if the proper config is not found,
16723 * or a negative error code
16724 * Based on ALC880 version - had to change it to override
16725 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16726static int alc861vd_parse_auto_config(struct hda_codec *codec)
16727{
16728 struct alc_spec *spec = codec->spec;
16729 int err;
16730 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16731
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016732 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16733 alc861vd_ignore);
16734 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016735 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016736 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016737 return 0; /* can't find valid BIOS pin config */
16738
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016739 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16740 if (err < 0)
16741 return err;
16742 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16743 if (err < 0)
16744 return err;
16745 err = alc861vd_auto_create_extra_out(spec,
16746 spec->autocfg.speaker_pins[0],
16747 "Speaker");
16748 if (err < 0)
16749 return err;
16750 err = alc861vd_auto_create_extra_out(spec,
16751 spec->autocfg.hp_pins[0],
16752 "Headphone");
16753 if (err < 0)
16754 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016755 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016756 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016757 return err;
16758
16759 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16760
Takashi Iwai757899a2010-07-30 10:48:14 +020016761 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016762
Takashi Iwai603c4012008-07-30 15:01:44 +020016763 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016764 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016765
Takashi Iwaid88897e2008-10-31 15:01:37 +010016766 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016767
16768 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016769 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016770
Takashi Iwai776e1842007-08-29 15:07:11 +020016771 err = alc_auto_add_mic_boost(codec);
16772 if (err < 0)
16773 return err;
16774
Kailang Yang6227cdc2010-02-25 08:36:52 +010016775 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016776
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016777 return 1;
16778}
16779
16780/* additional initialization for auto-configuration model */
16781static void alc861vd_auto_init(struct hda_codec *codec)
16782{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016783 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016784 alc861vd_auto_init_multi_out(codec);
16785 alc861vd_auto_init_hp_out(codec);
16786 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016787 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016788 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016789 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016790 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016791}
16792
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016793enum {
16794 ALC660VD_FIX_ASUS_GPIO1
16795};
16796
16797/* reset GPIO1 */
16798static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16799 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16800 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16801 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16802 { }
16803};
16804
16805static const struct alc_fixup alc861vd_fixups[] = {
16806 [ALC660VD_FIX_ASUS_GPIO1] = {
16807 .verbs = alc660vd_fix_asus_gpio1_verbs,
16808 },
16809};
16810
16811static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16812 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16813 {}
16814};
16815
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016816static int patch_alc861vd(struct hda_codec *codec)
16817{
16818 struct alc_spec *spec;
16819 int err, board_config;
16820
16821 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16822 if (spec == NULL)
16823 return -ENOMEM;
16824
16825 codec->spec = spec;
16826
16827 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16828 alc861vd_models,
16829 alc861vd_cfg_tbl);
16830
16831 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016832 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16833 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016834 board_config = ALC861VD_AUTO;
16835 }
16836
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016837 if (board_config == ALC861VD_AUTO)
16838 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016839
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016840 if (board_config == ALC861VD_AUTO) {
16841 /* automatic parse from the BIOS config */
16842 err = alc861vd_parse_auto_config(codec);
16843 if (err < 0) {
16844 alc_free(codec);
16845 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016846 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016847 printk(KERN_INFO
16848 "hda_codec: Cannot set up configuration "
16849 "from BIOS. Using base mode...\n");
16850 board_config = ALC861VD_3ST;
16851 }
16852 }
16853
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016854 err = snd_hda_attach_beep_device(codec, 0x23);
16855 if (err < 0) {
16856 alc_free(codec);
16857 return err;
16858 }
16859
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016860 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016861 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016862
Kailang Yang2f893282008-05-27 12:14:47 +020016863 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016864 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016865 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016866 }
16867
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016868 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16869 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16870
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016871 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16872 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16873
Takashi Iwaidd704692009-08-11 08:45:11 +020016874 if (!spec->adc_nids) {
16875 spec->adc_nids = alc861vd_adc_nids;
16876 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16877 }
16878 if (!spec->capsrc_nids)
16879 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016880
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016881 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016882 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016883
Takashi Iwai2134ea42008-01-10 16:53:55 +010016884 spec->vmaster_nid = 0x02;
16885
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016886 if (board_config == ALC861VD_AUTO)
16887 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16888
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016889 codec->patch_ops = alc_patch_ops;
16890
16891 if (board_config == ALC861VD_AUTO)
16892 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016893#ifdef CONFIG_SND_HDA_POWER_SAVE
16894 if (!spec->loopback.amplist)
16895 spec->loopback.amplist = alc861vd_loopbacks;
16896#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016897
16898 return 0;
16899}
16900
16901/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016902 * ALC662 support
16903 *
16904 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16905 * configuration. Each pin widget can choose any input DACs and a mixer.
16906 * Each ADC is connected from a mixer of all inputs. This makes possible
16907 * 6-channel independent captures.
16908 *
16909 * In addition, an independent DAC for the multi-playback (not used in this
16910 * driver yet).
16911 */
16912#define ALC662_DIGOUT_NID 0x06
16913#define ALC662_DIGIN_NID 0x0a
16914
16915static hda_nid_t alc662_dac_nids[4] = {
16916 /* front, rear, clfe, rear_surr */
16917 0x02, 0x03, 0x04
16918};
16919
Kailang Yang622e84c2009-04-21 07:39:04 +020016920static hda_nid_t alc272_dac_nids[2] = {
16921 0x02, 0x03
16922};
16923
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016924static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016925 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016926 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016927};
Takashi Iwaie1406342008-02-11 18:32:32 +010016928
Kailang Yang622e84c2009-04-21 07:39:04 +020016929static hda_nid_t alc272_adc_nids[1] = {
16930 /* ADC1-2 */
16931 0x08,
16932};
16933
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016934static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016935static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16936
Takashi Iwaie1406342008-02-11 18:32:32 +010016937
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016938/* input MUX */
16939/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016940static struct hda_input_mux alc662_capture_source = {
16941 .num_items = 4,
16942 .items = {
16943 { "Mic", 0x0 },
16944 { "Front Mic", 0x1 },
16945 { "Line", 0x2 },
16946 { "CD", 0x4 },
16947 },
16948};
16949
16950static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16951 .num_items = 2,
16952 .items = {
16953 { "Mic", 0x1 },
16954 { "Line", 0x2 },
16955 },
16956};
Kailang Yang291702f2007-10-16 14:28:03 +020016957
Kailang Yang6dda9f42008-05-27 12:05:31 +020016958static struct hda_input_mux alc663_capture_source = {
16959 .num_items = 3,
16960 .items = {
16961 { "Mic", 0x0 },
16962 { "Front Mic", 0x1 },
16963 { "Line", 0x2 },
16964 },
16965};
16966
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016967#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016968static struct hda_input_mux alc272_nc10_capture_source = {
16969 .num_items = 16,
16970 .items = {
16971 { "Autoselect Mic", 0x0 },
16972 { "Internal Mic", 0x1 },
16973 { "In-0x02", 0x2 },
16974 { "In-0x03", 0x3 },
16975 { "In-0x04", 0x4 },
16976 { "In-0x05", 0x5 },
16977 { "In-0x06", 0x6 },
16978 { "In-0x07", 0x7 },
16979 { "In-0x08", 0x8 },
16980 { "In-0x09", 0x9 },
16981 { "In-0x0a", 0x0a },
16982 { "In-0x0b", 0x0b },
16983 { "In-0x0c", 0x0c },
16984 { "In-0x0d", 0x0d },
16985 { "In-0x0e", 0x0e },
16986 { "In-0x0f", 0x0f },
16987 },
16988};
16989#endif
16990
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016991/*
16992 * 2ch mode
16993 */
16994static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16995 { 2, NULL }
16996};
16997
16998/*
16999 * 2ch mode
17000 */
17001static struct hda_verb alc662_3ST_ch2_init[] = {
17002 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17003 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17004 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17005 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17006 { } /* end */
17007};
17008
17009/*
17010 * 6ch mode
17011 */
17012static struct hda_verb alc662_3ST_ch6_init[] = {
17013 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17014 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17015 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17016 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17017 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17018 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17019 { } /* end */
17020};
17021
17022static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17023 { 2, alc662_3ST_ch2_init },
17024 { 6, alc662_3ST_ch6_init },
17025};
17026
17027/*
17028 * 2ch mode
17029 */
17030static struct hda_verb alc662_sixstack_ch6_init[] = {
17031 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17032 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17033 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17034 { } /* end */
17035};
17036
17037/*
17038 * 6ch mode
17039 */
17040static struct hda_verb alc662_sixstack_ch8_init[] = {
17041 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17042 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17043 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17044 { } /* end */
17045};
17046
17047static struct hda_channel_mode alc662_5stack_modes[2] = {
17048 { 2, alc662_sixstack_ch6_init },
17049 { 6, alc662_sixstack_ch8_init },
17050};
17051
17052/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17053 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17054 */
17055
17056static struct snd_kcontrol_new alc662_base_mixer[] = {
17057 /* output mixer control */
17058 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017059 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017060 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017061 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017062 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17063 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017064 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17065 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017066 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17067
17068 /*Input mixer control */
17069 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17070 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17071 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17072 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17073 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17074 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17075 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17076 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017077 { } /* end */
17078};
17079
17080static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17081 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017082 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17084 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17085 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17086 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17087 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17089 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17090 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17091 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017092 { } /* end */
17093};
17094
17095static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17096 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017097 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017098 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017099 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017100 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17101 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017102 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17103 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17105 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17106 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17107 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17108 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17109 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17110 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017113 { } /* end */
17114};
17115
17116static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17117 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17118 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017119 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17120 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017121 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17122 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17123 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17125 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017126 { } /* end */
17127};
17128
Kailang Yang291702f2007-10-16 14:28:03 +020017129static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017130 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17131 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017132
17133 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17134 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17135 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17136
17137 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17138 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17139 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17140 { } /* end */
17141};
17142
Kailang Yang8c427222008-01-10 13:03:59 +010017143static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017144 ALC262_HIPPO_MASTER_SWITCH,
17145 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017146 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17148 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017149 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17150 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17151 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17152 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17153 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17154 { } /* end */
17155};
17156
Kailang Yangf1d4e282008-08-26 14:03:29 +020017157static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17158 .ops = &snd_hda_bind_vol,
17159 .values = {
17160 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17161 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17162 0
17163 },
17164};
17165
17166static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17167 .ops = &snd_hda_bind_sw,
17168 .values = {
17169 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17170 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17171 0
17172 },
17173};
17174
Kailang Yang6dda9f42008-05-27 12:05:31 +020017175static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017176 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17177 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17178 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17180 { } /* end */
17181};
17182
17183static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17184 .ops = &snd_hda_bind_sw,
17185 .values = {
17186 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17187 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17188 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17189 0
17190 },
17191};
17192
17193static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17194 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17195 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17196 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17198 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17199 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17200
17201 { } /* end */
17202};
17203
17204static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17205 .ops = &snd_hda_bind_sw,
17206 .values = {
17207 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17208 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17209 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17210 0
17211 },
17212};
17213
17214static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17215 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17216 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17218 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17219 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17220 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17221 { } /* end */
17222};
17223
17224static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017225 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17226 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017227 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17229 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17230 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17231 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17232 { } /* end */
17233};
17234
17235static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17236 .ops = &snd_hda_bind_vol,
17237 .values = {
17238 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17239 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17240 0
17241 },
17242};
17243
17244static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17245 .ops = &snd_hda_bind_sw,
17246 .values = {
17247 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17248 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17249 0
17250 },
17251};
17252
17253static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17254 HDA_BIND_VOL("Master Playback Volume",
17255 &alc663_asus_two_bind_master_vol),
17256 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17257 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017258 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17260 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017261 { } /* end */
17262};
17263
17264static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17265 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17266 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17267 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17269 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17270 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017271 { } /* end */
17272};
17273
17274static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17275 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17276 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17277 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17278 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17280
17281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17283 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17284 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17285 { } /* end */
17286};
17287
17288static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17289 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17290 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17292
17293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17295 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17296 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17297 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17298 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17299 { } /* end */
17300};
17301
Kailang Yangebb83ee2009-12-17 12:23:00 +010017302static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17303 .ops = &snd_hda_bind_sw,
17304 .values = {
17305 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17306 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17307 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17308 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17309 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17310 0
17311 },
17312};
17313
17314static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17315 .ops = &snd_hda_bind_sw,
17316 .values = {
17317 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17318 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17319 0
17320 },
17321};
17322
17323static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17324 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17325 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17326 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17327 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17328 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17329 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17330 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17333 { } /* end */
17334};
17335
17336static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17337 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17338 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17339 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17340 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17341 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17344 { } /* end */
17345};
17346
17347
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017348static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17349 {
17350 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17351 .name = "Channel Mode",
17352 .info = alc_ch_mode_info,
17353 .get = alc_ch_mode_get,
17354 .put = alc_ch_mode_put,
17355 },
17356 { } /* end */
17357};
17358
17359static struct hda_verb alc662_init_verbs[] = {
17360 /* ADC: mute amp left and right */
17361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17362 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017363
Kailang Yangb60dd392007-09-20 12:50:29 +020017364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17365 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17366 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17369 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017370
17371 /* Front Pin: output 0 (0x0c) */
17372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17374
17375 /* Rear Pin: output 1 (0x0d) */
17376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17378
17379 /* CLFE Pin: output 2 (0x0e) */
17380 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17381 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17382
17383 /* Mic (rear) pin: input vref at 80% */
17384 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17386 /* Front Mic pin: input vref at 80% */
17387 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17388 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17389 /* Line In pin: input */
17390 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17392 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17393 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17394 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17395 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17396 /* CD pin widget for input */
17397 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17398
17399 /* FIXME: use matrix-type input source selection */
17400 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17401 /* Input mixer */
17402 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017403 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017404
17405 /* always trun on EAPD */
17406 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17407 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17408
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017409 { }
17410};
17411
Kailang Yangcec27c82010-02-04 14:18:18 +010017412static struct hda_verb alc663_init_verbs[] = {
17413 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17414 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17415 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17416 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17418 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17419 { }
17420};
17421
17422static struct hda_verb alc272_init_verbs[] = {
17423 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17424 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17425 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17426 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17427 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17428 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17429 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17430 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17431 { }
17432};
17433
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017434static struct hda_verb alc662_sue_init_verbs[] = {
17435 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17436 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017437 {}
17438};
17439
17440static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17441 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17442 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17443 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017444};
17445
Kailang Yang8c427222008-01-10 13:03:59 +010017446/* Set Unsolicited Event*/
17447static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17449 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17450 {}
17451};
17452
Kailang Yang6dda9f42008-05-27 12:05:31 +020017453static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17455 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017456 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17457 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017458 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017461 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17462 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17463 {}
17464};
17465
Kailang Yangf1d4e282008-08-26 14:03:29 +020017466static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17467 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17468 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17469 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17472 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17473 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17474 {}
17475};
17476
17477static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17478 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17479 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17480 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17481 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17484 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17485 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17486 {}
17487};
17488
17489static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17490 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17492 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17493 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17495 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17496 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17497 {}
17498};
17499
17500static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17501 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17502 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17503 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17504 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17505 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17507 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17510 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17511 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17512 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17513 {}
17514};
17515
17516static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17517 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17518 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17519 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17520 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17523 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17524 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17525 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17526 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17527 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17528 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17529 {}
17530};
17531
Kailang Yang6dda9f42008-05-27 12:05:31 +020017532static struct hda_verb alc663_g71v_init_verbs[] = {
17533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17534 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17535 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17536
17537 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17538 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17539 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17540
17541 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17542 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17543 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17544 {}
17545};
17546
17547static struct hda_verb alc663_g50v_init_verbs[] = {
17548 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17549 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17550 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17551
17552 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17553 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17554 {}
17555};
17556
Kailang Yangf1d4e282008-08-26 14:03:29 +020017557static struct hda_verb alc662_ecs_init_verbs[] = {
17558 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17559 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17560 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17561 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17562 {}
17563};
17564
Kailang Yang622e84c2009-04-21 07:39:04 +020017565static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17566 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17567 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17569 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17570 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17571 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17572 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17573 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17574 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17576 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17577 {}
17578};
17579
17580static struct hda_verb alc272_dell_init_verbs[] = {
17581 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17585 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17586 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17587 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17588 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17590 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17591 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17592 {}
17593};
17594
Kailang Yangebb83ee2009-12-17 12:23:00 +010017595static struct hda_verb alc663_mode7_init_verbs[] = {
17596 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17597 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17598 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17599 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17600 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17601 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17602 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17603 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17604 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17605 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17608 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17609 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17610 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17611 {}
17612};
17613
17614static struct hda_verb alc663_mode8_init_verbs[] = {
17615 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17617 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17618 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17619 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17620 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17621 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17622 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17623 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17624 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17625 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17628 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17629 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17630 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17631 {}
17632};
17633
Kailang Yangf1d4e282008-08-26 14:03:29 +020017634static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17635 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17636 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17637 { } /* end */
17638};
17639
Kailang Yang622e84c2009-04-21 07:39:04 +020017640static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17641 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17642 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17643 { } /* end */
17644};
17645
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017646static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17647{
17648 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017649 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017650
Wu Fengguang864f92b2009-11-18 12:38:02 +080017651 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017652 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017653
Takashi Iwai47fd8302007-08-10 17:11:07 +020017654 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17655 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017656}
17657
17658static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17659{
17660 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017661 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017662
Wu Fengguang864f92b2009-11-18 12:38:02 +080017663 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017664 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017665
Takashi Iwai47fd8302007-08-10 17:11:07 +020017666 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17667 HDA_AMP_MUTE, bits);
17668 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17669 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670}
17671
17672static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17673 unsigned int res)
17674{
17675 if ((res >> 26) == ALC880_HP_EVENT)
17676 alc662_lenovo_101e_all_automute(codec);
17677 if ((res >> 26) == ALC880_FRONT_EVENT)
17678 alc662_lenovo_101e_ispeaker_automute(codec);
17679}
17680
Kailang Yang291702f2007-10-16 14:28:03 +020017681/* unsolicited event for HP jack sensing */
17682static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17683 unsigned int res)
17684{
Kailang Yang291702f2007-10-16 14:28:03 +020017685 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017686 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017687 else
17688 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017689}
17690
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017691static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017692{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017693 struct alc_spec *spec = codec->spec;
17694
17695 alc262_hippo1_setup(codec);
17696 spec->ext_mic.pin = 0x18;
17697 spec->ext_mic.mux_idx = 0;
17698 spec->int_mic.pin = 0x19;
17699 spec->int_mic.mux_idx = 1;
17700 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017701}
17702
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017703static void alc662_eeepc_inithook(struct hda_codec *codec)
17704{
17705 alc262_hippo_automute(codec);
17706 alc_mic_automute(codec);
17707}
17708
17709static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017710{
Takashi Iwai42171c12009-05-08 14:11:43 +020017711 struct alc_spec *spec = codec->spec;
17712
17713 spec->autocfg.hp_pins[0] = 0x14;
17714 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017715}
17716
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017717#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17718
Kailang Yang6dda9f42008-05-27 12:05:31 +020017719static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17720{
17721 unsigned int present;
17722 unsigned char bits;
17723
Wu Fengguang864f92b2009-11-18 12:38:02 +080017724 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017725 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017726 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017727 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017728 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017729 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017730}
17731
17732static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17733{
17734 unsigned int present;
17735 unsigned char bits;
17736
Wu Fengguang864f92b2009-11-18 12:38:02 +080017737 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017738 bits = present ? HDA_AMP_MUTE : 0;
17739 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017740 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017741 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017742 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017743 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017744 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017745 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017746 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017747}
17748
17749static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17750{
17751 unsigned int present;
17752 unsigned char bits;
17753
Wu Fengguang864f92b2009-11-18 12:38:02 +080017754 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017755 bits = present ? HDA_AMP_MUTE : 0;
17756 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017757 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017758 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017759 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017760 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017761 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017762 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017763 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017764}
17765
17766static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17767{
17768 unsigned int present;
17769 unsigned char bits;
17770
Wu Fengguang864f92b2009-11-18 12:38:02 +080017771 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017772 bits = present ? 0 : PIN_OUT;
17773 snd_hda_codec_write(codec, 0x14, 0,
17774 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17775}
17776
17777static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17778{
17779 unsigned int present1, present2;
17780
Wu Fengguang864f92b2009-11-18 12:38:02 +080017781 present1 = snd_hda_jack_detect(codec, 0x21);
17782 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017783
17784 if (present1 || present2) {
17785 snd_hda_codec_write_cache(codec, 0x14, 0,
17786 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17787 } else {
17788 snd_hda_codec_write_cache(codec, 0x14, 0,
17789 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17790 }
17791}
17792
17793static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17794{
17795 unsigned int present1, present2;
17796
Wu Fengguang864f92b2009-11-18 12:38:02 +080017797 present1 = snd_hda_jack_detect(codec, 0x1b);
17798 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017799
17800 if (present1 || present2) {
17801 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017802 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017803 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017804 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017805 } else {
17806 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017807 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017808 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017809 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017810 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017811}
17812
Kailang Yangebb83ee2009-12-17 12:23:00 +010017813static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17814{
17815 unsigned int present1, present2;
17816
17817 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17818 AC_VERB_GET_PIN_SENSE, 0)
17819 & AC_PINSENSE_PRESENCE;
17820 present2 = snd_hda_codec_read(codec, 0x21, 0,
17821 AC_VERB_GET_PIN_SENSE, 0)
17822 & AC_PINSENSE_PRESENCE;
17823
17824 if (present1 || present2) {
17825 snd_hda_codec_write_cache(codec, 0x14, 0,
17826 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17827 snd_hda_codec_write_cache(codec, 0x17, 0,
17828 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17829 } else {
17830 snd_hda_codec_write_cache(codec, 0x14, 0,
17831 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17832 snd_hda_codec_write_cache(codec, 0x17, 0,
17833 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17834 }
17835}
17836
17837static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17838{
17839 unsigned int present1, present2;
17840
17841 present1 = snd_hda_codec_read(codec, 0x21, 0,
17842 AC_VERB_GET_PIN_SENSE, 0)
17843 & AC_PINSENSE_PRESENCE;
17844 present2 = snd_hda_codec_read(codec, 0x15, 0,
17845 AC_VERB_GET_PIN_SENSE, 0)
17846 & AC_PINSENSE_PRESENCE;
17847
17848 if (present1 || present2) {
17849 snd_hda_codec_write_cache(codec, 0x14, 0,
17850 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17851 snd_hda_codec_write_cache(codec, 0x17, 0,
17852 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17853 } else {
17854 snd_hda_codec_write_cache(codec, 0x14, 0,
17855 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17856 snd_hda_codec_write_cache(codec, 0x17, 0,
17857 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17858 }
17859}
17860
Kailang Yang6dda9f42008-05-27 12:05:31 +020017861static void alc663_m51va_unsol_event(struct hda_codec *codec,
17862 unsigned int res)
17863{
17864 switch (res >> 26) {
17865 case ALC880_HP_EVENT:
17866 alc663_m51va_speaker_automute(codec);
17867 break;
17868 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017869 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017870 break;
17871 }
17872}
17873
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017874static void alc663_m51va_setup(struct hda_codec *codec)
17875{
17876 struct alc_spec *spec = codec->spec;
17877 spec->ext_mic.pin = 0x18;
17878 spec->ext_mic.mux_idx = 0;
17879 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017880 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017881 spec->auto_mic = 1;
17882}
17883
Kailang Yang6dda9f42008-05-27 12:05:31 +020017884static void alc663_m51va_inithook(struct hda_codec *codec)
17885{
17886 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017887 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017888}
17889
Kailang Yangf1d4e282008-08-26 14:03:29 +020017890/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017891#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017892
17893static void alc663_mode1_setup(struct hda_codec *codec)
17894{
17895 struct alc_spec *spec = codec->spec;
17896 spec->ext_mic.pin = 0x18;
17897 spec->ext_mic.mux_idx = 0;
17898 spec->int_mic.pin = 0x19;
17899 spec->int_mic.mux_idx = 1;
17900 spec->auto_mic = 1;
17901}
17902
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017903#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017904
Kailang Yangf1d4e282008-08-26 14:03:29 +020017905/* ***************** Mode2 ******************************/
17906static void alc662_mode2_unsol_event(struct hda_codec *codec,
17907 unsigned int res)
17908{
17909 switch (res >> 26) {
17910 case ALC880_HP_EVENT:
17911 alc662_f5z_speaker_automute(codec);
17912 break;
17913 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017914 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017915 break;
17916 }
17917}
17918
Kailang Yangebb83ee2009-12-17 12:23:00 +010017919#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017920
Kailang Yangf1d4e282008-08-26 14:03:29 +020017921static void alc662_mode2_inithook(struct hda_codec *codec)
17922{
17923 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017924 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017925}
17926/* ***************** Mode3 ******************************/
17927static void alc663_mode3_unsol_event(struct hda_codec *codec,
17928 unsigned int res)
17929{
17930 switch (res >> 26) {
17931 case ALC880_HP_EVENT:
17932 alc663_two_hp_m1_speaker_automute(codec);
17933 break;
17934 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017935 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017936 break;
17937 }
17938}
17939
Kailang Yangebb83ee2009-12-17 12:23:00 +010017940#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017941
Kailang Yangf1d4e282008-08-26 14:03:29 +020017942static void alc663_mode3_inithook(struct hda_codec *codec)
17943{
17944 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017945 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017946}
17947/* ***************** Mode4 ******************************/
17948static void alc663_mode4_unsol_event(struct hda_codec *codec,
17949 unsigned int res)
17950{
17951 switch (res >> 26) {
17952 case ALC880_HP_EVENT:
17953 alc663_21jd_two_speaker_automute(codec);
17954 break;
17955 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017956 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017957 break;
17958 }
17959}
17960
Kailang Yangebb83ee2009-12-17 12:23:00 +010017961#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017962
Kailang Yangf1d4e282008-08-26 14:03:29 +020017963static void alc663_mode4_inithook(struct hda_codec *codec)
17964{
17965 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017966 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017967}
17968/* ***************** Mode5 ******************************/
17969static void alc663_mode5_unsol_event(struct hda_codec *codec,
17970 unsigned int res)
17971{
17972 switch (res >> 26) {
17973 case ALC880_HP_EVENT:
17974 alc663_15jd_two_speaker_automute(codec);
17975 break;
17976 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017977 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017978 break;
17979 }
17980}
17981
Kailang Yangebb83ee2009-12-17 12:23:00 +010017982#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017983
Kailang Yangf1d4e282008-08-26 14:03:29 +020017984static void alc663_mode5_inithook(struct hda_codec *codec)
17985{
17986 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017987 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017988}
17989/* ***************** Mode6 ******************************/
17990static void alc663_mode6_unsol_event(struct hda_codec *codec,
17991 unsigned int res)
17992{
17993 switch (res >> 26) {
17994 case ALC880_HP_EVENT:
17995 alc663_two_hp_m2_speaker_automute(codec);
17996 break;
17997 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017998 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017999 break;
18000 }
18001}
18002
Kailang Yangebb83ee2009-12-17 12:23:00 +010018003#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018004
Kailang Yangf1d4e282008-08-26 14:03:29 +020018005static void alc663_mode6_inithook(struct hda_codec *codec)
18006{
18007 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018008 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018009}
18010
Kailang Yangebb83ee2009-12-17 12:23:00 +010018011/* ***************** Mode7 ******************************/
18012static void alc663_mode7_unsol_event(struct hda_codec *codec,
18013 unsigned int res)
18014{
18015 switch (res >> 26) {
18016 case ALC880_HP_EVENT:
18017 alc663_two_hp_m7_speaker_automute(codec);
18018 break;
18019 case ALC880_MIC_EVENT:
18020 alc_mic_automute(codec);
18021 break;
18022 }
18023}
18024
18025#define alc663_mode7_setup alc663_mode1_setup
18026
18027static void alc663_mode7_inithook(struct hda_codec *codec)
18028{
18029 alc663_two_hp_m7_speaker_automute(codec);
18030 alc_mic_automute(codec);
18031}
18032
18033/* ***************** Mode8 ******************************/
18034static void alc663_mode8_unsol_event(struct hda_codec *codec,
18035 unsigned int res)
18036{
18037 switch (res >> 26) {
18038 case ALC880_HP_EVENT:
18039 alc663_two_hp_m8_speaker_automute(codec);
18040 break;
18041 case ALC880_MIC_EVENT:
18042 alc_mic_automute(codec);
18043 break;
18044 }
18045}
18046
18047#define alc663_mode8_setup alc663_m51va_setup
18048
18049static void alc663_mode8_inithook(struct hda_codec *codec)
18050{
18051 alc663_two_hp_m8_speaker_automute(codec);
18052 alc_mic_automute(codec);
18053}
18054
Kailang Yang6dda9f42008-05-27 12:05:31 +020018055static void alc663_g71v_hp_automute(struct hda_codec *codec)
18056{
18057 unsigned int present;
18058 unsigned char bits;
18059
Wu Fengguang864f92b2009-11-18 12:38:02 +080018060 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018061 bits = present ? HDA_AMP_MUTE : 0;
18062 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18063 HDA_AMP_MUTE, bits);
18064 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18065 HDA_AMP_MUTE, bits);
18066}
18067
18068static void alc663_g71v_front_automute(struct hda_codec *codec)
18069{
18070 unsigned int present;
18071 unsigned char bits;
18072
Wu Fengguang864f92b2009-11-18 12:38:02 +080018073 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018074 bits = present ? HDA_AMP_MUTE : 0;
18075 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18076 HDA_AMP_MUTE, bits);
18077}
18078
18079static void alc663_g71v_unsol_event(struct hda_codec *codec,
18080 unsigned int res)
18081{
18082 switch (res >> 26) {
18083 case ALC880_HP_EVENT:
18084 alc663_g71v_hp_automute(codec);
18085 break;
18086 case ALC880_FRONT_EVENT:
18087 alc663_g71v_front_automute(codec);
18088 break;
18089 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018090 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018091 break;
18092 }
18093}
18094
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018095#define alc663_g71v_setup alc663_m51va_setup
18096
Kailang Yang6dda9f42008-05-27 12:05:31 +020018097static void alc663_g71v_inithook(struct hda_codec *codec)
18098{
18099 alc663_g71v_front_automute(codec);
18100 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018101 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018102}
18103
18104static void alc663_g50v_unsol_event(struct hda_codec *codec,
18105 unsigned int res)
18106{
18107 switch (res >> 26) {
18108 case ALC880_HP_EVENT:
18109 alc663_m51va_speaker_automute(codec);
18110 break;
18111 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018112 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018113 break;
18114 }
18115}
18116
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018117#define alc663_g50v_setup alc663_m51va_setup
18118
Kailang Yang6dda9f42008-05-27 12:05:31 +020018119static void alc663_g50v_inithook(struct hda_codec *codec)
18120{
18121 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018122 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018123}
18124
Kailang Yangf1d4e282008-08-26 14:03:29 +020018125static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18126 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018127 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018128
18129 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18130 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18131 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18132
18133 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18134 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18135 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18136 { } /* end */
18137};
18138
Chris Pockelé9541ba12009-05-12 08:08:53 +020018139static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18140 /* Master Playback automatically created from Speaker and Headphone */
18141 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18142 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18143 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18145
18146 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18147 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18148 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18149
18150 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18151 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18152 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18153 { } /* end */
18154};
18155
Takashi Iwaicb53c622007-08-10 17:21:45 +020018156#ifdef CONFIG_SND_HDA_POWER_SAVE
18157#define alc662_loopbacks alc880_loopbacks
18158#endif
18159
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018160
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018161/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018162#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18163#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18164#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18165#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18166
18167/*
18168 * configuration and preset
18169 */
18170static const char *alc662_models[ALC662_MODEL_LAST] = {
18171 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18172 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18173 [ALC662_3ST_6ch] = "3stack-6ch",
18174 [ALC662_5ST_DIG] = "6stack-dig",
18175 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018176 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018177 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018178 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018179 [ALC663_ASUS_M51VA] = "m51va",
18180 [ALC663_ASUS_G71V] = "g71v",
18181 [ALC663_ASUS_H13] = "h13",
18182 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018183 [ALC663_ASUS_MODE1] = "asus-mode1",
18184 [ALC662_ASUS_MODE2] = "asus-mode2",
18185 [ALC663_ASUS_MODE3] = "asus-mode3",
18186 [ALC663_ASUS_MODE4] = "asus-mode4",
18187 [ALC663_ASUS_MODE5] = "asus-mode5",
18188 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018189 [ALC663_ASUS_MODE7] = "asus-mode7",
18190 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018191 [ALC272_DELL] = "dell",
18192 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018193 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018194 [ALC662_AUTO] = "auto",
18195};
18196
18197static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018198 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018199 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18200 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018201 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18202 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018203 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018204 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18205 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18206 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18207 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018208 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18209 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018210 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018211 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18212 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18213 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18214 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18215 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018216 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018217 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18218 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018219 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18220 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18221 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18222 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018223 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018224 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18225 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18226 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018227 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18228 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18229 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18230 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018231 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018232 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18233 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018234 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018235 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18236 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18237 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018238 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018239 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018240 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18241 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018242 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18243 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18244 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018245 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018246 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18247 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018248 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018249 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018250 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018251 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18252 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18253 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018254 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018255 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18256 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018257 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018258 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018259 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018260 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018261 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18262 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018263 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018264 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018265 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18266 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018267 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018268 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018269 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018270 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018271 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018272 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018273 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18274 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018275 {}
18276};
18277
18278static struct alc_config_preset alc662_presets[] = {
18279 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018280 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018281 .init_verbs = { alc662_init_verbs },
18282 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18283 .dac_nids = alc662_dac_nids,
18284 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018285 .dig_in_nid = ALC662_DIGIN_NID,
18286 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18287 .channel_mode = alc662_3ST_2ch_modes,
18288 .input_mux = &alc662_capture_source,
18289 },
18290 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018291 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018292 .init_verbs = { alc662_init_verbs },
18293 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18294 .dac_nids = alc662_dac_nids,
18295 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018296 .dig_in_nid = ALC662_DIGIN_NID,
18297 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18298 .channel_mode = alc662_3ST_6ch_modes,
18299 .need_dac_fix = 1,
18300 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018301 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018302 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018303 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018304 .init_verbs = { alc662_init_verbs },
18305 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18306 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018307 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18308 .channel_mode = alc662_3ST_6ch_modes,
18309 .need_dac_fix = 1,
18310 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018311 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018312 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018313 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018314 .init_verbs = { alc662_init_verbs },
18315 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18316 .dac_nids = alc662_dac_nids,
18317 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018318 .dig_in_nid = ALC662_DIGIN_NID,
18319 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18320 .channel_mode = alc662_5stack_modes,
18321 .input_mux = &alc662_capture_source,
18322 },
18323 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018324 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018325 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18326 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18327 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018328 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18329 .channel_mode = alc662_3ST_2ch_modes,
18330 .input_mux = &alc662_lenovo_101e_capture_source,
18331 .unsol_event = alc662_lenovo_101e_unsol_event,
18332 .init_hook = alc662_lenovo_101e_all_automute,
18333 },
Kailang Yang291702f2007-10-16 14:28:03 +020018334 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018335 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018336 .init_verbs = { alc662_init_verbs,
18337 alc662_eeepc_sue_init_verbs },
18338 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18339 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018340 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18341 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018342 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018343 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018344 .init_hook = alc662_eeepc_inithook,
18345 },
Kailang Yang8c427222008-01-10 13:03:59 +010018346 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018347 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018348 alc662_chmode_mixer },
18349 .init_verbs = { alc662_init_verbs,
18350 alc662_eeepc_ep20_sue_init_verbs },
18351 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18352 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018353 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18354 .channel_mode = alc662_3ST_6ch_modes,
18355 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018356 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018357 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018358 .init_hook = alc662_eeepc_ep20_inithook,
18359 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018361 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018362 .init_verbs = { alc662_init_verbs,
18363 alc662_ecs_init_verbs },
18364 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18365 .dac_nids = alc662_dac_nids,
18366 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18367 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018368 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018369 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018370 .init_hook = alc662_eeepc_inithook,
18371 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018372 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018373 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018374 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18375 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18376 .dac_nids = alc662_dac_nids,
18377 .dig_out_nid = ALC662_DIGOUT_NID,
18378 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18379 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018380 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018381 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018382 .init_hook = alc663_m51va_inithook,
18383 },
18384 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018385 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018386 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18387 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18388 .dac_nids = alc662_dac_nids,
18389 .dig_out_nid = ALC662_DIGOUT_NID,
18390 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18391 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018392 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018393 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018394 .init_hook = alc663_g71v_inithook,
18395 },
18396 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018397 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018398 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18399 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18400 .dac_nids = alc662_dac_nids,
18401 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18402 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018403 .unsol_event = alc663_m51va_unsol_event,
18404 .init_hook = alc663_m51va_inithook,
18405 },
18406 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018407 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018408 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18409 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18410 .dac_nids = alc662_dac_nids,
18411 .dig_out_nid = ALC662_DIGOUT_NID,
18412 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18413 .channel_mode = alc662_3ST_6ch_modes,
18414 .input_mux = &alc663_capture_source,
18415 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018416 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018417 .init_hook = alc663_g50v_inithook,
18418 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018419 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018420 .mixers = { alc663_m51va_mixer },
18421 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018422 .init_verbs = { alc662_init_verbs,
18423 alc663_21jd_amic_init_verbs },
18424 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18425 .hp_nid = 0x03,
18426 .dac_nids = alc662_dac_nids,
18427 .dig_out_nid = ALC662_DIGOUT_NID,
18428 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18429 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018430 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018431 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018432 .init_hook = alc663_mode1_inithook,
18433 },
18434 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018435 .mixers = { alc662_1bjd_mixer },
18436 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018437 .init_verbs = { alc662_init_verbs,
18438 alc662_1bjd_amic_init_verbs },
18439 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18440 .dac_nids = alc662_dac_nids,
18441 .dig_out_nid = ALC662_DIGOUT_NID,
18442 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18443 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018444 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018445 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018446 .init_hook = alc662_mode2_inithook,
18447 },
18448 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018449 .mixers = { alc663_two_hp_m1_mixer },
18450 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018451 .init_verbs = { alc662_init_verbs,
18452 alc663_two_hp_amic_m1_init_verbs },
18453 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18454 .hp_nid = 0x03,
18455 .dac_nids = alc662_dac_nids,
18456 .dig_out_nid = ALC662_DIGOUT_NID,
18457 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18458 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018459 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018460 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018461 .init_hook = alc663_mode3_inithook,
18462 },
18463 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018464 .mixers = { alc663_asus_21jd_clfe_mixer },
18465 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018466 .init_verbs = { alc662_init_verbs,
18467 alc663_21jd_amic_init_verbs},
18468 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18469 .hp_nid = 0x03,
18470 .dac_nids = alc662_dac_nids,
18471 .dig_out_nid = ALC662_DIGOUT_NID,
18472 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18473 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018474 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018475 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018476 .init_hook = alc663_mode4_inithook,
18477 },
18478 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018479 .mixers = { alc663_asus_15jd_clfe_mixer },
18480 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018481 .init_verbs = { alc662_init_verbs,
18482 alc663_15jd_amic_init_verbs },
18483 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18484 .hp_nid = 0x03,
18485 .dac_nids = alc662_dac_nids,
18486 .dig_out_nid = ALC662_DIGOUT_NID,
18487 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18488 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018489 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018490 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018491 .init_hook = alc663_mode5_inithook,
18492 },
18493 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018494 .mixers = { alc663_two_hp_m2_mixer },
18495 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018496 .init_verbs = { alc662_init_verbs,
18497 alc663_two_hp_amic_m2_init_verbs },
18498 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18499 .hp_nid = 0x03,
18500 .dac_nids = alc662_dac_nids,
18501 .dig_out_nid = ALC662_DIGOUT_NID,
18502 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18503 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018504 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018505 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018506 .init_hook = alc663_mode6_inithook,
18507 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018508 [ALC663_ASUS_MODE7] = {
18509 .mixers = { alc663_mode7_mixer },
18510 .cap_mixer = alc662_auto_capture_mixer,
18511 .init_verbs = { alc662_init_verbs,
18512 alc663_mode7_init_verbs },
18513 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18514 .hp_nid = 0x03,
18515 .dac_nids = alc662_dac_nids,
18516 .dig_out_nid = ALC662_DIGOUT_NID,
18517 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18518 .channel_mode = alc662_3ST_2ch_modes,
18519 .unsol_event = alc663_mode7_unsol_event,
18520 .setup = alc663_mode7_setup,
18521 .init_hook = alc663_mode7_inithook,
18522 },
18523 [ALC663_ASUS_MODE8] = {
18524 .mixers = { alc663_mode8_mixer },
18525 .cap_mixer = alc662_auto_capture_mixer,
18526 .init_verbs = { alc662_init_verbs,
18527 alc663_mode8_init_verbs },
18528 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18529 .hp_nid = 0x03,
18530 .dac_nids = alc662_dac_nids,
18531 .dig_out_nid = ALC662_DIGOUT_NID,
18532 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18533 .channel_mode = alc662_3ST_2ch_modes,
18534 .unsol_event = alc663_mode8_unsol_event,
18535 .setup = alc663_mode8_setup,
18536 .init_hook = alc663_mode8_inithook,
18537 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018538 [ALC272_DELL] = {
18539 .mixers = { alc663_m51va_mixer },
18540 .cap_mixer = alc272_auto_capture_mixer,
18541 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18542 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18543 .dac_nids = alc662_dac_nids,
18544 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18545 .adc_nids = alc272_adc_nids,
18546 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18547 .capsrc_nids = alc272_capsrc_nids,
18548 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018549 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018550 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018551 .init_hook = alc663_m51va_inithook,
18552 },
18553 [ALC272_DELL_ZM1] = {
18554 .mixers = { alc663_m51va_mixer },
18555 .cap_mixer = alc662_auto_capture_mixer,
18556 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18557 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18558 .dac_nids = alc662_dac_nids,
18559 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18560 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018561 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018562 .capsrc_nids = alc662_capsrc_nids,
18563 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018564 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018565 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018566 .init_hook = alc663_m51va_inithook,
18567 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018568 [ALC272_SAMSUNG_NC10] = {
18569 .mixers = { alc272_nc10_mixer },
18570 .init_verbs = { alc662_init_verbs,
18571 alc663_21jd_amic_init_verbs },
18572 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18573 .dac_nids = alc272_dac_nids,
18574 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18575 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018576 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018577 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018578 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018579 .init_hook = alc663_mode4_inithook,
18580 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018581};
18582
18583
18584/*
18585 * BIOS auto configuration
18586 */
18587
Takashi Iwai7085ec12009-10-02 09:03:58 +020018588/* convert from MIX nid to DAC */
18589static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18590{
18591 if (nid == 0x0f)
18592 return 0x02;
18593 else if (nid >= 0x0c && nid <= 0x0e)
18594 return nid - 0x0c + 0x02;
18595 else
18596 return 0;
18597}
18598
18599/* get MIX nid connected to the given pin targeted to DAC */
18600static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18601 hda_nid_t dac)
18602{
18603 hda_nid_t mix[4];
18604 int i, num;
18605
18606 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18607 for (i = 0; i < num; i++) {
18608 if (alc662_mix_to_dac(mix[i]) == dac)
18609 return mix[i];
18610 }
18611 return 0;
18612}
18613
18614/* look for an empty DAC slot */
18615static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18616{
18617 struct alc_spec *spec = codec->spec;
18618 hda_nid_t srcs[5];
18619 int i, j, num;
18620
18621 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18622 if (num < 0)
18623 return 0;
18624 for (i = 0; i < num; i++) {
18625 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18626 if (!nid)
18627 continue;
18628 for (j = 0; j < spec->multiout.num_dacs; j++)
18629 if (spec->multiout.dac_nids[j] == nid)
18630 break;
18631 if (j >= spec->multiout.num_dacs)
18632 return nid;
18633 }
18634 return 0;
18635}
18636
18637/* fill in the dac_nids table from the parsed pin configuration */
18638static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18639 const struct auto_pin_cfg *cfg)
18640{
18641 struct alc_spec *spec = codec->spec;
18642 int i;
18643 hda_nid_t dac;
18644
18645 spec->multiout.dac_nids = spec->private_dac_nids;
18646 for (i = 0; i < cfg->line_outs; i++) {
18647 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18648 if (!dac)
18649 continue;
18650 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18651 }
18652 return 0;
18653}
18654
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018655static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018656 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018657{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018658 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018659 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18660}
18661
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018662static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018663 hda_nid_t nid, unsigned int chs)
18664{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018665 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018666 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18667}
18668
18669#define alc662_add_stereo_vol(spec, pfx, nid) \
18670 alc662_add_vol_ctl(spec, pfx, nid, 3)
18671#define alc662_add_stereo_sw(spec, pfx, nid) \
18672 alc662_add_sw_ctl(spec, pfx, nid, 3)
18673
18674/* add playback controls from the parsed DAC table */
18675static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18676 const struct auto_pin_cfg *cfg)
18677{
18678 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018679 static const char *chname[4] = {
18680 "Front", "Surround", NULL /*CLFE*/, "Side"
18681 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018682 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018683 int i, err;
18684
18685 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018686 nid = spec->multiout.dac_nids[i];
18687 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018688 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018689 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18690 if (!mix)
18691 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018692 if (i == 2) {
18693 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018694 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018695 if (err < 0)
18696 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018697 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018698 if (err < 0)
18699 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018700 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018701 if (err < 0)
18702 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018703 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704 if (err < 0)
18705 return err;
18706 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018707 const char *pfx;
18708 if (cfg->line_outs == 1 &&
18709 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018710 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018711 pfx = "Speaker";
18712 else
18713 pfx = "PCM";
18714 } else
18715 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018716 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018717 if (err < 0)
18718 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018719 if (cfg->line_outs == 1 &&
18720 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18721 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018722 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018723 if (err < 0)
18724 return err;
18725 }
18726 }
18727 return 0;
18728}
18729
18730/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018731/* return DAC nid if any new DAC is assigned */
18732static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018733 const char *pfx)
18734{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018735 struct alc_spec *spec = codec->spec;
18736 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018737 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018738
18739 if (!pin)
18740 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018741 nid = alc662_look_for_dac(codec, pin);
18742 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018743 /* the corresponding DAC is already occupied */
18744 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18745 return 0; /* no way */
18746 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018747 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018748 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18749 }
18750
18751 mix = alc662_dac_to_mix(codec, pin, nid);
18752 if (!mix)
18753 return 0;
18754 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18755 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018756 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018757 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18758 if (err < 0)
18759 return err;
18760 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018761}
18762
18763/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018764#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018765 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018766
18767static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18768 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018769 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018770{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018771 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020018772 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018773
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018774 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018775 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018776 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18777 if (num <= 1)
18778 return;
18779 for (i = 0; i < num; i++) {
18780 if (alc662_mix_to_dac(srcs[i]) != dac)
18781 continue;
18782 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18783 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018784 }
18785}
18786
18787static void alc662_auto_init_multi_out(struct hda_codec *codec)
18788{
18789 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018790 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018791 int i;
18792
18793 for (i = 0; i <= HDA_SIDE; i++) {
18794 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18795 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018796 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018797 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018798 }
18799}
18800
18801static void alc662_auto_init_hp_out(struct hda_codec *codec)
18802{
18803 struct alc_spec *spec = codec->spec;
18804 hda_nid_t pin;
18805
18806 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018807 if (pin)
18808 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18809 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018810 pin = spec->autocfg.speaker_pins[0];
18811 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018812 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18813 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018814}
18815
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018816#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18817
18818static void alc662_auto_init_analog_input(struct hda_codec *codec)
18819{
18820 struct alc_spec *spec = codec->spec;
18821 int i;
18822
18823 for (i = 0; i < AUTO_PIN_LAST; i++) {
18824 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018825 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018826 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018827 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018828 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018829 snd_hda_codec_write(codec, nid, 0,
18830 AC_VERB_SET_AMP_GAIN_MUTE,
18831 AMP_OUT_MUTE);
18832 }
18833 }
18834}
18835
Takashi Iwaif511b012008-08-15 16:46:42 +020018836#define alc662_auto_init_input_src alc882_auto_init_input_src
18837
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018838static int alc662_parse_auto_config(struct hda_codec *codec)
18839{
18840 struct alc_spec *spec = codec->spec;
18841 int err;
18842 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18843
18844 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18845 alc662_ignore);
18846 if (err < 0)
18847 return err;
18848 if (!spec->autocfg.line_outs)
18849 return 0; /* can't find valid BIOS pin config */
18850
Takashi Iwai7085ec12009-10-02 09:03:58 +020018851 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018852 if (err < 0)
18853 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018854 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018855 if (err < 0)
18856 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018857 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018858 spec->autocfg.speaker_pins[0],
18859 "Speaker");
18860 if (err < 0)
18861 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018862 if (err)
18863 spec->multiout.extra_out_nid[0] = err;
18864 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018865 "Headphone");
18866 if (err < 0)
18867 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018868 if (err)
18869 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018870 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018871 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018872 return err;
18873
18874 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18875
Takashi Iwai757899a2010-07-30 10:48:14 +020018876 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018877
Takashi Iwai603c4012008-07-30 15:01:44 +020018878 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018879 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018880
18881 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018882 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018883
Kailang Yangcec27c82010-02-04 14:18:18 +010018884 add_verb(spec, alc662_init_verbs);
18885 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020018886 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010018887 add_verb(spec, alc663_init_verbs);
18888
18889 if (codec->vendor_id == 0x10ec0272)
18890 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018891
18892 err = alc_auto_add_mic_boost(codec);
18893 if (err < 0)
18894 return err;
18895
Kailang Yang6227cdc2010-02-25 08:36:52 +010018896 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18897 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18898 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18899 else
18900 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018901
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018902 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018903}
18904
18905/* additional initialization for auto-configuration model */
18906static void alc662_auto_init(struct hda_codec *codec)
18907{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018908 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018909 alc662_auto_init_multi_out(codec);
18910 alc662_auto_init_hp_out(codec);
18911 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018912 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020018913 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018914 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018915 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018916}
18917
18918static int patch_alc662(struct hda_codec *codec)
18919{
18920 struct alc_spec *spec;
18921 int err, board_config;
18922
18923 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18924 if (!spec)
18925 return -ENOMEM;
18926
18927 codec->spec = spec;
18928
Kailang Yangda00c242010-03-19 11:23:45 +010018929 alc_auto_parse_customize_define(codec);
18930
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018931 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18932
Kailang Yangc027ddc2010-03-19 11:33:06 +010018933 if (alc_read_coef_idx(codec, 0) == 0x8020)
18934 alc_codec_rename(codec, "ALC661");
18935 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18936 codec->bus->pci->subsystem_vendor == 0x1025 &&
18937 spec->cdefine.platform_type == 1)
18938 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018939
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018940 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18941 alc662_models,
18942 alc662_cfg_tbl);
18943 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018944 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18945 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018946 board_config = ALC662_AUTO;
18947 }
18948
18949 if (board_config == ALC662_AUTO) {
18950 /* automatic parse from the BIOS config */
18951 err = alc662_parse_auto_config(codec);
18952 if (err < 0) {
18953 alc_free(codec);
18954 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018955 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018956 printk(KERN_INFO
18957 "hda_codec: Cannot set up configuration "
18958 "from BIOS. Using base mode...\n");
18959 board_config = ALC662_3ST_2ch_DIG;
18960 }
18961 }
18962
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018963 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020018964 err = snd_hda_attach_beep_device(codec, 0x1);
18965 if (err < 0) {
18966 alc_free(codec);
18967 return err;
18968 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018969 }
18970
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018971 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018972 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018973
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018974 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18975 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18976
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018977 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18978 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18979
Takashi Iwaidd704692009-08-11 08:45:11 +020018980 if (!spec->adc_nids) {
18981 spec->adc_nids = alc662_adc_nids;
18982 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18983 }
18984 if (!spec->capsrc_nids)
18985 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018986
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018987 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018988 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018989
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018990 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010018991 switch (codec->vendor_id) {
18992 case 0x10ec0662:
18993 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18994 break;
18995 case 0x10ec0272:
18996 case 0x10ec0663:
18997 case 0x10ec0665:
18998 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18999 break;
19000 case 0x10ec0273:
19001 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19002 break;
19003 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019004 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019005 spec->vmaster_nid = 0x02;
19006
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019007 codec->patch_ops = alc_patch_ops;
19008 if (board_config == ALC662_AUTO)
19009 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020019010#ifdef CONFIG_SND_HDA_POWER_SAVE
19011 if (!spec->loopback.amplist)
19012 spec->loopback.amplist = alc662_loopbacks;
19013#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019014
19015 return 0;
19016}
19017
Kailang Yang274693f2009-12-03 10:07:50 +010019018static int patch_alc888(struct hda_codec *codec)
19019{
19020 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19021 kfree(codec->chip_name);
19022 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019023 if (!codec->chip_name) {
19024 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019025 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019026 }
19027 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019028 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019029 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019030}
19031
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019032/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019033 * ALC680 support
19034 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019035#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019036#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19037#define alc680_modes alc260_modes
19038
19039static hda_nid_t alc680_dac_nids[3] = {
19040 /* Lout1, Lout2, hp */
19041 0x02, 0x03, 0x04
19042};
19043
19044static hda_nid_t alc680_adc_nids[3] = {
19045 /* ADC0-2 */
19046 /* DMIC, MIC, Line-in*/
19047 0x07, 0x08, 0x09
19048};
19049
Kailang Yangc69aefa2010-08-17 10:39:22 +020019050/*
19051 * Analog capture ADC cgange
19052 */
19053static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19054 struct hda_codec *codec,
19055 unsigned int stream_tag,
19056 unsigned int format,
19057 struct snd_pcm_substream *substream)
19058{
19059 struct alc_spec *spec = codec->spec;
19060 struct auto_pin_cfg *cfg = &spec->autocfg;
19061 unsigned int pre_mic, pre_line;
19062
19063 pre_mic = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]);
19064 pre_line = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_LINE]);
19065
19066 spec->cur_adc_stream_tag = stream_tag;
19067 spec->cur_adc_format = format;
19068
19069 if (pre_mic || pre_line) {
19070 if (pre_mic)
19071 snd_hda_codec_setup_stream(codec, 0x08, stream_tag, 0,
19072 format);
19073 else
19074 snd_hda_codec_setup_stream(codec, 0x09, stream_tag, 0,
19075 format);
19076 } else
19077 snd_hda_codec_setup_stream(codec, 0x07, stream_tag, 0, format);
19078 return 0;
19079}
19080
19081static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19082 struct hda_codec *codec,
19083 struct snd_pcm_substream *substream)
19084{
19085 snd_hda_codec_cleanup_stream(codec, 0x07);
19086 snd_hda_codec_cleanup_stream(codec, 0x08);
19087 snd_hda_codec_cleanup_stream(codec, 0x09);
19088 return 0;
19089}
19090
19091static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19092 .substreams = 1, /* can be overridden */
19093 .channels_min = 2,
19094 .channels_max = 2,
19095 /* NID is set in alc_build_pcms */
19096 .ops = {
19097 .prepare = alc680_capture_pcm_prepare,
19098 .cleanup = alc680_capture_pcm_cleanup
19099 },
19100};
19101
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019102static struct snd_kcontrol_new alc680_base_mixer[] = {
19103 /* output mixer control */
19104 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19105 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19106 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019108 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019110 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019111 { }
19112};
19113
Kailang Yangc69aefa2010-08-17 10:39:22 +020019114static struct hda_bind_ctls alc680_bind_cap_vol = {
19115 .ops = &snd_hda_bind_vol,
19116 .values = {
19117 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19118 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19119 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19120 0
19121 },
19122};
19123
19124static struct hda_bind_ctls alc680_bind_cap_switch = {
19125 .ops = &snd_hda_bind_sw,
19126 .values = {
19127 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19128 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19129 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19130 0
19131 },
19132};
19133
19134static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19135 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19136 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019137 { } /* end */
19138};
19139
19140/*
19141 * generic initialization of ADC, input mixers and output mixers
19142 */
19143static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019144 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19145 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19146 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019147
Kailang Yangc69aefa2010-08-17 10:39:22 +020019148 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19150 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19151 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19152 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19153 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019154
19155 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19159 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019160
19161 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19162 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
19163
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019164 { }
19165};
19166
Kailang Yangc69aefa2010-08-17 10:39:22 +020019167/* toggle speaker-output according to the hp-jack state */
19168static void alc680_base_setup(struct hda_codec *codec)
19169{
19170 struct alc_spec *spec = codec->spec;
19171
19172 spec->autocfg.hp_pins[0] = 0x16;
19173 spec->autocfg.speaker_pins[0] = 0x14;
19174 spec->autocfg.speaker_pins[1] = 0x15;
19175 spec->autocfg.input_pins[AUTO_PIN_MIC] = 0x18;
19176 spec->autocfg.input_pins[AUTO_PIN_LINE] = 0x19;
19177}
19178
19179static void alc680_rec_autoswitch(struct hda_codec *codec)
19180{
19181 struct alc_spec *spec = codec->spec;
19182 struct auto_pin_cfg *cfg = &spec->autocfg;
19183 unsigned int present;
19184 hda_nid_t new_adc;
19185
19186 present = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]);
19187
19188 new_adc = present ? 0x8 : 0x7;
19189 __snd_hda_codec_cleanup_stream(codec, !present ? 0x8 : 0x7, 1);
19190 snd_hda_codec_setup_stream(codec, new_adc,
19191 spec->cur_adc_stream_tag, 0,
19192 spec->cur_adc_format);
19193
19194}
19195
19196static void alc680_unsol_event(struct hda_codec *codec,
19197 unsigned int res)
19198{
19199 if ((res >> 26) == ALC880_HP_EVENT)
19200 alc_automute_amp(codec);
19201 if ((res >> 26) == ALC880_MIC_EVENT)
19202 alc680_rec_autoswitch(codec);
19203}
19204
19205static void alc680_inithook(struct hda_codec *codec)
19206{
19207 alc_automute_amp(codec);
19208 alc680_rec_autoswitch(codec);
19209}
19210
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019211/* create input playback/capture controls for the given pin */
19212static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19213 const char *ctlname, int idx)
19214{
19215 hda_nid_t dac;
19216 int err;
19217
19218 switch (nid) {
19219 case 0x14:
19220 dac = 0x02;
19221 break;
19222 case 0x15:
19223 dac = 0x03;
19224 break;
19225 case 0x16:
19226 dac = 0x04;
19227 break;
19228 default:
19229 return 0;
19230 }
19231 if (spec->multiout.dac_nids[0] != dac &&
19232 spec->multiout.dac_nids[1] != dac) {
19233 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19234 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19235 HDA_OUTPUT));
19236 if (err < 0)
19237 return err;
19238
19239 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19240 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19241
19242 if (err < 0)
19243 return err;
19244 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19245 }
19246
19247 return 0;
19248}
19249
19250/* add playback controls from the parsed DAC table */
19251static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19252 const struct auto_pin_cfg *cfg)
19253{
19254 hda_nid_t nid;
19255 int err;
19256
19257 spec->multiout.dac_nids = spec->private_dac_nids;
19258
19259 nid = cfg->line_out_pins[0];
19260 if (nid) {
19261 const char *name;
19262 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19263 name = "Speaker";
19264 else
19265 name = "Front";
19266 err = alc680_new_analog_output(spec, nid, name, 0);
19267 if (err < 0)
19268 return err;
19269 }
19270
19271 nid = cfg->speaker_pins[0];
19272 if (nid) {
19273 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19274 if (err < 0)
19275 return err;
19276 }
19277 nid = cfg->hp_pins[0];
19278 if (nid) {
19279 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19280 if (err < 0)
19281 return err;
19282 }
19283
19284 return 0;
19285}
19286
19287static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19288 hda_nid_t nid, int pin_type)
19289{
19290 alc_set_pin_output(codec, nid, pin_type);
19291}
19292
19293static void alc680_auto_init_multi_out(struct hda_codec *codec)
19294{
19295 struct alc_spec *spec = codec->spec;
19296 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19297 if (nid) {
19298 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19299 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19300 }
19301}
19302
19303static void alc680_auto_init_hp_out(struct hda_codec *codec)
19304{
19305 struct alc_spec *spec = codec->spec;
19306 hda_nid_t pin;
19307
19308 pin = spec->autocfg.hp_pins[0];
19309 if (pin)
19310 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19311 pin = spec->autocfg.speaker_pins[0];
19312 if (pin)
19313 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19314}
19315
19316/* pcm configuration: identical with ALC880 */
19317#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19318#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19319#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19320#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019321#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019322
19323/*
19324 * BIOS auto configuration
19325 */
19326static int alc680_parse_auto_config(struct hda_codec *codec)
19327{
19328 struct alc_spec *spec = codec->spec;
19329 int err;
19330 static hda_nid_t alc680_ignore[] = { 0 };
19331
19332 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19333 alc680_ignore);
19334 if (err < 0)
19335 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019336
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019337 if (!spec->autocfg.line_outs) {
19338 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19339 spec->multiout.max_channels = 2;
19340 spec->no_analog = 1;
19341 goto dig_only;
19342 }
19343 return 0; /* can't find valid BIOS pin config */
19344 }
19345 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19346 if (err < 0)
19347 return err;
19348
19349 spec->multiout.max_channels = 2;
19350
19351 dig_only:
19352 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019353 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019354 if (spec->kctls.list)
19355 add_mixer(spec, spec->kctls.list);
19356
19357 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019358
19359 err = alc_auto_add_mic_boost(codec);
19360 if (err < 0)
19361 return err;
19362
19363 return 1;
19364}
19365
19366#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19367
19368/* init callback for auto-configuration model -- overriding the default init */
19369static void alc680_auto_init(struct hda_codec *codec)
19370{
19371 struct alc_spec *spec = codec->spec;
19372 alc680_auto_init_multi_out(codec);
19373 alc680_auto_init_hp_out(codec);
19374 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019375 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019376 if (spec->unsol_event)
19377 alc_inithook(codec);
19378}
19379
19380/*
19381 * configuration and preset
19382 */
19383static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019384 [ALC680_BASE] = "base",
19385 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019386};
19387
19388static struct snd_pci_quirk alc680_cfg_tbl[] = {
19389 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19390 {}
19391};
19392
19393static struct alc_config_preset alc680_presets[] = {
19394 [ALC680_BASE] = {
19395 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019396 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019397 .init_verbs = { alc680_init_verbs },
19398 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19399 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019400 .dig_out_nid = ALC680_DIGOUT_NID,
19401 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19402 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019403 .unsol_event = alc680_unsol_event,
19404 .setup = alc680_base_setup,
19405 .init_hook = alc680_inithook,
19406
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019407 },
19408};
19409
19410static int patch_alc680(struct hda_codec *codec)
19411{
19412 struct alc_spec *spec;
19413 int board_config;
19414 int err;
19415
19416 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19417 if (spec == NULL)
19418 return -ENOMEM;
19419
19420 codec->spec = spec;
19421
19422 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19423 alc680_models,
19424 alc680_cfg_tbl);
19425
19426 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19427 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19428 codec->chip_name);
19429 board_config = ALC680_AUTO;
19430 }
19431
19432 if (board_config == ALC680_AUTO) {
19433 /* automatic parse from the BIOS config */
19434 err = alc680_parse_auto_config(codec);
19435 if (err < 0) {
19436 alc_free(codec);
19437 return err;
19438 } else if (!err) {
19439 printk(KERN_INFO
19440 "hda_codec: Cannot set up configuration "
19441 "from BIOS. Using base mode...\n");
19442 board_config = ALC680_BASE;
19443 }
19444 }
19445
19446 if (board_config != ALC680_AUTO)
19447 setup_preset(codec, &alc680_presets[board_config]);
19448
19449 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019450 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019451 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019452 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019453
19454 if (!spec->adc_nids) {
19455 spec->adc_nids = alc680_adc_nids;
19456 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19457 }
19458
19459 if (!spec->cap_mixer)
19460 set_capture_mixer(codec);
19461
19462 spec->vmaster_nid = 0x02;
19463
19464 codec->patch_ops = alc_patch_ops;
19465 if (board_config == ALC680_AUTO)
19466 spec->init_hook = alc680_auto_init;
19467
19468 return 0;
19469}
19470
19471/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019472 * patch entries
19473 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019474static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019475 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019476 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019477 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019478 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019479 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019480 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019481 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019482 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019483 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019484 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019485 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19486 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19487 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019488 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019489 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019490 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19491 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019492 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019493 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019494 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019495 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019496 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019497 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019498 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019499 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019500 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019501 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019502 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019503 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019504 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019505 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019506 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019507 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019508 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019509 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019510 {} /* terminator */
19511};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019512
19513MODULE_ALIAS("snd-hda-codec-id:10ec*");
19514
19515MODULE_LICENSE("GPL");
19516MODULE_DESCRIPTION("Realtek HD-audio codec");
19517
19518static struct hda_codec_preset_list realtek_list = {
19519 .preset = snd_hda_preset_realtek,
19520 .owner = THIS_MODULE,
19521};
19522
19523static int __init patch_realtek_init(void)
19524{
19525 return snd_hda_add_codec_preset(&realtek_list);
19526}
19527
19528static void __exit patch_realtek_exit(void)
19529{
19530 snd_hda_delete_codec_preset(&realtek_list);
19531}
19532
19533module_init(patch_realtek_init)
19534module_exit(patch_realtek_exit)