blob: 50e0c82fd994b7346c72476d7037221766d59152 [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 Iwaie096c8e2010-08-03 17:20:35 +02005337 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005338 {}
5339};
5340
5341static inline int has_cdefine_beep(struct hda_codec *codec)
5342{
5343 struct alc_spec *spec = codec->spec;
5344 const struct snd_pci_quirk *q;
5345 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5346 if (q)
5347 return q->value;
5348 return spec->cdefine.enable_pcbeep;
5349}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005350#else
5351#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005352#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005353#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005354
5355/*
5356 * OK, here we have finally the patch for ALC880
5357 */
5358
Linus Torvalds1da177e2005-04-16 15:20:36 -07005359static int patch_alc880(struct hda_codec *codec)
5360{
5361 struct alc_spec *spec;
5362 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005363 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005364
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005365 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005366 if (spec == NULL)
5367 return -ENOMEM;
5368
5369 codec->spec = spec;
5370
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005371 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5372 alc880_models,
5373 alc880_cfg_tbl);
5374 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005375 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5376 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005378 }
5379
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005380 if (board_config == ALC880_AUTO) {
5381 /* automatic parse from the BIOS config */
5382 err = alc880_parse_auto_config(codec);
5383 if (err < 0) {
5384 alc_free(codec);
5385 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005386 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005387 printk(KERN_INFO
5388 "hda_codec: Cannot set up configuration "
5389 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005390 board_config = ALC880_3ST;
5391 }
5392 }
5393
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005394 err = snd_hda_attach_beep_device(codec, 0x1);
5395 if (err < 0) {
5396 alc_free(codec);
5397 return err;
5398 }
5399
Kailang Yangdf694da2005-12-05 19:42:22 +01005400 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005401 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005402
Linus Torvalds1da177e2005-04-16 15:20:36 -07005403 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5404 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005405 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005406
Linus Torvalds1da177e2005-04-16 15:20:36 -07005407 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5408 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5409
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005410 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005411 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005412 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005413 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005414 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415 if (wcap != AC_WID_AUD_IN) {
5416 spec->adc_nids = alc880_adc_nids_alt;
5417 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005418 } else {
5419 spec->adc_nids = alc880_adc_nids;
5420 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005421 }
5422 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005423 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005424 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005425
Takashi Iwai2134ea42008-01-10 16:53:55 +01005426 spec->vmaster_nid = 0x0c;
5427
Linus Torvalds1da177e2005-04-16 15:20:36 -07005428 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005429 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005430 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005431#ifdef CONFIG_SND_HDA_POWER_SAVE
5432 if (!spec->loopback.amplist)
5433 spec->loopback.amplist = alc880_loopbacks;
5434#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005435
5436 return 0;
5437}
5438
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005439
Linus Torvalds1da177e2005-04-16 15:20:36 -07005440/*
5441 * ALC260 support
5442 */
5443
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005444static hda_nid_t alc260_dac_nids[1] = {
5445 /* front */
5446 0x02,
5447};
5448
5449static hda_nid_t alc260_adc_nids[1] = {
5450 /* ADC0 */
5451 0x04,
5452};
5453
Kailang Yangdf694da2005-12-05 19:42:22 +01005454static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005455 /* ADC1 */
5456 0x05,
5457};
5458
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005459/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5460 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5461 */
5462static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005463 /* ADC0, ADC1 */
5464 0x04, 0x05
5465};
5466
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005467#define ALC260_DIGOUT_NID 0x03
5468#define ALC260_DIGIN_NID 0x06
5469
5470static struct hda_input_mux alc260_capture_source = {
5471 .num_items = 4,
5472 .items = {
5473 { "Mic", 0x0 },
5474 { "Front Mic", 0x1 },
5475 { "Line", 0x2 },
5476 { "CD", 0x4 },
5477 },
5478};
5479
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005480/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005481 * headphone jack and the internal CD lines since these are the only pins at
5482 * which audio can appear. For flexibility, also allow the option of
5483 * recording the mixer output on the second ADC (ADC0 doesn't have a
5484 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005485 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005486static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5487 {
5488 .num_items = 3,
5489 .items = {
5490 { "Mic/Line", 0x0 },
5491 { "CD", 0x4 },
5492 { "Headphone", 0x2 },
5493 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005494 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005495 {
5496 .num_items = 4,
5497 .items = {
5498 { "Mic/Line", 0x0 },
5499 { "CD", 0x4 },
5500 { "Headphone", 0x2 },
5501 { "Mixer", 0x5 },
5502 },
5503 },
5504
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005505};
5506
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005507/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5508 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005509 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005510static struct hda_input_mux alc260_acer_capture_sources[2] = {
5511 {
5512 .num_items = 4,
5513 .items = {
5514 { "Mic", 0x0 },
5515 { "Line", 0x2 },
5516 { "CD", 0x4 },
5517 { "Headphone", 0x5 },
5518 },
5519 },
5520 {
5521 .num_items = 5,
5522 .items = {
5523 { "Mic", 0x0 },
5524 { "Line", 0x2 },
5525 { "CD", 0x4 },
5526 { "Headphone", 0x6 },
5527 { "Mixer", 0x5 },
5528 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005529 },
5530};
Michael Schwingencc959482009-02-22 18:58:45 +01005531
5532/* Maxdata Favorit 100XS */
5533static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5534 {
5535 .num_items = 2,
5536 .items = {
5537 { "Line/Mic", 0x0 },
5538 { "CD", 0x4 },
5539 },
5540 },
5541 {
5542 .num_items = 3,
5543 .items = {
5544 { "Line/Mic", 0x0 },
5545 { "CD", 0x4 },
5546 { "Mixer", 0x5 },
5547 },
5548 },
5549};
5550
Linus Torvalds1da177e2005-04-16 15:20:36 -07005551/*
5552 * This is just place-holder, so there's something for alc_build_pcms to look
5553 * at when it calculates the maximum number of channels. ALC260 has no mixer
5554 * element which allows changing the channel mode, so the verb list is
5555 * never used.
5556 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005557static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005558 { 2, NULL },
5559};
5560
Kailang Yangdf694da2005-12-05 19:42:22 +01005561
5562/* Mixer combinations
5563 *
5564 * basic: base_output + input + pc_beep + capture
5565 * HP: base_output + input + capture_alt
5566 * HP_3013: hp_3013 + input + capture
5567 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005568 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005569 */
5570
5571static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005572 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005573 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005574 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5575 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5576 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5577 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5578 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005579};
Kailang Yangdf694da2005-12-05 19:42:22 +01005580
5581static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005582 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5583 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5584 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5585 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5586 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5587 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5588 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5589 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005590 { } /* end */
5591};
5592
Takashi Iwaibec15c32008-01-28 18:16:30 +01005593/* update HP, line and mono out pins according to the master switch */
5594static void alc260_hp_master_update(struct hda_codec *codec,
5595 hda_nid_t hp, hda_nid_t line,
5596 hda_nid_t mono)
5597{
5598 struct alc_spec *spec = codec->spec;
5599 unsigned int val = spec->master_sw ? PIN_HP : 0;
5600 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005601 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005602 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005603 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005604 val);
5605 /* mono (speaker) depending on the HP jack sense */
5606 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005607 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005608 val);
5609}
5610
5611static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5612 struct snd_ctl_elem_value *ucontrol)
5613{
5614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5615 struct alc_spec *spec = codec->spec;
5616 *ucontrol->value.integer.value = spec->master_sw;
5617 return 0;
5618}
5619
5620static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5621 struct snd_ctl_elem_value *ucontrol)
5622{
5623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5624 struct alc_spec *spec = codec->spec;
5625 int val = !!*ucontrol->value.integer.value;
5626 hda_nid_t hp, line, mono;
5627
5628 if (val == spec->master_sw)
5629 return 0;
5630 spec->master_sw = val;
5631 hp = (kcontrol->private_value >> 16) & 0xff;
5632 line = (kcontrol->private_value >> 8) & 0xff;
5633 mono = kcontrol->private_value & 0xff;
5634 alc260_hp_master_update(codec, hp, line, mono);
5635 return 1;
5636}
5637
5638static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5639 {
5640 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5641 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005642 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005643 .info = snd_ctl_boolean_mono_info,
5644 .get = alc260_hp_master_sw_get,
5645 .put = alc260_hp_master_sw_put,
5646 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5647 },
5648 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5649 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5650 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5651 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5652 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5653 HDA_OUTPUT),
5654 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5655 { } /* end */
5656};
5657
5658static struct hda_verb alc260_hp_unsol_verbs[] = {
5659 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5660 {},
5661};
5662
5663static void alc260_hp_automute(struct hda_codec *codec)
5664{
5665 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005666
Wu Fengguang864f92b2009-11-18 12:38:02 +08005667 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005668 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5669}
5670
5671static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5672{
5673 if ((res >> 26) == ALC880_HP_EVENT)
5674 alc260_hp_automute(codec);
5675}
5676
Kailang Yangdf694da2005-12-05 19:42:22 +01005677static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005678 {
5679 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5680 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005681 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005682 .info = snd_ctl_boolean_mono_info,
5683 .get = alc260_hp_master_sw_get,
5684 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005685 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005686 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005687 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5688 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5689 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5690 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5691 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5692 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005693 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5694 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005695 { } /* end */
5696};
5697
Kailang Yang3f878302008-08-26 13:02:23 +02005698static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5699 .ops = &snd_hda_bind_vol,
5700 .values = {
5701 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5702 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5703 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5704 0
5705 },
5706};
5707
5708static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5709 .ops = &snd_hda_bind_sw,
5710 .values = {
5711 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5712 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5713 0
5714 },
5715};
5716
5717static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5718 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5719 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5720 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5722 { } /* end */
5723};
5724
Takashi Iwaibec15c32008-01-28 18:16:30 +01005725static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5726 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5727 {},
5728};
5729
5730static void alc260_hp_3013_automute(struct hda_codec *codec)
5731{
5732 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005733
Wu Fengguang864f92b2009-11-18 12:38:02 +08005734 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005735 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005736}
5737
5738static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5739 unsigned int res)
5740{
5741 if ((res >> 26) == ALC880_HP_EVENT)
5742 alc260_hp_3013_automute(codec);
5743}
5744
Kailang Yang3f878302008-08-26 13:02:23 +02005745static void alc260_hp_3012_automute(struct hda_codec *codec)
5746{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005747 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005748
Kailang Yang3f878302008-08-26 13:02:23 +02005749 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5750 bits);
5751 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5752 bits);
5753 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5754 bits);
5755}
5756
5757static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5758 unsigned int res)
5759{
5760 if ((res >> 26) == ALC880_HP_EVENT)
5761 alc260_hp_3012_automute(codec);
5762}
5763
5764/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005765 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5766 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005767static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005768 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005769 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005770 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005771 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5772 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5773 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5774 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005775 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005776 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5777 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005778 { } /* end */
5779};
5780
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005781/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5782 * versions of the ALC260 don't act on requests to enable mic bias from NID
5783 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5784 * datasheet doesn't mention this restriction. At this stage it's not clear
5785 * whether this behaviour is intentional or is a hardware bug in chip
5786 * revisions available in early 2006. Therefore for now allow the
5787 * "Headphone Jack Mode" control to span all choices, but if it turns out
5788 * that the lack of mic bias for this NID is intentional we could change the
5789 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5790 *
5791 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5792 * don't appear to make the mic bias available from the "line" jack, even
5793 * though the NID used for this jack (0x14) can supply it. The theory is
5794 * that perhaps Acer have included blocking capacitors between the ALC260
5795 * and the output jack. If this turns out to be the case for all such
5796 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5797 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005798 *
5799 * The C20x Tablet series have a mono internal speaker which is controlled
5800 * via the chip's Mono sum widget and pin complex, so include the necessary
5801 * controls for such models. On models without a "mono speaker" the control
5802 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005804static struct snd_kcontrol_new alc260_acer_mixer[] = {
5805 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5806 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005807 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005808 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005809 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005810 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005811 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005812 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5813 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5814 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5815 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5816 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5817 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5818 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5819 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005820 { } /* end */
5821};
5822
Michael Schwingencc959482009-02-22 18:58:45 +01005823/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5824 */
5825static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5826 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5827 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5828 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5829 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5830 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5831 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5832 { } /* end */
5833};
5834
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005835/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5836 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5837 */
5838static struct snd_kcontrol_new alc260_will_mixer[] = {
5839 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5840 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5842 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5843 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5844 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5845 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5846 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5847 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5848 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005849 { } /* end */
5850};
5851
5852/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5853 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5854 */
5855static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5856 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5857 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5859 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5860 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5861 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5862 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5863 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5864 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5865 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5866 { } /* end */
5867};
5868
Kailang Yangdf694da2005-12-05 19:42:22 +01005869/*
5870 * initialization verbs
5871 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005872static struct hda_verb alc260_init_verbs[] = {
5873 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005874 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005875 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005877 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005878 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005879 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005880 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005881 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005883 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005884 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005885 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005886 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005887 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005888 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005889 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005890 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5891 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005892 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005893 /* set connection select to line in (default select for this ADC) */
5894 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005895 /* mute capture amp left and right */
5896 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5897 /* set connection select to line in (default select for this ADC) */
5898 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005899 /* set vol=0 Line-Out mixer amp left and right */
5900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5901 /* unmute pin widget amp left and right (no gain on this amp) */
5902 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5903 /* set vol=0 HP mixer amp left and right */
5904 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5905 /* unmute pin widget amp left and right (no gain on this amp) */
5906 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5907 /* set vol=0 Mono mixer amp left and right */
5908 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5909 /* unmute pin widget amp left and right (no gain on this amp) */
5910 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5911 /* unmute LINE-2 out pin */
5912 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005913 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5914 * Line In 2 = 0x03
5915 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005916 /* mute analog inputs */
5917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005922 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005923 /* mute Front out path */
5924 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5925 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5926 /* mute Headphone out path */
5927 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5928 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5929 /* mute Mono out path */
5930 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5931 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005932 { }
5933};
5934
Takashi Iwai474167d2006-05-17 17:17:43 +02005935#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005936static struct hda_verb alc260_hp_init_verbs[] = {
5937 /* Headphone and output */
5938 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5939 /* mono output */
5940 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5941 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5942 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5943 /* Mic2 (front panel) pin widget for input and vref at 80% */
5944 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5945 /* Line In pin widget for input */
5946 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5947 /* Line-2 pin widget for output */
5948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5949 /* CD pin widget for input */
5950 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5951 /* unmute amp left and right */
5952 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5953 /* set connection select to line in (default select for this ADC) */
5954 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5955 /* unmute Line-Out mixer amp left and right (volume = 0) */
5956 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5957 /* mute pin widget amp left and right (no gain on this amp) */
5958 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5959 /* unmute HP mixer amp left and right (volume = 0) */
5960 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5961 /* mute pin widget amp left and right (no gain on this amp) */
5962 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005963 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5964 * Line In 2 = 0x03
5965 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005966 /* mute analog inputs */
5967 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5969 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5970 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5971 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005972 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5973 /* Unmute Front out path */
5974 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5976 /* Unmute Headphone out path */
5977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5978 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5979 /* Unmute Mono out path */
5980 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5981 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5982 { }
5983};
Takashi Iwai474167d2006-05-17 17:17:43 +02005984#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005985
5986static struct hda_verb alc260_hp_3013_init_verbs[] = {
5987 /* Line out and output */
5988 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5989 /* mono output */
5990 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5991 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5992 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5993 /* Mic2 (front panel) pin widget for input and vref at 80% */
5994 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5995 /* Line In pin widget for input */
5996 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5997 /* Headphone pin widget for output */
5998 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5999 /* CD pin widget for input */
6000 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6001 /* unmute amp left and right */
6002 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6003 /* set connection select to line in (default select for this ADC) */
6004 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6005 /* unmute Line-Out mixer amp left and right (volume = 0) */
6006 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6007 /* mute pin widget amp left and right (no gain on this amp) */
6008 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6009 /* unmute HP mixer amp left and right (volume = 0) */
6010 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6011 /* mute pin widget amp left and right (no gain on this amp) */
6012 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006013 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6014 * Line In 2 = 0x03
6015 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006016 /* mute analog inputs */
6017 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6018 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6019 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6020 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6021 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006022 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6023 /* Unmute Front out path */
6024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6025 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6026 /* Unmute Headphone out path */
6027 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6028 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6029 /* Unmute Mono out path */
6030 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6031 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6032 { }
6033};
6034
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006035/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006036 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6037 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006038 */
6039static struct hda_verb alc260_fujitsu_init_verbs[] = {
6040 /* Disable all GPIOs */
6041 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6042 /* Internal speaker is connected to headphone pin */
6043 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6044 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6045 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006046 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6047 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6048 /* Ensure all other unused pins are disabled and muted. */
6049 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6050 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006051 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006052 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006053 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006054 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6055 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006057
Jonathan Woithef7ace402006-02-28 11:46:14 +01006058 /* Disable digital (SPDIF) pins */
6059 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6060 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006061
Kailang Yangea1fb292008-08-26 12:58:38 +02006062 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006063 * when acting as an output.
6064 */
6065 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6066
6067 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6069 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6071 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6074 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6075 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6076 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006077
Jonathan Woithef7ace402006-02-28 11:46:14 +01006078 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6079 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6080 /* Unmute Line1 pin widget output buffer since it starts as an output.
6081 * If the pin mode is changed by the user the pin mode control will
6082 * take care of enabling the pin's input/output buffers as needed.
6083 * Therefore there's no need to enable the input buffer at this
6084 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006085 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006086 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006087 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006088 * mixer ctrl)
6089 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006090 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006091
Jonathan Woithef7ace402006-02-28 11:46:14 +01006092 /* Mute capture amp left and right */
6093 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006094 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006095 * in (on mic1 pin)
6096 */
6097 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006098
Jonathan Woithef7ace402006-02-28 11:46:14 +01006099 /* Do the same for the second ADC: mute capture input amp and
6100 * set ADC connection to line in (on mic1 pin)
6101 */
6102 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6103 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006104
Jonathan Woithef7ace402006-02-28 11:46:14 +01006105 /* Mute all inputs to mixer widget (even unconnected ones) */
6106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6111 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6112 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6113 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006114
6115 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006116};
6117
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006118/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6119 * similar laptops (adapted from Fujitsu init verbs).
6120 */
6121static struct hda_verb alc260_acer_init_verbs[] = {
6122 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6123 * the headphone jack. Turn this on and rely on the standard mute
6124 * methods whenever the user wants to turn these outputs off.
6125 */
6126 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6127 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6128 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6129 /* Internal speaker/Headphone jack is connected to Line-out pin */
6130 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6131 /* Internal microphone/Mic jack is connected to Mic1 pin */
6132 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6133 /* Line In jack is connected to Line1 pin */
6134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006135 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6136 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006137 /* Ensure all other unused pins are disabled and muted. */
6138 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6139 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006140 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6141 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6144 /* Disable digital (SPDIF) pins */
6145 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6146 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6147
Kailang Yangea1fb292008-08-26 12:58:38 +02006148 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006149 * bus when acting as outputs.
6150 */
6151 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6152 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6153
6154 /* Start with output sum widgets muted and their output gains at min */
6155 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6156 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6157 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6158 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6159 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6160 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6161 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6162 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6163 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6164
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006165 /* Unmute Line-out pin widget amp left and right
6166 * (no equiv mixer ctrl)
6167 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006169 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6170 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006171 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6172 * inputs. If the pin mode is changed by the user the pin mode control
6173 * will take care of enabling the pin's input/output buffers as needed.
6174 * Therefore there's no need to enable the input buffer at this
6175 * stage.
6176 */
6177 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6178 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6179
6180 /* Mute capture amp left and right */
6181 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6182 /* Set ADC connection select to match default mixer setting - mic
6183 * (on mic1 pin)
6184 */
6185 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6186
6187 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006188 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006189 */
6190 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006191 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006192
6193 /* Mute all inputs to mixer widget (even unconnected ones) */
6194 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6195 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6196 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6199 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6200 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6201 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6202
6203 { }
6204};
6205
Michael Schwingencc959482009-02-22 18:58:45 +01006206/* Initialisation sequence for Maxdata Favorit 100XS
6207 * (adapted from Acer init verbs).
6208 */
6209static struct hda_verb alc260_favorit100_init_verbs[] = {
6210 /* GPIO 0 enables the output jack.
6211 * Turn this on and rely on the standard mute
6212 * methods whenever the user wants to turn these outputs off.
6213 */
6214 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6215 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6216 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6217 /* Line/Mic input jack is connected to Mic1 pin */
6218 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6219 /* Ensure all other unused pins are disabled and muted. */
6220 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6221 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6222 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6223 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6224 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6225 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6226 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6228 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6229 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6230 /* Disable digital (SPDIF) pins */
6231 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6232 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6233
6234 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6235 * bus when acting as outputs.
6236 */
6237 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6238 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6239
6240 /* Start with output sum widgets muted and their output gains at min */
6241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6243 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6246 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6247 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6248 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6249 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6250
6251 /* Unmute Line-out pin widget amp left and right
6252 * (no equiv mixer ctrl)
6253 */
6254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6255 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6256 * inputs. If the pin mode is changed by the user the pin mode control
6257 * will take care of enabling the pin's input/output buffers as needed.
6258 * Therefore there's no need to enable the input buffer at this
6259 * stage.
6260 */
6261 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6262
6263 /* Mute capture amp left and right */
6264 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6265 /* Set ADC connection select to match default mixer setting - mic
6266 * (on mic1 pin)
6267 */
6268 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6269
6270 /* Do similar with the second ADC: mute capture input amp and
6271 * set ADC connection to mic to match ALSA's default state.
6272 */
6273 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6274 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6275
6276 /* Mute all inputs to mixer widget (even unconnected ones) */
6277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6278 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6279 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6280 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6281 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6282 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6285
6286 { }
6287};
6288
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006289static struct hda_verb alc260_will_verbs[] = {
6290 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6291 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6292 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6293 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6294 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6295 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6296 {}
6297};
6298
6299static struct hda_verb alc260_replacer_672v_verbs[] = {
6300 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6301 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6302 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6303
6304 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6305 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6306 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6307
6308 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6309 {}
6310};
6311
6312/* toggle speaker-output according to the hp-jack state */
6313static void alc260_replacer_672v_automute(struct hda_codec *codec)
6314{
6315 unsigned int present;
6316
6317 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006318 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006319 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006320 snd_hda_codec_write_cache(codec, 0x01, 0,
6321 AC_VERB_SET_GPIO_DATA, 1);
6322 snd_hda_codec_write_cache(codec, 0x0f, 0,
6323 AC_VERB_SET_PIN_WIDGET_CONTROL,
6324 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006325 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006326 snd_hda_codec_write_cache(codec, 0x01, 0,
6327 AC_VERB_SET_GPIO_DATA, 0);
6328 snd_hda_codec_write_cache(codec, 0x0f, 0,
6329 AC_VERB_SET_PIN_WIDGET_CONTROL,
6330 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006331 }
6332}
6333
6334static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6335 unsigned int res)
6336{
6337 if ((res >> 26) == ALC880_HP_EVENT)
6338 alc260_replacer_672v_automute(codec);
6339}
6340
Kailang Yang3f878302008-08-26 13:02:23 +02006341static struct hda_verb alc260_hp_dc7600_verbs[] = {
6342 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6344 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6345 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6346 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6348 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6349 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6350 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6351 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6352 {}
6353};
6354
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006355/* Test configuration for debugging, modelled after the ALC880 test
6356 * configuration.
6357 */
6358#ifdef CONFIG_SND_DEBUG
6359static hda_nid_t alc260_test_dac_nids[1] = {
6360 0x02,
6361};
6362static hda_nid_t alc260_test_adc_nids[2] = {
6363 0x04, 0x05,
6364};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006365/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006366 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006367 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006368 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006369static struct hda_input_mux alc260_test_capture_sources[2] = {
6370 {
6371 .num_items = 7,
6372 .items = {
6373 { "MIC1 pin", 0x0 },
6374 { "MIC2 pin", 0x1 },
6375 { "LINE1 pin", 0x2 },
6376 { "LINE2 pin", 0x3 },
6377 { "CD pin", 0x4 },
6378 { "LINE-OUT pin", 0x5 },
6379 { "HP-OUT pin", 0x6 },
6380 },
6381 },
6382 {
6383 .num_items = 8,
6384 .items = {
6385 { "MIC1 pin", 0x0 },
6386 { "MIC2 pin", 0x1 },
6387 { "LINE1 pin", 0x2 },
6388 { "LINE2 pin", 0x3 },
6389 { "CD pin", 0x4 },
6390 { "Mixer", 0x5 },
6391 { "LINE-OUT pin", 0x6 },
6392 { "HP-OUT pin", 0x7 },
6393 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006394 },
6395};
6396static struct snd_kcontrol_new alc260_test_mixer[] = {
6397 /* Output driver widgets */
6398 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6399 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6400 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6401 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6402 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6403 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6404
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006405 /* Modes for retasking pin widgets
6406 * Note: the ALC260 doesn't seem to act on requests to enable mic
6407 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6408 * mention this restriction. At this stage it's not clear whether
6409 * this behaviour is intentional or is a hardware bug in chip
6410 * revisions available at least up until early 2006. Therefore for
6411 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6412 * choices, but if it turns out that the lack of mic bias for these
6413 * NIDs is intentional we could change their modes from
6414 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6415 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006416 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6417 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6418 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6419 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6420 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6421 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6422
6423 /* Loopback mixer controls */
6424 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6425 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6426 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6427 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6428 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6429 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6430 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6431 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6432 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6433 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006434 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6435 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6436 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6437 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006438
6439 /* Controls for GPIO pins, assuming they are configured as outputs */
6440 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6441 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6442 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6443 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6444
Jonathan Woithe92621f12006-02-28 11:47:47 +01006445 /* Switches to allow the digital IO pins to be enabled. The datasheet
6446 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006447 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006448 */
6449 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6450 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6451
Jonathan Woithef8225f62008-01-08 12:16:54 +01006452 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6453 * this output to turn on an external amplifier.
6454 */
6455 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6456 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6457
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006458 { } /* end */
6459};
6460static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006461 /* Enable all GPIOs as outputs with an initial value of 0 */
6462 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6463 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6464 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6465
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006466 /* Enable retasking pins as output, initially without power amp */
6467 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6468 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6470 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6471 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6472 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6473
Jonathan Woithe92621f12006-02-28 11:47:47 +01006474 /* Disable digital (SPDIF) pins initially, but users can enable
6475 * them via a mixer switch. In the case of SPDIF-out, this initverb
6476 * payload also sets the generation to 0, output to be in "consumer"
6477 * PCM format, copyright asserted, no pre-emphasis and no validity
6478 * control.
6479 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006480 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6481 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6482
Kailang Yangea1fb292008-08-26 12:58:38 +02006483 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006484 * OUT1 sum bus when acting as an output.
6485 */
6486 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6487 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6488 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6489 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6490
6491 /* Start with output sum widgets muted and their output gains at min */
6492 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6493 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6494 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6495 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6496 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6497 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6498 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6499 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6500 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6501
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006502 /* Unmute retasking pin widget output buffers since the default
6503 * state appears to be output. As the pin mode is changed by the
6504 * user the pin mode control will take care of enabling the pin's
6505 * input/output buffers as needed.
6506 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006507 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6508 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6510 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6511 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6512 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6513 /* Also unmute the mono-out pin widget */
6514 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6515
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006516 /* Mute capture amp left and right */
6517 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006518 /* Set ADC connection select to match default mixer setting (mic1
6519 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006520 */
6521 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6522
6523 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006524 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006525 */
6526 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6527 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6528
6529 /* Mute all inputs to mixer widget (even unconnected ones) */
6530 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6532 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6533 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6534 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6535 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6537 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6538
6539 { }
6540};
6541#endif
6542
Takashi Iwai63300792008-01-24 15:31:36 +01006543#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6544#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006545
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006546#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6547#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6548
Kailang Yangdf694da2005-12-05 19:42:22 +01006549/*
6550 * for BIOS auto-configuration
6551 */
6552
6553static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006554 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006555{
6556 hda_nid_t nid_vol;
6557 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006558 int err;
6559
6560 if (nid >= 0x0f && nid < 0x11) {
6561 nid_vol = nid - 0x7;
6562 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6563 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6564 } else if (nid == 0x11) {
6565 nid_vol = nid - 0x7;
6566 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6567 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6568 } else if (nid >= 0x12 && nid <= 0x15) {
6569 nid_vol = 0x08;
6570 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6571 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6572 } else
6573 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006574
Takashi Iwai863b4512008-10-21 17:01:47 +02006575 if (!(*vol_bits & (1 << nid_vol))) {
6576 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006577 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006578 if (err < 0)
6579 return err;
6580 *vol_bits |= (1 << nid_vol);
6581 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006582 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006583 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006584 return err;
6585 return 1;
6586}
6587
6588/* add playback controls from the parsed DAC table */
6589static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6590 const struct auto_pin_cfg *cfg)
6591{
6592 hda_nid_t nid;
6593 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006594 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006595
6596 spec->multiout.num_dacs = 1;
6597 spec->multiout.dac_nids = spec->private_dac_nids;
6598 spec->multiout.dac_nids[0] = 0x02;
6599
6600 nid = cfg->line_out_pins[0];
6601 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006602 const char *pfx;
6603 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6604 pfx = "Master";
6605 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6606 pfx = "Speaker";
6607 else
6608 pfx = "Front";
6609 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006610 if (err < 0)
6611 return err;
6612 }
6613
Takashi Iwai82bc9552006-03-21 11:24:42 +01006614 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006615 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006616 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006617 if (err < 0)
6618 return err;
6619 }
6620
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006621 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006622 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006623 err = alc260_add_playback_controls(spec, nid, "Headphone",
6624 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006625 if (err < 0)
6626 return err;
6627 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006628 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006629}
6630
6631/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006632static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006633 const struct auto_pin_cfg *cfg)
6634{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006635 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006636}
6637
6638static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6639 hda_nid_t nid, int pin_type,
6640 int sel_idx)
6641{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006642 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006643 /* need the manual connection? */
6644 if (nid >= 0x12) {
6645 int idx = nid - 0x12;
6646 snd_hda_codec_write(codec, idx + 0x0b, 0,
6647 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006648 }
6649}
6650
6651static void alc260_auto_init_multi_out(struct hda_codec *codec)
6652{
6653 struct alc_spec *spec = codec->spec;
6654 hda_nid_t nid;
6655
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006656 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006657 if (nid) {
6658 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6659 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6660 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006661
Takashi Iwai82bc9552006-03-21 11:24:42 +01006662 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006663 if (nid)
6664 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6665
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006666 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006667 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006668 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006669}
Kailang Yangdf694da2005-12-05 19:42:22 +01006670
6671#define ALC260_PIN_CD_NID 0x16
6672static void alc260_auto_init_analog_input(struct hda_codec *codec)
6673{
6674 struct alc_spec *spec = codec->spec;
6675 int i;
6676
6677 for (i = 0; i < AUTO_PIN_LAST; i++) {
6678 hda_nid_t nid = spec->autocfg.input_pins[i];
6679 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006680 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006681 if (nid != ALC260_PIN_CD_NID &&
6682 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006683 snd_hda_codec_write(codec, nid, 0,
6684 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006685 AMP_OUT_MUTE);
6686 }
6687 }
6688}
6689
Takashi Iwai7f311a42010-04-09 17:32:23 +02006690#define alc260_auto_init_input_src alc880_auto_init_input_src
6691
Kailang Yangdf694da2005-12-05 19:42:22 +01006692/*
6693 * generic initialization of ADC, input mixers and output mixers
6694 */
6695static struct hda_verb alc260_volume_init_verbs[] = {
6696 /*
6697 * Unmute ADC0-1 and set the default input to mic-in
6698 */
6699 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6700 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6701 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6702 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006703
Kailang Yangdf694da2005-12-05 19:42:22 +01006704 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6705 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006706 * Note: PASD motherboards uses the Line In 2 as the input for
6707 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006708 */
6709 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006710 /* mute analog inputs */
6711 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6712 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6714 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006716
6717 /*
6718 * Set up output mixers (0x08 - 0x0a)
6719 */
6720 /* set vol=0 to output mixers */
6721 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6722 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6723 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6724 /* set up input amps for analog loopback */
6725 /* Amp Indices: DAC = 0, mixer = 1 */
6726 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6728 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6730 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6731 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006732
Kailang Yangdf694da2005-12-05 19:42:22 +01006733 { }
6734};
6735
6736static int alc260_parse_auto_config(struct hda_codec *codec)
6737{
6738 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006739 int err;
6740 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6741
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006742 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6743 alc260_ignore);
6744 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006745 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006746 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6747 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006748 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006749 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006750 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006751 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006752 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006753 return err;
6754
6755 spec->multiout.max_channels = 2;
6756
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006757 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006758 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006759 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006760 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006761
Takashi Iwaid88897e2008-10-31 15:01:37 +01006762 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006763
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006764 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006765 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006766
Kailang Yang6227cdc2010-02-25 08:36:52 +01006767 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006768
Kailang Yangdf694da2005-12-05 19:42:22 +01006769 return 1;
6770}
6771
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006772/* additional initialization for auto-configuration model */
6773static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006774{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006775 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006776 alc260_auto_init_multi_out(codec);
6777 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006778 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006779 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006780 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006781 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006782}
6783
Takashi Iwaicb53c622007-08-10 17:21:45 +02006784#ifdef CONFIG_SND_HDA_POWER_SAVE
6785static struct hda_amp_list alc260_loopbacks[] = {
6786 { 0x07, HDA_INPUT, 0 },
6787 { 0x07, HDA_INPUT, 1 },
6788 { 0x07, HDA_INPUT, 2 },
6789 { 0x07, HDA_INPUT, 3 },
6790 { 0x07, HDA_INPUT, 4 },
6791 { } /* end */
6792};
6793#endif
6794
Kailang Yangdf694da2005-12-05 19:42:22 +01006795/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006796 * Pin config fixes
6797 */
6798enum {
6799 PINFIX_HP_DC5750,
6800};
6801
Takashi Iwaifc091762010-08-04 23:53:36 +02006802static const struct alc_fixup alc260_fixups[] = {
6803 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006804 .pins = (const struct alc_pincfg[]) {
6805 { 0x11, 0x90130110 }, /* speaker */
6806 { }
6807 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006808 },
6809};
6810
6811static struct snd_pci_quirk alc260_fixup_tbl[] = {
6812 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6813 {}
6814};
6815
6816/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006817 * ALC260 configurations
6818 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006819static const char *alc260_models[ALC260_MODEL_LAST] = {
6820 [ALC260_BASIC] = "basic",
6821 [ALC260_HP] = "hp",
6822 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006823 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006824 [ALC260_FUJITSU_S702X] = "fujitsu",
6825 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006826 [ALC260_WILL] = "will",
6827 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006828 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006829#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006830 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006831#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006832 [ALC260_AUTO] = "auto",
6833};
6834
6835static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006836 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006837 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006838 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006839 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006840 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006841 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006842 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006843 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006844 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006845 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6846 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6847 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6848 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6849 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6850 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6851 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6852 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6853 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006854 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006855 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006856 {}
6857};
6858
Kailang Yangdf694da2005-12-05 19:42:22 +01006859static struct alc_config_preset alc260_presets[] = {
6860 [ALC260_BASIC] = {
6861 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006862 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006863 .init_verbs = { alc260_init_verbs },
6864 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6865 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006866 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006867 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006868 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6869 .channel_mode = alc260_modes,
6870 .input_mux = &alc260_capture_source,
6871 },
6872 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006873 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006874 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006875 .init_verbs = { alc260_init_verbs,
6876 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006877 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6878 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006879 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6880 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006881 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6882 .channel_mode = alc260_modes,
6883 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006884 .unsol_event = alc260_hp_unsol_event,
6885 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006886 },
Kailang Yang3f878302008-08-26 13:02:23 +02006887 [ALC260_HP_DC7600] = {
6888 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006889 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006890 .init_verbs = { alc260_init_verbs,
6891 alc260_hp_dc7600_verbs },
6892 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6893 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006894 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6895 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006896 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6897 .channel_mode = alc260_modes,
6898 .input_mux = &alc260_capture_source,
6899 .unsol_event = alc260_hp_3012_unsol_event,
6900 .init_hook = alc260_hp_3012_automute,
6901 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006902 [ALC260_HP_3013] = {
6903 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006904 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006905 .init_verbs = { alc260_hp_3013_init_verbs,
6906 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006907 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6908 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006909 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6910 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006911 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6912 .channel_mode = alc260_modes,
6913 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006914 .unsol_event = alc260_hp_3013_unsol_event,
6915 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006916 },
6917 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006918 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 .init_verbs = { alc260_fujitsu_init_verbs },
6920 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6921 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006922 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6923 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6925 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006926 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6927 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006928 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006929 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006930 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006931 .init_verbs = { alc260_acer_init_verbs },
6932 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6933 .dac_nids = alc260_dac_nids,
6934 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6935 .adc_nids = alc260_dual_adc_nids,
6936 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6937 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006938 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6939 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006940 },
Michael Schwingencc959482009-02-22 18:58:45 +01006941 [ALC260_FAVORIT100] = {
6942 .mixers = { alc260_favorit100_mixer },
6943 .init_verbs = { alc260_favorit100_init_verbs },
6944 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6945 .dac_nids = alc260_dac_nids,
6946 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6947 .adc_nids = alc260_dual_adc_nids,
6948 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6949 .channel_mode = alc260_modes,
6950 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6951 .input_mux = alc260_favorit100_capture_sources,
6952 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006953 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006954 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006955 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6956 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6957 .dac_nids = alc260_dac_nids,
6958 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6959 .adc_nids = alc260_adc_nids,
6960 .dig_out_nid = ALC260_DIGOUT_NID,
6961 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6962 .channel_mode = alc260_modes,
6963 .input_mux = &alc260_capture_source,
6964 },
6965 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006966 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006967 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6968 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6969 .dac_nids = alc260_dac_nids,
6970 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6971 .adc_nids = alc260_adc_nids,
6972 .dig_out_nid = ALC260_DIGOUT_NID,
6973 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6974 .channel_mode = alc260_modes,
6975 .input_mux = &alc260_capture_source,
6976 .unsol_event = alc260_replacer_672v_unsol_event,
6977 .init_hook = alc260_replacer_672v_automute,
6978 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006979#ifdef CONFIG_SND_DEBUG
6980 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006981 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006982 .init_verbs = { alc260_test_init_verbs },
6983 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6984 .dac_nids = alc260_test_dac_nids,
6985 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6986 .adc_nids = alc260_test_adc_nids,
6987 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6988 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006989 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6990 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006991 },
6992#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006993};
6994
Linus Torvalds1da177e2005-04-16 15:20:36 -07006995static int patch_alc260(struct hda_codec *codec)
6996{
6997 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006998 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006999
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007000 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007001 if (spec == NULL)
7002 return -ENOMEM;
7003
7004 codec->spec = spec;
7005
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007006 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7007 alc260_models,
7008 alc260_cfg_tbl);
7009 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007010 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007011 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007012 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007013 }
7014
Takashi Iwaifc091762010-08-04 23:53:36 +02007015 if (board_config == ALC260_AUTO)
7016 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7017
Kailang Yangdf694da2005-12-05 19:42:22 +01007018 if (board_config == ALC260_AUTO) {
7019 /* automatic parse from the BIOS config */
7020 err = alc260_parse_auto_config(codec);
7021 if (err < 0) {
7022 alc_free(codec);
7023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007024 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007025 printk(KERN_INFO
7026 "hda_codec: Cannot set up configuration "
7027 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007028 board_config = ALC260_BASIC;
7029 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007030 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007031
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007032 err = snd_hda_attach_beep_device(codec, 0x1);
7033 if (err < 0) {
7034 alc_free(codec);
7035 return err;
7036 }
7037
Kailang Yangdf694da2005-12-05 19:42:22 +01007038 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007039 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007040
Linus Torvalds1da177e2005-04-16 15:20:36 -07007041 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7042 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307043 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007044
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007045 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7046 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7047
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007048 if (!spec->adc_nids && spec->input_mux) {
7049 /* check whether NID 0x04 is valid */
7050 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007051 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007052 /* get type */
7053 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7054 spec->adc_nids = alc260_adc_nids_alt;
7055 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7056 } else {
7057 spec->adc_nids = alc260_adc_nids;
7058 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7059 }
7060 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007061 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007062 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007063
Takashi Iwaifc091762010-08-04 23:53:36 +02007064 if (board_config == ALC260_AUTO)
7065 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7066
Takashi Iwai2134ea42008-01-10 16:53:55 +01007067 spec->vmaster_nid = 0x08;
7068
Linus Torvalds1da177e2005-04-16 15:20:36 -07007069 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007070 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007071 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007072#ifdef CONFIG_SND_HDA_POWER_SAVE
7073 if (!spec->loopback.amplist)
7074 spec->loopback.amplist = alc260_loopbacks;
7075#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007076
7077 return 0;
7078}
7079
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007080
Linus Torvalds1da177e2005-04-16 15:20:36 -07007081/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007082 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007083 *
7084 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7085 * configuration. Each pin widget can choose any input DACs and a mixer.
7086 * Each ADC is connected from a mixer of all inputs. This makes possible
7087 * 6-channel independent captures.
7088 *
7089 * In addition, an independent DAC for the multi-playback (not used in this
7090 * driver yet).
7091 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007092#define ALC882_DIGOUT_NID 0x06
7093#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007094#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7095#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7096#define ALC1200_DIGOUT_NID 0x10
7097
Linus Torvalds1da177e2005-04-16 15:20:36 -07007098
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007099static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007100 { 8, NULL }
7101};
7102
Takashi Iwai4953550a2009-06-30 15:28:30 +02007103/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007104static hda_nid_t alc882_dac_nids[4] = {
7105 /* front, rear, clfe, rear_surr */
7106 0x02, 0x03, 0x04, 0x05
7107};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007108#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007109
Takashi Iwai4953550a2009-06-30 15:28:30 +02007110/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007111#define alc882_adc_nids alc880_adc_nids
7112#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007113#define alc883_adc_nids alc882_adc_nids_alt
7114static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7115static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7116#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007117
Takashi Iwaie1406342008-02-11 18:32:32 +01007118static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7119static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007120#define alc883_capsrc_nids alc882_capsrc_nids_alt
7121static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7122#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007123
Linus Torvalds1da177e2005-04-16 15:20:36 -07007124/* input MUX */
7125/* FIXME: should be a matrix-type input source selection */
7126
7127static struct hda_input_mux alc882_capture_source = {
7128 .num_items = 4,
7129 .items = {
7130 { "Mic", 0x0 },
7131 { "Front Mic", 0x1 },
7132 { "Line", 0x2 },
7133 { "CD", 0x4 },
7134 },
7135};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007136
Takashi Iwai4953550a2009-06-30 15:28:30 +02007137#define alc883_capture_source alc882_capture_source
7138
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007139static struct hda_input_mux alc889_capture_source = {
7140 .num_items = 3,
7141 .items = {
7142 { "Front Mic", 0x0 },
7143 { "Mic", 0x3 },
7144 { "Line", 0x2 },
7145 },
7146};
7147
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007148static struct hda_input_mux mb5_capture_source = {
7149 .num_items = 3,
7150 .items = {
7151 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307152 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007153 { "CD", 0x4 },
7154 },
7155};
7156
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007157static struct hda_input_mux macmini3_capture_source = {
7158 .num_items = 2,
7159 .items = {
7160 { "Line", 0x2 },
7161 { "CD", 0x4 },
7162 },
7163};
7164
Takashi Iwai4953550a2009-06-30 15:28:30 +02007165static struct hda_input_mux alc883_3stack_6ch_intel = {
7166 .num_items = 4,
7167 .items = {
7168 { "Mic", 0x1 },
7169 { "Front Mic", 0x0 },
7170 { "Line", 0x2 },
7171 { "CD", 0x4 },
7172 },
7173};
7174
7175static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7176 .num_items = 2,
7177 .items = {
7178 { "Mic", 0x1 },
7179 { "Line", 0x2 },
7180 },
7181};
7182
7183static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7184 .num_items = 4,
7185 .items = {
7186 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007187 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007188 { "Line", 0x2 },
7189 { "CD", 0x4 },
7190 },
7191};
7192
7193static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7194 .num_items = 2,
7195 .items = {
7196 { "Mic", 0x0 },
7197 { "Int Mic", 0x1 },
7198 },
7199};
7200
7201static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7202 .num_items = 3,
7203 .items = {
7204 { "Mic", 0x0 },
7205 { "Front Mic", 0x1 },
7206 { "Line", 0x4 },
7207 },
7208};
7209
7210static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7211 .num_items = 2,
7212 .items = {
7213 { "Mic", 0x0 },
7214 { "Line", 0x2 },
7215 },
7216};
7217
7218static struct hda_input_mux alc889A_mb31_capture_source = {
7219 .num_items = 2,
7220 .items = {
7221 { "Mic", 0x0 },
7222 /* Front Mic (0x01) unused */
7223 { "Line", 0x2 },
7224 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007225 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007226 },
7227};
7228
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007229static struct hda_input_mux alc889A_imac91_capture_source = {
7230 .num_items = 2,
7231 .items = {
7232 { "Mic", 0x01 },
7233 { "Line", 0x2 }, /* Not sure! */
7234 },
7235};
7236
Takashi Iwai4953550a2009-06-30 15:28:30 +02007237/*
7238 * 2ch mode
7239 */
7240static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7241 { 2, NULL }
7242};
7243
Kailang Yangdf694da2005-12-05 19:42:22 +01007244/*
Kailang Yang272a5272007-05-14 11:00:38 +02007245 * 2ch mode
7246 */
7247static struct hda_verb alc882_3ST_ch2_init[] = {
7248 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7249 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7250 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7251 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7252 { } /* end */
7253};
7254
7255/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007256 * 4ch mode
7257 */
7258static struct hda_verb alc882_3ST_ch4_init[] = {
7259 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7260 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7261 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7262 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7263 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7264 { } /* end */
7265};
7266
7267/*
Kailang Yang272a5272007-05-14 11:00:38 +02007268 * 6ch mode
7269 */
7270static struct hda_verb alc882_3ST_ch6_init[] = {
7271 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7272 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7273 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7274 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7275 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7276 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7277 { } /* end */
7278};
7279
Takashi Iwai4953550a2009-06-30 15:28:30 +02007280static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007281 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007282 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007283 { 6, alc882_3ST_ch6_init },
7284};
7285
Takashi Iwai4953550a2009-06-30 15:28:30 +02007286#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7287
Kailang Yang272a5272007-05-14 11:00:38 +02007288/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307289 * 2ch mode
7290 */
7291static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7292 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7293 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7294 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7295 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7296 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7297 { } /* end */
7298};
7299
7300/*
7301 * 4ch mode
7302 */
7303static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7304 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7305 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7306 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7307 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7308 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7309 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7310 { } /* end */
7311};
7312
7313/*
7314 * 6ch mode
7315 */
7316static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7317 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7318 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7319 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7320 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7321 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7322 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7323 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7324 { } /* end */
7325};
7326
7327static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7328 { 2, alc883_3ST_ch2_clevo_init },
7329 { 4, alc883_3ST_ch4_clevo_init },
7330 { 6, alc883_3ST_ch6_clevo_init },
7331};
7332
7333
7334/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007335 * 6ch mode
7336 */
7337static struct hda_verb alc882_sixstack_ch6_init[] = {
7338 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7339 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7340 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7341 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7342 { } /* end */
7343};
7344
7345/*
7346 * 8ch mode
7347 */
7348static struct hda_verb alc882_sixstack_ch8_init[] = {
7349 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7350 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7351 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7352 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7353 { } /* end */
7354};
7355
7356static struct hda_channel_mode alc882_sixstack_modes[2] = {
7357 { 6, alc882_sixstack_ch6_init },
7358 { 8, alc882_sixstack_ch8_init },
7359};
7360
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007361
7362/* Macbook Air 2,1 */
7363
7364static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7365 { 2, NULL },
7366};
7367
Takashi Iwai87350ad2007-08-16 18:19:38 +02007368/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007369 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007370 */
7371
7372/*
7373 * 2ch mode
7374 */
7375static struct hda_verb alc885_mbp_ch2_init[] = {
7376 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7377 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7378 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7379 { } /* end */
7380};
7381
7382/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007383 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007384 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007385static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007386 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7387 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7388 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7389 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7390 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7391 { } /* end */
7392};
7393
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007394static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007395 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007396 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007397};
7398
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007399/*
7400 * 2ch
7401 * Speakers/Woofer/HP = Front
7402 * LineIn = Input
7403 */
7404static struct hda_verb alc885_mb5_ch2_init[] = {
7405 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7406 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7407 { } /* end */
7408};
7409
7410/*
7411 * 6ch mode
7412 * Speakers/HP = Front
7413 * Woofer = LFE
7414 * LineIn = Surround
7415 */
7416static struct hda_verb alc885_mb5_ch6_init[] = {
7417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7420 { } /* end */
7421};
7422
7423static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7424 { 2, alc885_mb5_ch2_init },
7425 { 6, alc885_mb5_ch6_init },
7426};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007427
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007428#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007429
7430/*
7431 * 2ch mode
7432 */
7433static struct hda_verb alc883_4ST_ch2_init[] = {
7434 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7435 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7436 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7437 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7438 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7439 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7440 { } /* end */
7441};
7442
7443/*
7444 * 4ch mode
7445 */
7446static struct hda_verb alc883_4ST_ch4_init[] = {
7447 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7448 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7451 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7452 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7453 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7454 { } /* end */
7455};
7456
7457/*
7458 * 6ch mode
7459 */
7460static struct hda_verb alc883_4ST_ch6_init[] = {
7461 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7462 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7463 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7464 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7465 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7466 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7467 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7468 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7469 { } /* end */
7470};
7471
7472/*
7473 * 8ch mode
7474 */
7475static struct hda_verb alc883_4ST_ch8_init[] = {
7476 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7477 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7478 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7479 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7480 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7481 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7482 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7483 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7484 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7485 { } /* end */
7486};
7487
7488static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7489 { 2, alc883_4ST_ch2_init },
7490 { 4, alc883_4ST_ch4_init },
7491 { 6, alc883_4ST_ch6_init },
7492 { 8, alc883_4ST_ch8_init },
7493};
7494
7495
7496/*
7497 * 2ch mode
7498 */
7499static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7500 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7501 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7502 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7503 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7504 { } /* end */
7505};
7506
7507/*
7508 * 4ch mode
7509 */
7510static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7511 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7512 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7513 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7514 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7515 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7516 { } /* end */
7517};
7518
7519/*
7520 * 6ch mode
7521 */
7522static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7523 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7524 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7525 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7526 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7528 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7529 { } /* end */
7530};
7531
7532static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7533 { 2, alc883_3ST_ch2_intel_init },
7534 { 4, alc883_3ST_ch4_intel_init },
7535 { 6, alc883_3ST_ch6_intel_init },
7536};
7537
7538/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007539 * 2ch mode
7540 */
7541static struct hda_verb alc889_ch2_intel_init[] = {
7542 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7543 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7544 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7545 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7546 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7547 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7548 { } /* end */
7549};
7550
7551/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007552 * 6ch mode
7553 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007554static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007555 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7556 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7557 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7558 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7559 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007560 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7561 { } /* end */
7562};
7563
7564/*
7565 * 8ch mode
7566 */
7567static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007568 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7569 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7570 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7571 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7572 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007575 { } /* end */
7576};
7577
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007578static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7579 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007580 { 6, alc889_ch6_intel_init },
7581 { 8, alc889_ch8_intel_init },
7582};
7583
7584/*
7585 * 6ch mode
7586 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007587static struct hda_verb alc883_sixstack_ch6_init[] = {
7588 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7589 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7590 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7591 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7592 { } /* end */
7593};
7594
7595/*
7596 * 8ch mode
7597 */
7598static struct hda_verb alc883_sixstack_ch8_init[] = {
7599 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7600 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7601 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { } /* end */
7604};
7605
7606static struct hda_channel_mode alc883_sixstack_modes[2] = {
7607 { 6, alc883_sixstack_ch6_init },
7608 { 8, alc883_sixstack_ch8_init },
7609};
7610
7611
Linus Torvalds1da177e2005-04-16 15:20:36 -07007612/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7613 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7614 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007615static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007616 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007617 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007618 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007619 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007620 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7621 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007622 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7623 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007624 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007625 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007626 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7627 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7628 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7629 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7630 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7631 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007632 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7634 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007635 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007636 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007637 { } /* end */
7638};
7639
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007640/* Macbook Air 2,1 same control for HP and internal Speaker */
7641
7642static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7643 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7644 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7645 { }
7646};
7647
7648
Takashi Iwai87350ad2007-08-16 18:19:38 +02007649static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007650 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7651 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7652 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7653 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7654 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007655 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7656 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7658 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007659 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7661 { } /* end */
7662};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007663
7664static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7666 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7668 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7669 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7670 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307671 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7672 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307673 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7674 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007675 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7676 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7677 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7678 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7679 { } /* end */
7680};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007681
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007682static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7683 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7684 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7685 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7686 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7687 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7688 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7690 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7691 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7692 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7693 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7694 { } /* end */
7695};
7696
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007697static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007698 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7699 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007700 { } /* end */
7701};
7702
7703
Kailang Yangbdd148a2007-05-08 15:19:08 +02007704static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7705 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7706 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7707 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7708 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7709 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7710 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007714 { } /* end */
7715};
7716
Kailang Yang272a5272007-05-14 11:00:38 +02007717static struct snd_kcontrol_new alc882_targa_mixer[] = {
7718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7720 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7721 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7722 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007727 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007728 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7729 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007730 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007731 { } /* end */
7732};
7733
7734/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7735 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7736 */
7737static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7738 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7739 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7741 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7742 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7743 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7744 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7745 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7746 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7747 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007750 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007751 { } /* end */
7752};
7753
Takashi Iwai914759b2007-09-06 14:52:04 +02007754static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7755 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7756 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7758 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7759 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7761 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007765 { } /* end */
7766};
7767
Kailang Yangdf694da2005-12-05 19:42:22 +01007768static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7769 {
7770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7771 .name = "Channel Mode",
7772 .info = alc_ch_mode_info,
7773 .get = alc_ch_mode_get,
7774 .put = alc_ch_mode_put,
7775 },
7776 { } /* end */
7777};
7778
Takashi Iwai4953550a2009-06-30 15:28:30 +02007779static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007780 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007781 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7782 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007783 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007784 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7785 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007786 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007787 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7788 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007789 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007790 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7791 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007792
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007793 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007796 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007797 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007798 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007799 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007800 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007801 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007802 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007804 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007805 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007806 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007807 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007808 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007809 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007810 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007811 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7812 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007813 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007814 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7815 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007816 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007817 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7818 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7819 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7820 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7821 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007822 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007823 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007824
7825 /* FIXME: use matrix-type input source selection */
7826 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007827 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007828 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007829 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007831 /* ADC2: mute amp left and right */
7832 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007833 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007834 /* ADC3: mute amp left and right */
7835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007836 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007837
7838 { }
7839};
7840
Takashi Iwai4953550a2009-06-30 15:28:30 +02007841static struct hda_verb alc882_adc1_init_verbs[] = {
7842 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7845 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7847 /* ADC1: mute amp left and right */
7848 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7849 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7850 { }
7851};
7852
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007853static struct hda_verb alc882_eapd_verbs[] = {
7854 /* change to EAPD mode */
7855 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007856 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007857 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007858};
7859
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007860static struct hda_verb alc889_eapd_verbs[] = {
7861 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7862 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7863 { }
7864};
7865
Wu Fengguang6732bd02009-07-30 09:19:14 +02007866static struct hda_verb alc_hp15_unsol_verbs[] = {
7867 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7869 {}
7870};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007871
7872static struct hda_verb alc885_init_verbs[] = {
7873 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007874 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7875 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007876 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007877 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7878 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007879 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007880 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7881 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007882 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007883 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7884 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007885
7886 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007887 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007888 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7889 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7890 /* Front Pin: output 0 (0x0c) */
7891 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7892 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7893 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7894 /* Rear Pin: output 1 (0x0d) */
7895 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7896 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7897 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7898 /* CLFE Pin: output 2 (0x0e) */
7899 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7900 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7901 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7902 /* Side Pin: output 3 (0x0f) */
7903 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7904 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7905 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7906 /* Mic (rear) pin: input vref at 80% */
7907 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7908 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7909 /* Front Mic pin: input vref at 80% */
7910 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7911 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7912 /* Line In pin: input */
7913 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7914 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7915
7916 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7917 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007918 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007919 /* Input mixer2 */
7920 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007921 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007922 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007923 /* ADC2: mute amp left and right */
7924 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7925 /* ADC3: mute amp left and right */
7926 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7927
7928 { }
7929};
7930
7931static struct hda_verb alc885_init_input_verbs[] = {
7932 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7933 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7934 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7935 { }
7936};
7937
7938
7939/* Unmute Selector 24h and set the default input to front mic */
7940static struct hda_verb alc889_init_input_verbs[] = {
7941 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7943 { }
7944};
7945
7946
Takashi Iwai4953550a2009-06-30 15:28:30 +02007947#define alc883_init_verbs alc882_base_init_verbs
7948
Tobin Davis9102cd12006-12-15 10:02:12 +01007949/* Mac Pro test */
7950static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7951 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7952 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7953 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7955 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007956 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007957 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7958 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007959 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007960 { } /* end */
7961};
7962
7963static struct hda_verb alc882_macpro_init_verbs[] = {
7964 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7965 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7966 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7967 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7968 /* Front Pin: output 0 (0x0c) */
7969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7970 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7971 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7972 /* Front Mic pin: input vref at 80% */
7973 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7974 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7975 /* Speaker: output */
7976 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7977 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7978 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7979 /* Headphone output (output 0 - 0x0c) */
7980 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7981 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7982 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7983
7984 /* FIXME: use matrix-type input source selection */
7985 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7986 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7991 /* Input mixer2 */
7992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7995 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7996 /* Input mixer3 */
7997 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7998 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8001 /* ADC1: mute amp left and right */
8002 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8003 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8004 /* ADC2: mute amp left and right */
8005 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8006 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8007 /* ADC3: mute amp left and right */
8008 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8009 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8010
8011 { }
8012};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008013
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008014/* Macbook 5,1 */
8015static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008016 /* DACs */
8017 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8018 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8019 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8020 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008021 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8024 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008025 /* Surround mixer */
8026 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8027 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8029 /* LFE mixer */
8030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8033 /* HP mixer */
8034 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8036 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8037 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008040 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8041 /* LFE Pin (0x0e) */
8042 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8043 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8044 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8045 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008046 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008048 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308049 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008050 /* Front Mic pin: input vref at 80% */
8051 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8052 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8053 /* Line In pin */
8054 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8055 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8056
Alex Murrayb8f171e2010-06-14 12:08:43 +09308057 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008060 { }
8061};
8062
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008063/* Macmini 3,1 */
8064static struct hda_verb alc885_macmini3_init_verbs[] = {
8065 /* DACs */
8066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8067 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8068 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8069 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8070 /* Front mixer */
8071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8074 /* Surround mixer */
8075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8078 /* LFE mixer */
8079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8082 /* HP mixer */
8083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8084 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8085 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8086 /* Front Pin (0x0c) */
8087 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8088 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8089 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8090 /* LFE Pin (0x0e) */
8091 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8092 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8093 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8094 /* HP Pin (0x0f) */
8095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8096 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8097 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8098 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8099 /* Line In pin */
8100 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8101 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8102
8103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8107 { }
8108};
8109
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008110
8111static struct hda_verb alc885_mba21_init_verbs[] = {
8112 /*Internal and HP Speaker Mixer*/
8113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8116 /*Internal Speaker Pin (0x0c)*/
8117 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8118 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8119 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8120 /* HP Pin: output 0 (0x0e) */
8121 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8122 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8123 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8124 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8125 /* Line in (is hp when jack connected)*/
8126 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8127 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8128
8129 { }
8130 };
8131
8132
Takashi Iwai87350ad2007-08-16 18:19:38 +02008133/* Macbook Pro rev3 */
8134static struct hda_verb alc885_mbp3_init_verbs[] = {
8135 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8139 /* Rear mixer */
8140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8141 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008143 /* HP mixer */
8144 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8145 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008147 /* Front Pin: output 0 (0x0c) */
8148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008151 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8154 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008155 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8156 /* Mic (rear) pin: input vref at 80% */
8157 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8158 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8159 /* Front Mic pin: input vref at 80% */
8160 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8161 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8162 /* Line In pin: use output 1 when in LineOut mode */
8163 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8164 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8165 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8166
8167 /* FIXME: use matrix-type input source selection */
8168 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8169 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8174 /* Input mixer2 */
8175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8176 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8179 /* Input mixer3 */
8180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8184 /* ADC1: mute amp left and right */
8185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8186 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8187 /* ADC2: mute amp left and right */
8188 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8189 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8190 /* ADC3: mute amp left and right */
8191 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8192 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8193
8194 { }
8195};
8196
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008197/* iMac 9,1 */
8198static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008199 /* Internal Speaker Pin (0x0c) */
8200 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8202 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8203 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8204 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8205 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8206 /* HP Pin: Rear */
8207 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8208 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8210 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8211 /* Line in Rear */
8212 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8213 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214 /* Front Mic pin: input vref at 80% */
8215 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8216 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008217 /* Rear mixer */
8218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8219 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8220 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008221 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8222 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8225 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008226 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8227 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8228 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008230 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008231 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8233 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008235 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008236 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8237 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8238 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008240 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008241 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8242 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008243 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008244 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8245 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008246 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008247 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8248 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008249 { }
8250};
8251
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008252/* iMac 24 mixer. */
8253static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8254 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8255 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8256 { } /* end */
8257};
8258
8259/* iMac 24 init verbs. */
8260static struct hda_verb alc885_imac24_init_verbs[] = {
8261 /* Internal speakers: output 0 (0x0c) */
8262 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8264 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8265 /* Internal speakers: output 0 (0x0c) */
8266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8268 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8269 /* Headphone: output 0 (0x0c) */
8270 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8271 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8272 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8273 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8274 /* Front Mic: input vref at 80% */
8275 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8277 { }
8278};
8279
8280/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008281static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008282{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008283 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008284
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008285 spec->autocfg.hp_pins[0] = 0x14;
8286 spec->autocfg.speaker_pins[0] = 0x18;
8287 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008288}
8289
Takashi Iwai9d54f082010-02-22 08:34:40 +01008290#define alc885_mb5_setup alc885_imac24_setup
8291#define alc885_macmini3_setup alc885_imac24_setup
8292
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008293/* Macbook Air 2,1 */
8294static void alc885_mba21_setup(struct hda_codec *codec)
8295{
8296 struct alc_spec *spec = codec->spec;
8297
8298 spec->autocfg.hp_pins[0] = 0x14;
8299 spec->autocfg.speaker_pins[0] = 0x18;
8300}
8301
8302
8303
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008304static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008305{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008306 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008307
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008308 spec->autocfg.hp_pins[0] = 0x15;
8309 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008310}
8311
Takashi Iwai9d54f082010-02-22 08:34:40 +01008312static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308313{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008314 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308315
Takashi Iwai9d54f082010-02-22 08:34:40 +01008316 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008317 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008318 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008319}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008320
Kailang Yang272a5272007-05-14 11:00:38 +02008321static struct hda_verb alc882_targa_verbs[] = {
8322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8324
8325 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8326 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008327
Kailang Yang272a5272007-05-14 11:00:38 +02008328 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8329 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8330 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8331
8332 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008333 { } /* end */
8334};
8335
8336/* toggle speaker-output according to the hp-jack state */
8337static void alc882_targa_automute(struct hda_codec *codec)
8338{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008339 struct alc_spec *spec = codec->spec;
8340 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008341 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008342 spec->jack_present ? 1 : 3);
8343}
8344
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008345static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008346{
8347 struct alc_spec *spec = codec->spec;
8348
8349 spec->autocfg.hp_pins[0] = 0x14;
8350 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008351}
8352
8353static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8354{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008355 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008356 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008357}
8358
8359static struct hda_verb alc882_asus_a7j_verbs[] = {
8360 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8361 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8362
8363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8364 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8365 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008366
Kailang Yang272a5272007-05-14 11:00:38 +02008367 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8369 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8370
8371 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8372 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8373 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8374 { } /* end */
8375};
8376
Takashi Iwai914759b2007-09-06 14:52:04 +02008377static struct hda_verb alc882_asus_a7m_verbs[] = {
8378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8379 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8380
8381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8382 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8383 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008384
Takashi Iwai914759b2007-09-06 14:52:04 +02008385 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8386 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8387 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8388
8389 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8390 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8391 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8392 { } /* end */
8393};
8394
Tobin Davis9102cd12006-12-15 10:02:12 +01008395static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8396{
8397 unsigned int gpiostate, gpiomask, gpiodir;
8398
8399 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8400 AC_VERB_GET_GPIO_DATA, 0);
8401
8402 if (!muted)
8403 gpiostate |= (1 << pin);
8404 else
8405 gpiostate &= ~(1 << pin);
8406
8407 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8408 AC_VERB_GET_GPIO_MASK, 0);
8409 gpiomask |= (1 << pin);
8410
8411 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8412 AC_VERB_GET_GPIO_DIRECTION, 0);
8413 gpiodir |= (1 << pin);
8414
8415
8416 snd_hda_codec_write(codec, codec->afg, 0,
8417 AC_VERB_SET_GPIO_MASK, gpiomask);
8418 snd_hda_codec_write(codec, codec->afg, 0,
8419 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8420
8421 msleep(1);
8422
8423 snd_hda_codec_write(codec, codec->afg, 0,
8424 AC_VERB_SET_GPIO_DATA, gpiostate);
8425}
8426
Takashi Iwai7debbe52007-08-16 15:01:03 +02008427/* set up GPIO at initialization */
8428static void alc885_macpro_init_hook(struct hda_codec *codec)
8429{
8430 alc882_gpio_mute(codec, 0, 0);
8431 alc882_gpio_mute(codec, 1, 0);
8432}
8433
8434/* set up GPIO and update auto-muting at initialization */
8435static void alc885_imac24_init_hook(struct hda_codec *codec)
8436{
8437 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008438 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008439}
8440
Kailang Yangdf694da2005-12-05 19:42:22 +01008441/*
8442 * generic initialization of ADC, input mixers and output mixers
8443 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008444static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008445 /*
8446 * Unmute ADC0-2 and set the default input to mic-in
8447 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008448 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8450 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8451 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8452
Kailang Yangdf694da2005-12-05 19:42:22 +01008453 /*
8454 * Set up output mixers (0x0c - 0x0f)
8455 */
8456 /* set vol=0 to output mixers */
8457 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8458 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8459 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8460 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8461 /* set up input amps for analog loopback */
8462 /* Amp Indices: DAC = 0, mixer = 1 */
8463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8465 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8467 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8469 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8471 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8472 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8473
8474 /* FIXME: use matrix-type input source selection */
8475 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008476 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008478 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008480 { }
8481};
8482
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008483/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8484static struct hda_verb alc889A_mb31_ch2_init[] = {
8485 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8486 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8487 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8488 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8489 { } /* end */
8490};
8491
8492/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8493static struct hda_verb alc889A_mb31_ch4_init[] = {
8494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8495 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8497 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8498 { } /* end */
8499};
8500
8501/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8502static struct hda_verb alc889A_mb31_ch5_init[] = {
8503 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8504 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8507 { } /* end */
8508};
8509
8510/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8511static struct hda_verb alc889A_mb31_ch6_init[] = {
8512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8513 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8514 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8515 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8516 { } /* end */
8517};
8518
8519static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8520 { 2, alc889A_mb31_ch2_init },
8521 { 4, alc889A_mb31_ch4_init },
8522 { 5, alc889A_mb31_ch5_init },
8523 { 6, alc889A_mb31_ch6_init },
8524};
8525
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008526static struct hda_verb alc883_medion_eapd_verbs[] = {
8527 /* eanable EAPD on medion laptop */
8528 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8529 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8530 { }
8531};
8532
Takashi Iwai4953550a2009-06-30 15:28:30 +02008533#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008534
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008535static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8536 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8537 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8538 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8539 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8540 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8541 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8542 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8544 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8546 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8547 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8548 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008549 { } /* end */
8550};
8551
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008552static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8554 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8556 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8557 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8558 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8559 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8560 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8561 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8562 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008563 { } /* end */
8564};
8565
Jiang zhefb97dc62008-03-06 11:07:11 +01008566static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8568 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8569 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8570 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8572 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8574 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8575 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8576 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008577 { } /* end */
8578};
8579
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008580static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8581 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8582 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8591 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008592 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008593 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008594 { } /* end */
8595};
8596
8597static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8598 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8599 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8600 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8601 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8602 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8603 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8604 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8605 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8606 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8607 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8608 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8609 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8610 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8611 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008612 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8614 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008615 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008616 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008617 { } /* end */
8618};
8619
Jiang zhe17bba1b2008-06-04 12:11:07 +02008620static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8622 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8623 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8624 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8625 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8626 HDA_OUTPUT),
8627 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8628 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8629 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8631 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8632 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8633 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8634 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8635 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8636 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8638 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8639 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8640 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008641 { } /* end */
8642};
8643
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008644static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8645 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8646 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8647 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8648 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8649 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8650 HDA_OUTPUT),
8651 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8652 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8653 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8654 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8655 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8657 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8658 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8660 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8662 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8663 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8664 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8665 { } /* end */
8666};
8667
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008668static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008669 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008670 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008671 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008672 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008673 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8674 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008675 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8676 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008677 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8678 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8679 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8680 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8681 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8682 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008683 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008684 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8685 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008686 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008688 { } /* end */
8689};
8690
Sasha Alexandrc2592492009-06-16 14:52:54 -04008691static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008692 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008693 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008694 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008695 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008696 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8697 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8698 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8699 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8700 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8701 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8702 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8703 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8705 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008707 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008709 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008710};
Kailang Yangccc656c2006-10-17 12:32:26 +02008711
Sasha Alexandrc2592492009-06-16 14:52:54 -04008712static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008714 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008716 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008717 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8718 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008722 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8723 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8724 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008725 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008726};
Kailang Yangccc656c2006-10-17 12:32:26 +02008727
Takashi Iwaib99dba32009-09-17 18:23:00 +02008728static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8729 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8730 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8731 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8732 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8733 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8734 { } /* end */
8735};
8736
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008737static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8738 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8739 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008740 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8741 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8743 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8744 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008746 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008747};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008748
Kailang Yang272a5272007-05-14 11:00:38 +02008749static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8750 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8751 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8753 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8754 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008757 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8758 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008759 { } /* end */
8760};
8761
8762static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8763 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8765 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8770 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8771 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008772 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008773};
Kailang Yang272a5272007-05-14 11:00:38 +02008774
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008775static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8776 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8777 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8778 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8779 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8780 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8781 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8782 { } /* end */
8783};
8784
8785static struct hda_verb alc883_medion_wim2160_verbs[] = {
8786 /* Unmute front mixer */
8787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8788 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8789
8790 /* Set speaker pin to front mixer */
8791 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8792
8793 /* Init headphone pin */
8794 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8795 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8796 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8797 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8798
8799 { } /* end */
8800};
8801
8802/* toggle speaker-output according to the hp-jack state */
8803static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8804{
8805 struct alc_spec *spec = codec->spec;
8806
8807 spec->autocfg.hp_pins[0] = 0x1a;
8808 spec->autocfg.speaker_pins[0] = 0x15;
8809}
8810
Tobin Davis2880a862007-08-07 11:50:26 +02008811static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008812 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8813 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008814 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008815 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8816 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008817 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8818 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8819 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008820 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008821};
Tobin Davis2880a862007-08-07 11:50:26 +02008822
Tony Vroond2fd4b02009-06-21 00:40:10 +01008823static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008825 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008826 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8827 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008828 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8829 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8831 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8833 { } /* end */
8834};
8835
Kailang Yange2757d52008-08-26 13:17:46 +02008836static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8837 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8838 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8839 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8840 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8841 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8842 0x0d, 1, 0x0, HDA_OUTPUT),
8843 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8844 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8845 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8846 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8847 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008848 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8849 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8850 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8851 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8853 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8855 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8856 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8857 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008858 { } /* end */
8859};
8860
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008861static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8862 /* Output mixers */
8863 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8864 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8866 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8867 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8868 HDA_OUTPUT),
8869 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8870 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8871 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8872 /* Output switches */
8873 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8874 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8875 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8876 /* Boost mixers */
8877 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8878 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8879 /* Input mixers */
8880 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8881 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8882 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8883 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8884 { } /* end */
8885};
8886
Guido Günther3e1647c2009-06-05 00:47:26 +02008887static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8888 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8889 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8890 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8891 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8892 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8894 { } /* end */
8895};
8896
Kailang Yange2757d52008-08-26 13:17:46 +02008897static struct hda_bind_ctls alc883_bind_cap_vol = {
8898 .ops = &snd_hda_bind_vol,
8899 .values = {
8900 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8901 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8902 0
8903 },
8904};
8905
8906static struct hda_bind_ctls alc883_bind_cap_switch = {
8907 .ops = &snd_hda_bind_sw,
8908 .values = {
8909 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8910 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8911 0
8912 },
8913};
8914
8915static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8916 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8917 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8918 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8919 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8920 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8921 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8922 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8923 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008924 { } /* end */
8925};
8926
8927static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008928 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8929 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8930 {
8931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8932 /* .name = "Capture Source", */
8933 .name = "Input Source",
8934 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008935 .info = alc_mux_enum_info,
8936 .get = alc_mux_enum_get,
8937 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008938 },
8939 { } /* end */
8940};
8941
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008942static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8943 {
8944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8945 .name = "Channel Mode",
8946 .info = alc_ch_mode_info,
8947 .get = alc_ch_mode_get,
8948 .put = alc_ch_mode_put,
8949 },
8950 { } /* end */
8951};
8952
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008953/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008954static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008955{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008956 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008957
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008958 spec->autocfg.hp_pins[0] = 0x15;
8959 spec->autocfg.speaker_pins[0] = 0x14;
8960 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008961}
8962
8963/* auto-toggle front mic */
8964/*
8965static void alc883_mitac_mic_automute(struct hda_codec *codec)
8966{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008967 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008968
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008969 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8970}
8971*/
8972
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008973static struct hda_verb alc883_mitac_verbs[] = {
8974 /* HP */
8975 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8977 /* Subwoofer */
8978 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8979 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8980
8981 /* enable unsolicited event */
8982 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8983 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8984
8985 { } /* end */
8986};
8987
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308988static struct hda_verb alc883_clevo_m540r_verbs[] = {
8989 /* HP */
8990 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8991 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8992 /* Int speaker */
8993 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8994
8995 /* enable unsolicited event */
8996 /*
8997 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8998 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8999 */
9000
9001 { } /* end */
9002};
9003
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009004static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009005 /* HP */
9006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9008 /* Int speaker */
9009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9011
9012 /* enable unsolicited event */
9013 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009014 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009015
9016 { } /* end */
9017};
9018
Jiang zhefb97dc62008-03-06 11:07:11 +01009019static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9020 /* HP */
9021 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9023 /* Subwoofer */
9024 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9026
9027 /* enable unsolicited event */
9028 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9029
9030 { } /* end */
9031};
9032
Sasha Alexandrc2592492009-06-16 14:52:54 -04009033static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9036
9037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9038 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009039
David Heidelberger64a8be72009-06-08 16:15:18 +02009040/* Connect Line-Out side jack (SPDIF) to Side */
9041 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9042 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9043 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9044/* Connect Mic jack to CLFE */
9045 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9046 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9047 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9048/* Connect Line-in jack to Surround */
9049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9050 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9051 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9052/* Connect HP out jack to Front */
9053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9054 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9055 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009056
9057 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009058
9059 { } /* end */
9060};
9061
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009062static struct hda_verb alc883_lenovo_101e_verbs[] = {
9063 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9064 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9065 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9066 { } /* end */
9067};
9068
Kailang Yang272a5272007-05-14 11:00:38 +02009069static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9070 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9071 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9072 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9073 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9074 { } /* end */
9075};
9076
9077static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9078 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9080 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9081 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9082 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9083 { } /* end */
9084};
9085
Kailang Yang189609a2007-08-20 11:31:23 +02009086static struct hda_verb alc883_haier_w66_verbs[] = {
9087 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9088 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9089
9090 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9091
9092 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9093 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9094 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9096 { } /* end */
9097};
9098
Kailang Yange2757d52008-08-26 13:17:46 +02009099static struct hda_verb alc888_lenovo_sky_verbs[] = {
9100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9102 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9104 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9106 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9107 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9108 { } /* end */
9109};
9110
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009111static struct hda_verb alc888_6st_dell_verbs[] = {
9112 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9113 { }
9114};
9115
Guido Günther3e1647c2009-06-05 00:47:26 +02009116static struct hda_verb alc883_vaiott_verbs[] = {
9117 /* HP */
9118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9119 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9120
9121 /* enable unsolicited event */
9122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9123
9124 { } /* end */
9125};
9126
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009127static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009128{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009129 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009130
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009131 spec->autocfg.hp_pins[0] = 0x1b;
9132 spec->autocfg.speaker_pins[0] = 0x14;
9133 spec->autocfg.speaker_pins[1] = 0x16;
9134 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009135}
9136
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009137static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009138 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009139 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9140 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009141 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009142 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009143};
9144
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009145/*
9146 * 2ch mode
9147 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009148static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009149 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9150 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9151 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9152 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009153 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009154};
9155
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009156/*
9157 * 4ch mode
9158 */
9159static struct hda_verb alc888_3st_hp_4ch_init[] = {
9160 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9161 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9162 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9163 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9164 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9165 { } /* end */
9166};
9167
9168/*
9169 * 6ch mode
9170 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009171static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009172 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9173 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009174 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009175 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9176 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009177 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9178 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009179};
9180
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009181static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009182 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009183 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009184 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009185};
9186
Kailang Yang272a5272007-05-14 11:00:38 +02009187/* toggle front-jack and RCA according to the hp-jack state */
9188static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9189{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009190 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009191
Takashi Iwai47fd8302007-08-10 17:11:07 +02009192 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9193 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9194 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9195 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009196}
9197
9198/* toggle RCA according to the front-jack state */
9199static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9200{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009201 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009202
Takashi Iwai47fd8302007-08-10 17:11:07 +02009203 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9204 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009205}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009206
Kailang Yang272a5272007-05-14 11:00:38 +02009207static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9208 unsigned int res)
9209{
9210 if ((res >> 26) == ALC880_HP_EVENT)
9211 alc888_lenovo_ms7195_front_automute(codec);
9212 if ((res >> 26) == ALC880_FRONT_EVENT)
9213 alc888_lenovo_ms7195_rca_automute(codec);
9214}
9215
9216static struct hda_verb alc883_medion_md2_verbs[] = {
9217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9219
9220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9221
9222 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9223 { } /* end */
9224};
9225
9226/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009227static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009228{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009229 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009230
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009231 spec->autocfg.hp_pins[0] = 0x14;
9232 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009233}
9234
Kailang Yangccc656c2006-10-17 12:32:26 +02009235/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009236#define alc883_targa_init_hook alc882_targa_init_hook
9237#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009238
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009239static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9240{
9241 unsigned int present;
9242
Takashi Iwaid56757a2009-11-18 08:00:14 +01009243 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009244 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9245 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9246}
9247
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009248static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009249{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009250 struct alc_spec *spec = codec->spec;
9251
9252 spec->autocfg.hp_pins[0] = 0x15;
9253 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009254}
9255
9256static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9257{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009258 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009259 alc883_clevo_m720_mic_automute(codec);
9260}
9261
9262static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009263 unsigned int res)
9264{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009265 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009266 case ALC880_MIC_EVENT:
9267 alc883_clevo_m720_mic_automute(codec);
9268 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009269 default:
9270 alc_automute_amp_unsol_event(codec, res);
9271 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009272 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009273}
9274
Jiang zhefb97dc62008-03-06 11:07:11 +01009275/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009276static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009277{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009278 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009279
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009280 spec->autocfg.hp_pins[0] = 0x14;
9281 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009282}
9283
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009284static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009285{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009286 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009287
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009288 spec->autocfg.hp_pins[0] = 0x1b;
9289 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009290}
9291
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009292static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9293{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009294 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009295
Takashi Iwai47fd8302007-08-10 17:11:07 +02009296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9297 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009298}
9299
9300static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9301{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009302 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009303
Takashi Iwai47fd8302007-08-10 17:11:07 +02009304 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9305 HDA_AMP_MUTE, bits);
9306 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9307 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009308}
9309
9310static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9311 unsigned int res)
9312{
9313 if ((res >> 26) == ALC880_HP_EVENT)
9314 alc883_lenovo_101e_all_automute(codec);
9315 if ((res >> 26) == ALC880_FRONT_EVENT)
9316 alc883_lenovo_101e_ispeaker_automute(codec);
9317}
9318
Takashi Iwai676a9b52007-08-16 15:23:35 +02009319/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009320static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009321{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009322 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009323
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009324 spec->autocfg.hp_pins[0] = 0x14;
9325 spec->autocfg.speaker_pins[0] = 0x15;
9326 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009327}
9328
Kailang Yangd1a991a2007-08-15 16:21:59 +02009329static struct hda_verb alc883_acer_eapd_verbs[] = {
9330 /* HP Pin: output 0 (0x0c) */
9331 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9332 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9333 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9334 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009337 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009338 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9339 /* eanable EAPD on medion laptop */
9340 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9341 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009342 /* enable unsolicited event */
9343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009344 { }
9345};
9346
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009347static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9349 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9350 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9351 { } /* end */
9352};
9353
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009354static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009355{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009356 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009357
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009358 spec->autocfg.hp_pins[0] = 0x1b;
9359 spec->autocfg.speaker_pins[0] = 0x14;
9360 spec->autocfg.speaker_pins[1] = 0x15;
9361 spec->autocfg.speaker_pins[2] = 0x16;
9362 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009363}
9364
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009365static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009366{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009367 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009368
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009369 spec->autocfg.hp_pins[0] = 0x1b;
9370 spec->autocfg.speaker_pins[0] = 0x14;
9371 spec->autocfg.speaker_pins[1] = 0x15;
9372 spec->autocfg.speaker_pins[2] = 0x16;
9373 spec->autocfg.speaker_pins[3] = 0x17;
9374 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009375}
9376
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009377static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009378{
9379 struct alc_spec *spec = codec->spec;
9380
9381 spec->autocfg.hp_pins[0] = 0x15;
9382 spec->autocfg.speaker_pins[0] = 0x14;
9383 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009384}
9385
Kailang Yange2757d52008-08-26 13:17:46 +02009386static struct hda_verb alc888_asus_m90v_verbs[] = {
9387 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9388 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9390 /* enable unsolicited event */
9391 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9392 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9393 { } /* end */
9394};
9395
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009396static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009398 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009400 spec->autocfg.hp_pins[0] = 0x1b;
9401 spec->autocfg.speaker_pins[0] = 0x14;
9402 spec->autocfg.speaker_pins[1] = 0x15;
9403 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009404 spec->ext_mic.pin = 0x18;
9405 spec->int_mic.pin = 0x19;
9406 spec->ext_mic.mux_idx = 0;
9407 spec->int_mic.mux_idx = 1;
9408 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009409}
9410
9411static struct hda_verb alc888_asus_eee1601_verbs[] = {
9412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9417 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9418 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9419 /* enable unsolicited event */
9420 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9421 { } /* end */
9422};
9423
Kailang Yange2757d52008-08-26 13:17:46 +02009424static void alc883_eee1601_inithook(struct hda_codec *codec)
9425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009426 struct alc_spec *spec = codec->spec;
9427
9428 spec->autocfg.hp_pins[0] = 0x14;
9429 spec->autocfg.speaker_pins[0] = 0x1b;
9430 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009431}
9432
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009433static struct hda_verb alc889A_mb31_verbs[] = {
9434 /* Init rear pin (used as headphone output) */
9435 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9436 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9437 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9438 /* Init line pin (used as output in 4ch and 6ch mode) */
9439 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9440 /* Init line 2 pin (used as headphone out by default) */
9441 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9442 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9443 { } /* end */
9444};
9445
9446/* Mute speakers according to the headphone jack state */
9447static void alc889A_mb31_automute(struct hda_codec *codec)
9448{
9449 unsigned int present;
9450
9451 /* Mute only in 2ch or 4ch mode */
9452 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9453 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009454 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009455 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9456 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9457 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9459 }
9460}
9461
9462static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9463{
9464 if ((res >> 26) == ALC880_HP_EVENT)
9465 alc889A_mb31_automute(codec);
9466}
9467
Takashi Iwai4953550a2009-06-30 15:28:30 +02009468
Takashi Iwaicb53c622007-08-10 17:21:45 +02009469#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009470#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009471#endif
9472
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009473/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009474#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9475#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9476#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9477#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9478
9479static hda_nid_t alc883_slave_dig_outs[] = {
9480 ALC1200_DIGOUT_NID, 0,
9481};
9482
9483static hda_nid_t alc1200_slave_dig_outs[] = {
9484 ALC883_DIGOUT_NID, 0,
9485};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009486
9487/*
9488 * configuration and preset
9489 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009490static const char *alc882_models[ALC882_MODEL_LAST] = {
9491 [ALC882_3ST_DIG] = "3stack-dig",
9492 [ALC882_6ST_DIG] = "6stack-dig",
9493 [ALC882_ARIMA] = "arima",
9494 [ALC882_W2JC] = "w2jc",
9495 [ALC882_TARGA] = "targa",
9496 [ALC882_ASUS_A7J] = "asus-a7j",
9497 [ALC882_ASUS_A7M] = "asus-a7m",
9498 [ALC885_MACPRO] = "macpro",
9499 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009500 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009501 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502 [ALC885_MBP3] = "mbp3",
9503 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009504 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009505 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009506 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9507 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009508 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009509 [ALC883_TARGA_DIG] = "targa-dig",
9510 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009511 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009512 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009513 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009514 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009515 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009516 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009517 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009518 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009519 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009520 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009521 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009522 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009523 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9524 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009525 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009526 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009527 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009528 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009529 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309530 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009531 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009532 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009533 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009534 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009535 [ALC889A_INTEL] = "intel-alc889a",
9536 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009537 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009538 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009539 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009540 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009541};
9542
Takashi Iwai4953550a2009-06-30 15:28:30 +02009543static struct snd_pci_quirk alc882_cfg_tbl[] = {
9544 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9545
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009546 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009547 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009548 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009549 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9550 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009551 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009552 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9553 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009554 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009555 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009556 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9557 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009558 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9559 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009560 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9561 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009562 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009563 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009564 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009565 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009566 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9567 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009568 /* default Acer -- disabled as it causes more problems.
9569 * model=auto should work fine now
9570 */
9571 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009572
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009573 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009574
Tobin Davisfebe3372007-06-12 11:27:46 +02009575 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009576 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9577 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009578 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009579 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009580 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009581
9582 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9583 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9584 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009585 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009586 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9587 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9588 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009589 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009590 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009591 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009592 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009593
9594 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009595 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009596 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009597 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009598 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9599 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009600 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009601 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009602 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9603
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009604 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9605 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9606 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009607 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009608 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009609 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009610 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009611 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009612 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9613 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9614 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9615 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9616 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9617 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009618 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009619 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9620 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9621 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009622 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009623 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009624 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9625 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009626 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009627 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009628 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009629 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009630 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009631 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009632 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009633 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009634 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009635
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009636 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009637 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009638 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9639 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309640 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009641 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009642 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009643 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009644 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009645 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009646 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009647 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009648 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009649 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009650 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009651 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9652 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009653 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009654 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009655 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009656 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009657 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009658
Jiang zhe17bba1b2008-06-04 12:11:07 +02009659 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9660 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009661 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009662 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9663 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9664 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009665 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009666
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009667 {}
9668};
9669
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670/* codec SSID table for Intel Mac */
9671static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9672 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9673 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9674 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9675 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9676 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9677 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9678 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009679 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009680 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009681 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009682 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9684 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9685 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009686 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009687 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009688 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009689 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9690 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009691 */
9692 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009693 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009694 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009695 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009696};
9697
Takashi Iwai4953550a2009-06-30 15:28:30 +02009698static struct alc_config_preset alc882_presets[] = {
9699 [ALC882_3ST_DIG] = {
9700 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009701 .init_verbs = { alc882_base_init_verbs,
9702 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009703 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9704 .dac_nids = alc882_dac_nids,
9705 .dig_out_nid = ALC882_DIGOUT_NID,
9706 .dig_in_nid = ALC882_DIGIN_NID,
9707 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9708 .channel_mode = alc882_ch_modes,
9709 .need_dac_fix = 1,
9710 .input_mux = &alc882_capture_source,
9711 },
9712 [ALC882_6ST_DIG] = {
9713 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009714 .init_verbs = { alc882_base_init_verbs,
9715 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009716 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9717 .dac_nids = alc882_dac_nids,
9718 .dig_out_nid = ALC882_DIGOUT_NID,
9719 .dig_in_nid = ALC882_DIGIN_NID,
9720 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9721 .channel_mode = alc882_sixstack_modes,
9722 .input_mux = &alc882_capture_source,
9723 },
9724 [ALC882_ARIMA] = {
9725 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009726 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9727 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009728 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9729 .dac_nids = alc882_dac_nids,
9730 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9731 .channel_mode = alc882_sixstack_modes,
9732 .input_mux = &alc882_capture_source,
9733 },
9734 [ALC882_W2JC] = {
9735 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009736 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9737 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009738 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9739 .dac_nids = alc882_dac_nids,
9740 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9741 .channel_mode = alc880_threestack_modes,
9742 .need_dac_fix = 1,
9743 .input_mux = &alc882_capture_source,
9744 .dig_out_nid = ALC882_DIGOUT_NID,
9745 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009746 [ALC885_MBA21] = {
9747 .mixers = { alc885_mba21_mixer },
9748 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9749 .num_dacs = 2,
9750 .dac_nids = alc882_dac_nids,
9751 .channel_mode = alc885_mba21_ch_modes,
9752 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9753 .input_mux = &alc882_capture_source,
9754 .unsol_event = alc_automute_amp_unsol_event,
9755 .setup = alc885_mba21_setup,
9756 .init_hook = alc_automute_amp,
9757 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009758 [ALC885_MBP3] = {
9759 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9760 .init_verbs = { alc885_mbp3_init_verbs,
9761 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009762 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009763 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009764 .hp_nid = 0x04,
9765 .channel_mode = alc885_mbp_4ch_modes,
9766 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009767 .input_mux = &alc882_capture_source,
9768 .dig_out_nid = ALC882_DIGOUT_NID,
9769 .dig_in_nid = ALC882_DIGIN_NID,
9770 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009771 .setup = alc885_mbp3_setup,
9772 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009773 },
9774 [ALC885_MB5] = {
9775 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9776 .init_verbs = { alc885_mb5_init_verbs,
9777 alc880_gpio1_init_verbs },
9778 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9779 .dac_nids = alc882_dac_nids,
9780 .channel_mode = alc885_mb5_6ch_modes,
9781 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9782 .input_mux = &mb5_capture_source,
9783 .dig_out_nid = ALC882_DIGOUT_NID,
9784 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009785 .unsol_event = alc_automute_amp_unsol_event,
9786 .setup = alc885_mb5_setup,
9787 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009788 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009789 [ALC885_MACMINI3] = {
9790 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9791 .init_verbs = { alc885_macmini3_init_verbs,
9792 alc880_gpio1_init_verbs },
9793 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9794 .dac_nids = alc882_dac_nids,
9795 .channel_mode = alc885_macmini3_6ch_modes,
9796 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9797 .input_mux = &macmini3_capture_source,
9798 .dig_out_nid = ALC882_DIGOUT_NID,
9799 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009800 .unsol_event = alc_automute_amp_unsol_event,
9801 .setup = alc885_macmini3_setup,
9802 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009803 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009804 [ALC885_MACPRO] = {
9805 .mixers = { alc882_macpro_mixer },
9806 .init_verbs = { alc882_macpro_init_verbs },
9807 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9808 .dac_nids = alc882_dac_nids,
9809 .dig_out_nid = ALC882_DIGOUT_NID,
9810 .dig_in_nid = ALC882_DIGIN_NID,
9811 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9812 .channel_mode = alc882_ch_modes,
9813 .input_mux = &alc882_capture_source,
9814 .init_hook = alc885_macpro_init_hook,
9815 },
9816 [ALC885_IMAC24] = {
9817 .mixers = { alc885_imac24_mixer },
9818 .init_verbs = { alc885_imac24_init_verbs },
9819 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9820 .dac_nids = alc882_dac_nids,
9821 .dig_out_nid = ALC882_DIGOUT_NID,
9822 .dig_in_nid = ALC882_DIGIN_NID,
9823 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9824 .channel_mode = alc882_ch_modes,
9825 .input_mux = &alc882_capture_source,
9826 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009827 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009828 .init_hook = alc885_imac24_init_hook,
9829 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009830 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009831 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009832 .init_verbs = { alc885_imac91_init_verbs,
9833 alc880_gpio1_init_verbs },
9834 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9835 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009836 .channel_mode = alc885_mba21_ch_modes,
9837 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9838 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009839 .dig_out_nid = ALC882_DIGOUT_NID,
9840 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009841 .unsol_event = alc_automute_amp_unsol_event,
9842 .setup = alc885_imac91_setup,
9843 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009844 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845 [ALC882_TARGA] = {
9846 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009847 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009848 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009849 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9850 .dac_nids = alc882_dac_nids,
9851 .dig_out_nid = ALC882_DIGOUT_NID,
9852 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9853 .adc_nids = alc882_adc_nids,
9854 .capsrc_nids = alc882_capsrc_nids,
9855 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9856 .channel_mode = alc882_3ST_6ch_modes,
9857 .need_dac_fix = 1,
9858 .input_mux = &alc882_capture_source,
9859 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009860 .setup = alc882_targa_setup,
9861 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009862 },
9863 [ALC882_ASUS_A7J] = {
9864 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009865 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9866 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009867 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9868 .dac_nids = alc882_dac_nids,
9869 .dig_out_nid = ALC882_DIGOUT_NID,
9870 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9871 .adc_nids = alc882_adc_nids,
9872 .capsrc_nids = alc882_capsrc_nids,
9873 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9874 .channel_mode = alc882_3ST_6ch_modes,
9875 .need_dac_fix = 1,
9876 .input_mux = &alc882_capture_source,
9877 },
9878 [ALC882_ASUS_A7M] = {
9879 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009880 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9881 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009882 alc882_asus_a7m_verbs },
9883 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9884 .dac_nids = alc882_dac_nids,
9885 .dig_out_nid = ALC882_DIGOUT_NID,
9886 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9887 .channel_mode = alc880_threestack_modes,
9888 .need_dac_fix = 1,
9889 .input_mux = &alc882_capture_source,
9890 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009891 [ALC883_3ST_2ch_DIG] = {
9892 .mixers = { alc883_3ST_2ch_mixer },
9893 .init_verbs = { alc883_init_verbs },
9894 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9895 .dac_nids = alc883_dac_nids,
9896 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009897 .dig_in_nid = ALC883_DIGIN_NID,
9898 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9899 .channel_mode = alc883_3ST_2ch_modes,
9900 .input_mux = &alc883_capture_source,
9901 },
9902 [ALC883_3ST_6ch_DIG] = {
9903 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9904 .init_verbs = { alc883_init_verbs },
9905 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9906 .dac_nids = alc883_dac_nids,
9907 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009908 .dig_in_nid = ALC883_DIGIN_NID,
9909 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9910 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009911 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009912 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009913 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009914 [ALC883_3ST_6ch] = {
9915 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9916 .init_verbs = { alc883_init_verbs },
9917 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9918 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009919 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9920 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009921 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009922 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009923 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009924 [ALC883_3ST_6ch_INTEL] = {
9925 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9926 .init_verbs = { alc883_init_verbs },
9927 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9928 .dac_nids = alc883_dac_nids,
9929 .dig_out_nid = ALC883_DIGOUT_NID,
9930 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009931 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9933 .channel_mode = alc883_3ST_6ch_intel_modes,
9934 .need_dac_fix = 1,
9935 .input_mux = &alc883_3stack_6ch_intel,
9936 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009937 [ALC889A_INTEL] = {
9938 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009939 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9940 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009941 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9942 .dac_nids = alc883_dac_nids,
9943 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9944 .adc_nids = alc889_adc_nids,
9945 .dig_out_nid = ALC883_DIGOUT_NID,
9946 .dig_in_nid = ALC883_DIGIN_NID,
9947 .slave_dig_outs = alc883_slave_dig_outs,
9948 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9949 .channel_mode = alc889_8ch_intel_modes,
9950 .capsrc_nids = alc889_capsrc_nids,
9951 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009952 .setup = alc889_automute_setup,
9953 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009954 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009955 .need_dac_fix = 1,
9956 },
9957 [ALC889_INTEL] = {
9958 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9959 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009960 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9962 .dac_nids = alc883_dac_nids,
9963 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9964 .adc_nids = alc889_adc_nids,
9965 .dig_out_nid = ALC883_DIGOUT_NID,
9966 .dig_in_nid = ALC883_DIGIN_NID,
9967 .slave_dig_outs = alc883_slave_dig_outs,
9968 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9969 .channel_mode = alc889_8ch_intel_modes,
9970 .capsrc_nids = alc889_capsrc_nids,
9971 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009972 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009973 .init_hook = alc889_intel_init_hook,
9974 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009975 .need_dac_fix = 1,
9976 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009977 [ALC883_6ST_DIG] = {
9978 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9979 .init_verbs = { alc883_init_verbs },
9980 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9981 .dac_nids = alc883_dac_nids,
9982 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009983 .dig_in_nid = ALC883_DIGIN_NID,
9984 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9985 .channel_mode = alc883_sixstack_modes,
9986 .input_mux = &alc883_capture_source,
9987 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009988 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009989 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009990 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9991 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009992 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9993 .dac_nids = alc883_dac_nids,
9994 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009995 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9996 .channel_mode = alc883_3ST_6ch_modes,
9997 .need_dac_fix = 1,
9998 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009999 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010000 .setup = alc882_targa_setup,
10001 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010002 },
10003 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010004 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010005 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10006 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010007 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10008 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010009 .adc_nids = alc883_adc_nids_alt,
10010 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010011 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010012 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010013 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10014 .channel_mode = alc883_3ST_2ch_modes,
10015 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010016 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010017 .setup = alc882_targa_setup,
10018 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010019 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010020 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010021 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10022 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010023 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010024 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010025 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10026 .dac_nids = alc883_dac_nids,
10027 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10028 .adc_nids = alc883_adc_nids_rev,
10029 .capsrc_nids = alc883_capsrc_nids_rev,
10030 .dig_out_nid = ALC883_DIGOUT_NID,
10031 .dig_in_nid = ALC883_DIGIN_NID,
10032 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10033 .channel_mode = alc883_4ST_8ch_modes,
10034 .need_dac_fix = 1,
10035 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010036 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010037 .setup = alc882_targa_setup,
10038 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010039 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010040 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010041 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010042 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10043 * and the headphone jack. Turn this on and rely on the
10044 * standard mute methods whenever the user wants to turn
10045 * these outputs off.
10046 */
10047 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10048 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10049 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010050 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10051 .channel_mode = alc883_3ST_2ch_modes,
10052 .input_mux = &alc883_capture_source,
10053 },
Tobin Davis2880a862007-08-07 11:50:26 +020010054 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010055 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010056 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10058 .dac_nids = alc883_dac_nids,
10059 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010060 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10061 .channel_mode = alc883_3ST_2ch_modes,
10062 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010063 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010064 .setup = alc883_acer_aspire_setup,
10065 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010066 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010067 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010068 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010069 alc883_chmode_mixer },
10070 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10071 alc888_acer_aspire_4930g_verbs },
10072 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10073 .dac_nids = alc883_dac_nids,
10074 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10075 .adc_nids = alc883_adc_nids_rev,
10076 .capsrc_nids = alc883_capsrc_nids_rev,
10077 .dig_out_nid = ALC883_DIGOUT_NID,
10078 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10079 .channel_mode = alc883_3ST_6ch_modes,
10080 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010081 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010082 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010083 ARRAY_SIZE(alc888_2_capture_sources),
10084 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010085 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010086 .setup = alc888_acer_aspire_4930g_setup,
10087 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010088 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010089 [ALC888_ACER_ASPIRE_6530G] = {
10090 .mixers = { alc888_acer_aspire_6530_mixer },
10091 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10092 alc888_acer_aspire_6530g_verbs },
10093 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10094 .dac_nids = alc883_dac_nids,
10095 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10096 .adc_nids = alc883_adc_nids_rev,
10097 .capsrc_nids = alc883_capsrc_nids_rev,
10098 .dig_out_nid = ALC883_DIGOUT_NID,
10099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10100 .channel_mode = alc883_3ST_2ch_modes,
10101 .num_mux_defs =
10102 ARRAY_SIZE(alc888_2_capture_sources),
10103 .input_mux = alc888_acer_aspire_6530_sources,
10104 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010105 .setup = alc888_acer_aspire_6530g_setup,
10106 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010107 },
Hector Martin3b315d72009-06-02 10:54:19 +020010108 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010109 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010110 alc883_chmode_mixer },
10111 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010112 alc889_acer_aspire_8930g_verbs,
10113 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010114 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10115 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010116 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10117 .adc_nids = alc889_adc_nids,
10118 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010119 .dig_out_nid = ALC883_DIGOUT_NID,
10120 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10121 .channel_mode = alc883_3ST_6ch_modes,
10122 .need_dac_fix = 1,
10123 .const_channel_count = 6,
10124 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010125 ARRAY_SIZE(alc889_capture_sources),
10126 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010127 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010128 .setup = alc889_acer_aspire_8930g_setup,
10129 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010130#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010131 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010132#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010133 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010134 [ALC888_ACER_ASPIRE_7730G] = {
10135 .mixers = { alc883_3ST_6ch_mixer,
10136 alc883_chmode_mixer },
10137 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10138 alc888_acer_aspire_7730G_verbs },
10139 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10140 .dac_nids = alc883_dac_nids,
10141 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10142 .adc_nids = alc883_adc_nids_rev,
10143 .capsrc_nids = alc883_capsrc_nids_rev,
10144 .dig_out_nid = ALC883_DIGOUT_NID,
10145 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10146 .channel_mode = alc883_3ST_6ch_modes,
10147 .need_dac_fix = 1,
10148 .const_channel_count = 6,
10149 .input_mux = &alc883_capture_source,
10150 .unsol_event = alc_automute_amp_unsol_event,
10151 .setup = alc888_acer_aspire_6530g_setup,
10152 .init_hook = alc_automute_amp,
10153 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010154 [ALC883_MEDION] = {
10155 .mixers = { alc883_fivestack_mixer,
10156 alc883_chmode_mixer },
10157 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010158 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010159 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10160 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010161 .adc_nids = alc883_adc_nids_alt,
10162 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010163 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010164 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10165 .channel_mode = alc883_sixstack_modes,
10166 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010167 },
Kailang Yang272a5272007-05-14 11:00:38 +020010168 [ALC883_MEDION_MD2] = {
10169 .mixers = { alc883_medion_md2_mixer},
10170 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10171 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10172 .dac_nids = alc883_dac_nids,
10173 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010174 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10175 .channel_mode = alc883_3ST_2ch_modes,
10176 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010177 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010178 .setup = alc883_medion_md2_setup,
10179 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010180 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010181 [ALC883_MEDION_WIM2160] = {
10182 .mixers = { alc883_medion_wim2160_mixer },
10183 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10185 .dac_nids = alc883_dac_nids,
10186 .dig_out_nid = ALC883_DIGOUT_NID,
10187 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10188 .adc_nids = alc883_adc_nids,
10189 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10190 .channel_mode = alc883_3ST_2ch_modes,
10191 .input_mux = &alc883_capture_source,
10192 .unsol_event = alc_automute_amp_unsol_event,
10193 .setup = alc883_medion_wim2160_setup,
10194 .init_hook = alc_automute_amp,
10195 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010196 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010197 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010198 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10199 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10200 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10202 .channel_mode = alc883_3ST_2ch_modes,
10203 .input_mux = &alc883_capture_source,
10204 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010205 [ALC883_CLEVO_M540R] = {
10206 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10207 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10208 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10209 .dac_nids = alc883_dac_nids,
10210 .dig_out_nid = ALC883_DIGOUT_NID,
10211 .dig_in_nid = ALC883_DIGIN_NID,
10212 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10213 .channel_mode = alc883_3ST_6ch_clevo_modes,
10214 .need_dac_fix = 1,
10215 .input_mux = &alc883_capture_source,
10216 /* This machine has the hardware HP auto-muting, thus
10217 * we need no software mute via unsol event
10218 */
10219 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010220 [ALC883_CLEVO_M720] = {
10221 .mixers = { alc883_clevo_m720_mixer },
10222 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010223 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10224 .dac_nids = alc883_dac_nids,
10225 .dig_out_nid = ALC883_DIGOUT_NID,
10226 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10227 .channel_mode = alc883_3ST_2ch_modes,
10228 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010229 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010230 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010231 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010232 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010233 [ALC883_LENOVO_101E_2ch] = {
10234 .mixers = { alc883_lenovo_101e_2ch_mixer},
10235 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10236 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10237 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010238 .adc_nids = alc883_adc_nids_alt,
10239 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010240 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010241 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10242 .channel_mode = alc883_3ST_2ch_modes,
10243 .input_mux = &alc883_lenovo_101e_capture_source,
10244 .unsol_event = alc883_lenovo_101e_unsol_event,
10245 .init_hook = alc883_lenovo_101e_all_automute,
10246 },
Kailang Yang272a5272007-05-14 11:00:38 +020010247 [ALC883_LENOVO_NB0763] = {
10248 .mixers = { alc883_lenovo_nb0763_mixer },
10249 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10250 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10251 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010252 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10253 .channel_mode = alc883_3ST_2ch_modes,
10254 .need_dac_fix = 1,
10255 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010256 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010257 .setup = alc883_medion_md2_setup,
10258 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010259 },
10260 [ALC888_LENOVO_MS7195_DIG] = {
10261 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10262 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10263 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10264 .dac_nids = alc883_dac_nids,
10265 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010266 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10267 .channel_mode = alc883_3ST_6ch_modes,
10268 .need_dac_fix = 1,
10269 .input_mux = &alc883_capture_source,
10270 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10271 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010272 },
10273 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010274 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010275 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10276 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10277 .dac_nids = alc883_dac_nids,
10278 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010279 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10280 .channel_mode = alc883_3ST_2ch_modes,
10281 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010282 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010283 .setup = alc883_haier_w66_setup,
10284 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010285 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010286 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010287 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010288 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10290 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010291 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10292 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010293 .need_dac_fix = 1,
10294 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010295 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010296 .setup = alc888_3st_hp_setup,
10297 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010298 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010299 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010300 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010301 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10303 .dac_nids = alc883_dac_nids,
10304 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010305 .dig_in_nid = ALC883_DIGIN_NID,
10306 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10307 .channel_mode = alc883_sixstack_modes,
10308 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010309 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010310 .setup = alc888_6st_dell_setup,
10311 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010312 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010313 [ALC883_MITAC] = {
10314 .mixers = { alc883_mitac_mixer },
10315 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10316 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10317 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010318 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10319 .channel_mode = alc883_3ST_2ch_modes,
10320 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010321 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010322 .setup = alc883_mitac_setup,
10323 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010324 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010325 [ALC883_FUJITSU_PI2515] = {
10326 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10327 .init_verbs = { alc883_init_verbs,
10328 alc883_2ch_fujitsu_pi2515_verbs},
10329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10330 .dac_nids = alc883_dac_nids,
10331 .dig_out_nid = ALC883_DIGOUT_NID,
10332 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10333 .channel_mode = alc883_3ST_2ch_modes,
10334 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010335 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010336 .setup = alc883_2ch_fujitsu_pi2515_setup,
10337 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010338 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010339 [ALC888_FUJITSU_XA3530] = {
10340 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10341 .init_verbs = { alc883_init_verbs,
10342 alc888_fujitsu_xa3530_verbs },
10343 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10344 .dac_nids = alc883_dac_nids,
10345 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10346 .adc_nids = alc883_adc_nids_rev,
10347 .capsrc_nids = alc883_capsrc_nids_rev,
10348 .dig_out_nid = ALC883_DIGOUT_NID,
10349 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10350 .channel_mode = alc888_4ST_8ch_intel_modes,
10351 .num_mux_defs =
10352 ARRAY_SIZE(alc888_2_capture_sources),
10353 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010354 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010355 .setup = alc888_fujitsu_xa3530_setup,
10356 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010357 },
Kailang Yange2757d52008-08-26 13:17:46 +020010358 [ALC888_LENOVO_SKY] = {
10359 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10360 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10361 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10362 .dac_nids = alc883_dac_nids,
10363 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010364 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10365 .channel_mode = alc883_sixstack_modes,
10366 .need_dac_fix = 1,
10367 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010368 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010369 .setup = alc888_lenovo_sky_setup,
10370 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010371 },
10372 [ALC888_ASUS_M90V] = {
10373 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10374 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10375 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10376 .dac_nids = alc883_dac_nids,
10377 .dig_out_nid = ALC883_DIGOUT_NID,
10378 .dig_in_nid = ALC883_DIGIN_NID,
10379 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10380 .channel_mode = alc883_3ST_6ch_modes,
10381 .need_dac_fix = 1,
10382 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010383 .unsol_event = alc_sku_unsol_event,
10384 .setup = alc883_mode2_setup,
10385 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010386 },
10387 [ALC888_ASUS_EEE1601] = {
10388 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010389 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010390 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10391 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10392 .dac_nids = alc883_dac_nids,
10393 .dig_out_nid = ALC883_DIGOUT_NID,
10394 .dig_in_nid = ALC883_DIGIN_NID,
10395 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10396 .channel_mode = alc883_3ST_2ch_modes,
10397 .need_dac_fix = 1,
10398 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010399 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010400 .init_hook = alc883_eee1601_inithook,
10401 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010402 [ALC1200_ASUS_P5Q] = {
10403 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10404 .init_verbs = { alc883_init_verbs },
10405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10406 .dac_nids = alc883_dac_nids,
10407 .dig_out_nid = ALC1200_DIGOUT_NID,
10408 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010409 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010410 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10411 .channel_mode = alc883_sixstack_modes,
10412 .input_mux = &alc883_capture_source,
10413 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010414 [ALC889A_MB31] = {
10415 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10416 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10417 alc880_gpio1_init_verbs },
10418 .adc_nids = alc883_adc_nids,
10419 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010420 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010421 .dac_nids = alc883_dac_nids,
10422 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10423 .channel_mode = alc889A_mb31_6ch_modes,
10424 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10425 .input_mux = &alc889A_mb31_capture_source,
10426 .dig_out_nid = ALC883_DIGOUT_NID,
10427 .unsol_event = alc889A_mb31_unsol_event,
10428 .init_hook = alc889A_mb31_automute,
10429 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010430 [ALC883_SONY_VAIO_TT] = {
10431 .mixers = { alc883_vaiott_mixer },
10432 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10433 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10434 .dac_nids = alc883_dac_nids,
10435 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10436 .channel_mode = alc883_3ST_2ch_modes,
10437 .input_mux = &alc883_capture_source,
10438 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010439 .setup = alc883_vaiott_setup,
10440 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010441 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010442};
10443
10444
10445/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010446 * Pin config fixes
10447 */
10448enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010449 PINFIX_ABIT_AW9D_MAX,
10450 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010451};
10452
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010453static const struct alc_fixup alc882_fixups[] = {
10454 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010455 .pins = (const struct alc_pincfg[]) {
10456 { 0x15, 0x01080104 }, /* side */
10457 { 0x16, 0x01011012 }, /* rear */
10458 { 0x17, 0x01016011 }, /* clfe */
10459 { }
10460 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010461 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010462 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010463 .verbs = (const struct hda_verb[]) {
10464 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10465 {}
10466 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010467 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010468};
10469
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010470static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010471 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010472 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10473 {}
10474};
10475
10476/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010477 * BIOS auto configuration
10478 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010479static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10480 const struct auto_pin_cfg *cfg)
10481{
10482 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10483}
10484
Takashi Iwai4953550a2009-06-30 15:28:30 +020010485static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010486 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010487 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010488{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010489 int idx;
10490
Takashi Iwai489008c2010-04-07 09:06:00 +020010491 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010492 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010493
Takashi Iwai489008c2010-04-07 09:06:00 +020010494 if (dac == 0x25)
10495 idx = 4;
10496 else if (dac >= 0x02 && dac <= 0x05)
10497 idx = dac - 2;
10498 else
10499 return;
10500 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010501}
10502
Takashi Iwai4953550a2009-06-30 15:28:30 +020010503static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010504{
10505 struct alc_spec *spec = codec->spec;
10506 int i;
10507
10508 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010509 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010510 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010511 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010512 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010513 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010514 }
10515}
10516
Takashi Iwai4953550a2009-06-30 15:28:30 +020010517static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010518{
10519 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010520 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010522 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010523 if (pin) {
10524 dac = spec->multiout.hp_nid;
10525 if (!dac)
10526 dac = spec->multiout.dac_nids[0]; /* to front */
10527 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10528 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010529 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010530 if (pin) {
10531 dac = spec->multiout.extra_out_nid[0];
10532 if (!dac)
10533 dac = spec->multiout.dac_nids[0]; /* to front */
10534 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10535 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010536}
10537
Takashi Iwai4953550a2009-06-30 15:28:30 +020010538static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010539{
10540 struct alc_spec *spec = codec->spec;
10541 int i;
10542
10543 for (i = 0; i < AUTO_PIN_LAST; i++) {
10544 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010545 if (!nid)
10546 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010547 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010548 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10549 snd_hda_codec_write(codec, nid, 0,
10550 AC_VERB_SET_AMP_GAIN_MUTE,
10551 AMP_OUT_MUTE);
10552 }
10553}
10554
10555static void alc882_auto_init_input_src(struct hda_codec *codec)
10556{
10557 struct alc_spec *spec = codec->spec;
10558 int c;
10559
10560 for (c = 0; c < spec->num_adc_nids; c++) {
10561 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10562 hda_nid_t nid = spec->capsrc_nids[c];
10563 unsigned int mux_idx;
10564 const struct hda_input_mux *imux;
10565 int conns, mute, idx, item;
10566
10567 conns = snd_hda_get_connections(codec, nid, conn_list,
10568 ARRAY_SIZE(conn_list));
10569 if (conns < 0)
10570 continue;
10571 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10572 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010573 if (!imux->num_items && mux_idx > 0)
10574 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010575 for (idx = 0; idx < conns; idx++) {
10576 /* if the current connection is the selected one,
10577 * unmute it as default - otherwise mute it
10578 */
10579 mute = AMP_IN_MUTE(idx);
10580 for (item = 0; item < imux->num_items; item++) {
10581 if (imux->items[item].index == idx) {
10582 if (spec->cur_mux[c] == item)
10583 mute = AMP_IN_UNMUTE(idx);
10584 break;
10585 }
10586 }
10587 /* check if we have a selector or mixer
10588 * we could check for the widget type instead, but
10589 * just check for Amp-In presence (in case of mixer
10590 * without amp-in there is something wrong, this
10591 * function shouldn't be used or capsrc nid is wrong)
10592 */
10593 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010594 snd_hda_codec_write(codec, nid, 0,
10595 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010596 mute);
10597 else if (mute != AMP_IN_MUTE(idx))
10598 snd_hda_codec_write(codec, nid, 0,
10599 AC_VERB_SET_CONNECT_SEL,
10600 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010601 }
10602 }
10603}
10604
Takashi Iwai4953550a2009-06-30 15:28:30 +020010605/* add mic boosts if needed */
10606static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010607{
10608 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010609 int err;
10610 hda_nid_t nid;
10611
10612 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10613 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10614 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10615 "Mic Boost",
10616 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10617 if (err < 0)
10618 return err;
10619 }
10620 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10621 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10622 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10623 "Front Mic Boost",
10624 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10625 if (err < 0)
10626 return err;
10627 }
10628 return 0;
10629}
10630
10631/* almost identical with ALC880 parser... */
10632static int alc882_parse_auto_config(struct hda_codec *codec)
10633{
10634 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010635 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010636 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010637
Takashi Iwai05f5f472009-08-25 13:10:18 +020010638 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10639 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010640 if (err < 0)
10641 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010642 if (!spec->autocfg.line_outs)
10643 return 0; /* can't find valid BIOS pin config */
10644
10645 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10646 if (err < 0)
10647 return err;
10648 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10649 if (err < 0)
10650 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010651 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10652 "Headphone");
10653 if (err < 0)
10654 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010655 err = alc880_auto_create_extra_out(spec,
10656 spec->autocfg.speaker_pins[0],
10657 "Speaker");
10658 if (err < 0)
10659 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010660 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10661 if (err < 0)
10662 return err;
10663
10664 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10665
Takashi Iwai757899a2010-07-30 10:48:14 +020010666 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010667
10668 if (spec->kctls.list)
10669 add_mixer(spec, spec->kctls.list);
10670
10671 add_verb(spec, alc883_auto_init_verbs);
10672 /* if ADC 0x07 is available, initialize it, too */
10673 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10674 add_verb(spec, alc882_adc1_init_verbs);
10675
10676 spec->num_mux_defs = 1;
10677 spec->input_mux = &spec->private_imux[0];
10678
Kailang Yang6227cdc2010-02-25 08:36:52 +010010679 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010680
10681 err = alc_auto_add_mic_boost(codec);
10682 if (err < 0)
10683 return err;
10684
Takashi Iwai776e1842007-08-29 15:07:11 +020010685 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010686}
10687
10688/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010689static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010690{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010691 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010692 alc882_auto_init_multi_out(codec);
10693 alc882_auto_init_hp_out(codec);
10694 alc882_auto_init_analog_input(codec);
10695 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010696 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010697 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010698 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010699}
10700
Takashi Iwai4953550a2009-06-30 15:28:30 +020010701static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010702{
10703 struct alc_spec *spec;
10704 int err, board_config;
10705
10706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10707 if (spec == NULL)
10708 return -ENOMEM;
10709
10710 codec->spec = spec;
10711
Kailang Yangda00c242010-03-19 11:23:45 +010010712 alc_auto_parse_customize_define(codec);
10713
Takashi Iwai4953550a2009-06-30 15:28:30 +020010714 switch (codec->vendor_id) {
10715 case 0x10ec0882:
10716 case 0x10ec0885:
10717 break;
10718 default:
10719 /* ALC883 and variants */
10720 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10721 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010722 }
10723
Takashi Iwai4953550a2009-06-30 15:28:30 +020010724 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10725 alc882_models,
10726 alc882_cfg_tbl);
10727
10728 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10729 board_config = snd_hda_check_board_codec_sid_config(codec,
10730 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10731
10732 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010733 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010734 codec->chip_name);
10735 board_config = ALC882_AUTO;
10736 }
10737
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010738 if (board_config == ALC882_AUTO)
10739 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010740
10741 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010742 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010743 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010744 if (err < 0) {
10745 alc_free(codec);
10746 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010747 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010748 printk(KERN_INFO
10749 "hda_codec: Cannot set up configuration "
10750 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010751 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752 }
10753 }
10754
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010755 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010756 err = snd_hda_attach_beep_device(codec, 0x1);
10757 if (err < 0) {
10758 alc_free(codec);
10759 return err;
10760 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010761 }
10762
Takashi Iwai4953550a2009-06-30 15:28:30 +020010763 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010764 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010765
Takashi Iwai4953550a2009-06-30 15:28:30 +020010766 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10767 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10768 /* FIXME: setup DAC5 */
10769 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10770 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10771
10772 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10773 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10774
Takashi Iwai4953550a2009-06-30 15:28:30 +020010775 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010776 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010777 spec->num_adc_nids = 0;
10778 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010779 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010780 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010781 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010782 hda_nid_t nid = alc882_adc_nids[i];
10783 unsigned int wcap = get_wcaps(codec, nid);
10784 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010785 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010786 if (wcap != AC_WID_AUD_IN)
10787 continue;
10788 spec->private_adc_nids[spec->num_adc_nids] = nid;
10789 err = snd_hda_get_connections(codec, nid, &cap, 1);
10790 if (err < 0)
10791 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010792 err = snd_hda_get_connections(codec, cap, items,
10793 ARRAY_SIZE(items));
10794 if (err < 0)
10795 continue;
10796 for (j = 0; j < imux->num_items; j++)
10797 if (imux->items[j].index >= err)
10798 break;
10799 if (j < imux->num_items)
10800 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010801 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10802 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010803 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010804 spec->adc_nids = spec->private_adc_nids;
10805 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010806 }
10807
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010808 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010809
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010810 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010811 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010812
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010813 if (board_config == ALC882_AUTO)
10814 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10815
Takashi Iwai2134ea42008-01-10 16:53:55 +010010816 spec->vmaster_nid = 0x0c;
10817
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010818 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010819 if (board_config == ALC882_AUTO)
10820 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010821#ifdef CONFIG_SND_HDA_POWER_SAVE
10822 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010823 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010824#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010825
10826 return 0;
10827}
10828
Takashi Iwai4953550a2009-06-30 15:28:30 +020010829
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010830/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010831 * ALC262 support
10832 */
10833
10834#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10835#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10836
10837#define alc262_dac_nids alc260_dac_nids
10838#define alc262_adc_nids alc882_adc_nids
10839#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010840#define alc262_capsrc_nids alc882_capsrc_nids
10841#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010842
10843#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010844#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010845
Kailang Yang4e555fe2008-08-26 13:05:55 +020010846static hda_nid_t alc262_dmic_adc_nids[1] = {
10847 /* ADC0 */
10848 0x09
10849};
10850
10851static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10852
Kailang Yangdf694da2005-12-05 19:42:22 +010010853static struct snd_kcontrol_new alc262_base_mixer[] = {
10854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10855 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10856 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10857 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10858 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10859 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10860 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010862 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010863 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10864 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010865 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010866 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10867 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10868 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10869 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010870 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010871};
10872
Takashi Iwaice875f02008-01-28 18:17:43 +010010873/* update HP, line and mono-out pins according to the master switch */
10874static void alc262_hp_master_update(struct hda_codec *codec)
10875{
10876 struct alc_spec *spec = codec->spec;
10877 int val = spec->master_sw;
10878
10879 /* HP & line-out */
10880 snd_hda_codec_write_cache(codec, 0x1b, 0,
10881 AC_VERB_SET_PIN_WIDGET_CONTROL,
10882 val ? PIN_HP : 0);
10883 snd_hda_codec_write_cache(codec, 0x15, 0,
10884 AC_VERB_SET_PIN_WIDGET_CONTROL,
10885 val ? PIN_HP : 0);
10886 /* mono (speaker) depending on the HP jack sense */
10887 val = val && !spec->jack_present;
10888 snd_hda_codec_write_cache(codec, 0x16, 0,
10889 AC_VERB_SET_PIN_WIDGET_CONTROL,
10890 val ? PIN_OUT : 0);
10891}
10892
10893static void alc262_hp_bpc_automute(struct hda_codec *codec)
10894{
10895 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010896
10897 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010898 alc262_hp_master_update(codec);
10899}
10900
10901static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10902{
10903 if ((res >> 26) != ALC880_HP_EVENT)
10904 return;
10905 alc262_hp_bpc_automute(codec);
10906}
10907
10908static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10909{
10910 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010911
10912 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010913 alc262_hp_master_update(codec);
10914}
10915
10916static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10917 unsigned int res)
10918{
10919 if ((res >> 26) != ALC880_HP_EVENT)
10920 return;
10921 alc262_hp_wildwest_automute(codec);
10922}
10923
Takashi Iwaib72519b2009-05-08 14:31:55 +020010924#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010925
10926static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10927 struct snd_ctl_elem_value *ucontrol)
10928{
10929 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10930 struct alc_spec *spec = codec->spec;
10931 int val = !!*ucontrol->value.integer.value;
10932
10933 if (val == spec->master_sw)
10934 return 0;
10935 spec->master_sw = val;
10936 alc262_hp_master_update(codec);
10937 return 1;
10938}
10939
Takashi Iwaib72519b2009-05-08 14:31:55 +020010940#define ALC262_HP_MASTER_SWITCH \
10941 { \
10942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10943 .name = "Master Playback Switch", \
10944 .info = snd_ctl_boolean_mono_info, \
10945 .get = alc262_hp_master_sw_get, \
10946 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010947 }, \
10948 { \
10949 .iface = NID_MAPPING, \
10950 .name = "Master Playback Switch", \
10951 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010952 }
10953
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010954
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010955static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010956 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010957 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10958 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010960 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10961 HDA_OUTPUT),
10962 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10963 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10965 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010966 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010967 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10968 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010969 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010970 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10971 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10972 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10973 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10975 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10976 { } /* end */
10977};
10978
Kailang Yangcd7509a2007-01-26 18:33:17 +010010979static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010980 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010981 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10983 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10984 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010985 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10986 HDA_OUTPUT),
10987 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10988 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010989 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10990 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010991 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010992 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10993 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10994 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10995 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010996 { } /* end */
10997};
10998
10999static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11000 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11001 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011002 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011003 { } /* end */
11004};
11005
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011006/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011007static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011008{
11009 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011010
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011011 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011012 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011013}
11014
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011015static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011016 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11017 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011018 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11022 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11023 { } /* end */
11024};
11025
11026static struct hda_verb alc262_hp_t5735_verbs[] = {
11027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11029
11030 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11031 { }
11032};
11033
Kailang Yang8c427222008-01-10 13:03:59 +010011034static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011035 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011037 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11038 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011039 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11040 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11041 { } /* end */
11042};
11043
11044static struct hda_verb alc262_hp_rp5700_verbs[] = {
11045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11046 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11047 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11048 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11050 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11052 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11054 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11055 {}
11056};
11057
11058static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11059 .num_items = 1,
11060 .items = {
11061 { "Line", 0x1 },
11062 },
11063};
11064
Takashi Iwai42171c12009-05-08 14:11:43 +020011065/* bind hp and internal speaker mute (with plug check) as master switch */
11066static void alc262_hippo_master_update(struct hda_codec *codec)
11067{
11068 struct alc_spec *spec = codec->spec;
11069 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11070 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11071 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11072 unsigned int mute;
11073
11074 /* HP */
11075 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11076 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11077 HDA_AMP_MUTE, mute);
11078 /* mute internal speaker per jack sense */
11079 if (spec->jack_present)
11080 mute = HDA_AMP_MUTE;
11081 if (line_nid)
11082 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11083 HDA_AMP_MUTE, mute);
11084 if (speaker_nid && speaker_nid != line_nid)
11085 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11086 HDA_AMP_MUTE, mute);
11087}
11088
11089#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11090
11091static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11092 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011093{
11094 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011095 struct alc_spec *spec = codec->spec;
11096 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011097
Takashi Iwai42171c12009-05-08 14:11:43 +020011098 if (val == spec->master_sw)
11099 return 0;
11100 spec->master_sw = val;
11101 alc262_hippo_master_update(codec);
11102 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011103}
Takashi Iwai5b319542007-07-26 11:49:22 +020011104
Takashi Iwai42171c12009-05-08 14:11:43 +020011105#define ALC262_HIPPO_MASTER_SWITCH \
11106 { \
11107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11108 .name = "Master Playback Switch", \
11109 .info = snd_ctl_boolean_mono_info, \
11110 .get = alc262_hippo_master_sw_get, \
11111 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011112 }, \
11113 { \
11114 .iface = NID_MAPPING, \
11115 .name = "Master Playback Switch", \
11116 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11117 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011118 }
11119
11120static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11121 ALC262_HIPPO_MASTER_SWITCH,
11122 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11123 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11124 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11127 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11128 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11129 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11130 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11131 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11132 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11133 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11134 { } /* end */
11135};
11136
11137static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11138 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11139 ALC262_HIPPO_MASTER_SWITCH,
11140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11149 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11150 { } /* end */
11151};
11152
11153/* mute/unmute internal speaker according to the hp jack and mute state */
11154static void alc262_hippo_automute(struct hda_codec *codec)
11155{
11156 struct alc_spec *spec = codec->spec;
11157 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011158
Wu Fengguang864f92b2009-11-18 12:38:02 +080011159 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011160 alc262_hippo_master_update(codec);
11161}
11162
11163static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11164{
11165 if ((res >> 26) != ALC880_HP_EVENT)
11166 return;
11167 alc262_hippo_automute(codec);
11168}
11169
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011170static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011171{
11172 struct alc_spec *spec = codec->spec;
11173
11174 spec->autocfg.hp_pins[0] = 0x15;
11175 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011176}
11177
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011178static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011179{
11180 struct alc_spec *spec = codec->spec;
11181
11182 spec->autocfg.hp_pins[0] = 0x1b;
11183 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011184}
11185
11186
Kailang Yang272a5272007-05-14 11:00:38 +020011187static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011188 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011189 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11192 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11193 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11194 { } /* end */
11195};
11196
Kailang Yang83c34212007-07-05 11:43:05 +020011197static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011198 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11199 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11201 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11203 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11204 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11205 { } /* end */
11206};
Kailang Yang272a5272007-05-14 11:00:38 +020011207
Tony Vroonba340e82009-02-02 19:01:30 +000011208static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11209 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11210 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11211 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11212 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11213 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11214 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11217 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11218 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11220 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11221 { } /* end */
11222};
11223
11224static struct hda_verb alc262_tyan_verbs[] = {
11225 /* Headphone automute */
11226 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11227 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11229
11230 /* P11 AUX_IN, white 4-pin connector */
11231 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11232 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11233 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11234 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11235
11236 {}
11237};
11238
11239/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011240static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011241{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011242 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011243
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011244 spec->autocfg.hp_pins[0] = 0x1b;
11245 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011246}
11247
Tony Vroonba340e82009-02-02 19:01:30 +000011248
Kailang Yangdf694da2005-12-05 19:42:22 +010011249#define alc262_capture_mixer alc882_capture_mixer
11250#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11251
11252/*
11253 * generic initialization of ADC, input mixers and output mixers
11254 */
11255static struct hda_verb alc262_init_verbs[] = {
11256 /*
11257 * Unmute ADC0-2 and set the default input to mic-in
11258 */
11259 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11260 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11261 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11262 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11263 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11264 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11265
Takashi Iwaicb53c622007-08-10 17:21:45 +020011266 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011267 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011268 * Note: PASD motherboards uses the Line In 2 as the input for
11269 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011270 */
11271 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011272 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11273 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11274 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11275 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11276 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011277
11278 /*
11279 * Set up output mixers (0x0c - 0x0e)
11280 */
11281 /* set vol=0 to output mixers */
11282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11283 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11285 /* set up input amps for analog loopback */
11286 /* Amp Indices: DAC = 0, mixer = 1 */
11287 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11289 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11290 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11291 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11292 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11293
11294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11298 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11299 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11300
11301 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11302 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11303 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11304 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011306
Kailang Yangdf694da2005-12-05 19:42:22 +010011307 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11308 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011309
Kailang Yangdf694da2005-12-05 19:42:22 +010011310 /* FIXME: use matrix-type input source selection */
11311 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11312 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11314 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11315 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11317 /* Input mixer2 */
11318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11319 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11320 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11321 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11322 /* Input mixer3 */
11323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11324 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11325 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011326 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011327
11328 { }
11329};
11330
Kailang Yang4e555fe2008-08-26 13:05:55 +020011331static struct hda_verb alc262_eapd_verbs[] = {
11332 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11333 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11334 { }
11335};
11336
Kailang Yangccc656c2006-10-17 12:32:26 +020011337static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11339 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11340 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11341
11342 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11343 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11344 {}
11345};
11346
Kailang Yang272a5272007-05-14 11:00:38 +020011347static struct hda_verb alc262_sony_unsol_verbs[] = {
11348 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11349 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11351
11352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011354 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011355};
11356
Kailang Yang4e555fe2008-08-26 13:05:55 +020011357static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11358 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11359 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11361 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011363 { } /* end */
11364};
11365
11366static struct hda_verb alc262_toshiba_s06_verbs[] = {
11367 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11369 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11370 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11371 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11372 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11373 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11374 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11375 {}
11376};
11377
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011378static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011379{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011380 struct alc_spec *spec = codec->spec;
11381
11382 spec->autocfg.hp_pins[0] = 0x15;
11383 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011384 spec->ext_mic.pin = 0x18;
11385 spec->ext_mic.mux_idx = 0;
11386 spec->int_mic.pin = 0x12;
11387 spec->int_mic.mux_idx = 9;
11388 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011389}
11390
Takashi Iwai834be882006-03-01 14:16:17 +010011391/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011392 * nec model
11393 * 0x15 = headphone
11394 * 0x16 = internal speaker
11395 * 0x18 = external mic
11396 */
11397
11398static struct snd_kcontrol_new alc262_nec_mixer[] = {
11399 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11400 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11401
11402 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11403 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11404 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11405
11406 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11408 { } /* end */
11409};
11410
11411static struct hda_verb alc262_nec_verbs[] = {
11412 /* Unmute Speaker */
11413 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11414
11415 /* Headphone */
11416 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11418
11419 /* External mic to headphone */
11420 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11421 /* External mic to speaker */
11422 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11423 {}
11424};
11425
11426/*
Takashi Iwai834be882006-03-01 14:16:17 +010011427 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011428 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11429 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011430 */
11431
11432#define ALC_HP_EVENT 0x37
11433
11434static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11435 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11436 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011437 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11438 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011439 {}
11440};
11441
Jiang zhe0e31daf2008-03-20 12:12:39 +010011442static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11443 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11445 {}
11446};
11447
Daniel T Chene2595322009-12-19 18:19:02 -050011448static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11449 /* Front Mic pin: input vref at 50% */
11450 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11451 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11452 {}
11453};
11454
Takashi Iwai834be882006-03-01 14:16:17 +010011455static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011456 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011457 .items = {
11458 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011459 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011460 { "CD", 0x4 },
11461 },
11462};
11463
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011464static struct hda_input_mux alc262_HP_capture_source = {
11465 .num_items = 5,
11466 .items = {
11467 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011468 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011469 { "Line", 0x2 },
11470 { "CD", 0x4 },
11471 { "AUX IN", 0x6 },
11472 },
11473};
11474
zhejiangaccbe492007-08-31 12:36:05 +020011475static struct hda_input_mux alc262_HP_D7000_capture_source = {
11476 .num_items = 4,
11477 .items = {
11478 { "Mic", 0x0 },
11479 { "Front Mic", 0x2 },
11480 { "Line", 0x1 },
11481 { "CD", 0x4 },
11482 },
11483};
11484
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011485/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011486static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11487{
11488 struct alc_spec *spec = codec->spec;
11489 unsigned int mute;
11490
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011491 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011492 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11493 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011494 spec->sense_updated = 1;
11495 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011496 /* unmute internal speaker only if both HPs are unplugged and
11497 * master switch is on
11498 */
11499 if (spec->jack_present)
11500 mute = HDA_AMP_MUTE;
11501 else
Takashi Iwai834be882006-03-01 14:16:17 +010011502 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011503 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11504 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011505}
11506
11507/* unsolicited event for HP jack sensing */
11508static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11509 unsigned int res)
11510{
11511 if ((res >> 26) != ALC_HP_EVENT)
11512 return;
11513 alc262_fujitsu_automute(codec, 1);
11514}
11515
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011516static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11517{
11518 alc262_fujitsu_automute(codec, 1);
11519}
11520
Takashi Iwai834be882006-03-01 14:16:17 +010011521/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011522static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11523 .ops = &snd_hda_bind_vol,
11524 .values = {
11525 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11526 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11527 0
11528 },
11529};
Takashi Iwai834be882006-03-01 14:16:17 +010011530
Jiang zhe0e31daf2008-03-20 12:12:39 +010011531/* mute/unmute internal speaker according to the hp jack and mute state */
11532static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11533{
11534 struct alc_spec *spec = codec->spec;
11535 unsigned int mute;
11536
11537 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011538 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011539 spec->sense_updated = 1;
11540 }
11541 if (spec->jack_present) {
11542 /* mute internal speaker */
11543 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11544 HDA_AMP_MUTE, HDA_AMP_MUTE);
11545 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11546 HDA_AMP_MUTE, HDA_AMP_MUTE);
11547 } else {
11548 /* unmute internal speaker if necessary */
11549 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11550 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11551 HDA_AMP_MUTE, mute);
11552 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11553 HDA_AMP_MUTE, mute);
11554 }
11555}
11556
11557/* unsolicited event for HP jack sensing */
11558static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11559 unsigned int res)
11560{
11561 if ((res >> 26) != ALC_HP_EVENT)
11562 return;
11563 alc262_lenovo_3000_automute(codec, 1);
11564}
11565
Takashi Iwai8de56b72009-07-24 16:51:47 +020011566static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11567 int dir, int idx, long *valp)
11568{
11569 int i, change = 0;
11570
11571 for (i = 0; i < 2; i++, valp++)
11572 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11573 HDA_AMP_MUTE,
11574 *valp ? 0 : HDA_AMP_MUTE);
11575 return change;
11576}
11577
Takashi Iwai834be882006-03-01 14:16:17 +010011578/* bind hp and internal speaker mute (with plug check) */
11579static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11580 struct snd_ctl_elem_value *ucontrol)
11581{
11582 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11583 long *valp = ucontrol->value.integer.value;
11584 int change;
11585
Takashi Iwai8de56b72009-07-24 16:51:47 +020011586 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11587 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011588 if (change)
11589 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011590 return change;
11591}
11592
11593static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011594 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011595 {
11596 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11597 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011598 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011599 .info = snd_hda_mixer_amp_switch_info,
11600 .get = snd_hda_mixer_amp_switch_get,
11601 .put = alc262_fujitsu_master_sw_put,
11602 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11603 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011604 {
11605 .iface = NID_MAPPING,
11606 .name = "Master Playback Switch",
11607 .private_value = 0x1b,
11608 },
Takashi Iwai834be882006-03-01 14:16:17 +010011609 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11610 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11611 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011614 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11615 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11616 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011617 { } /* end */
11618};
11619
Jiang zhe0e31daf2008-03-20 12:12:39 +010011620/* bind hp and internal speaker mute (with plug check) */
11621static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11622 struct snd_ctl_elem_value *ucontrol)
11623{
11624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11625 long *valp = ucontrol->value.integer.value;
11626 int change;
11627
Takashi Iwai8de56b72009-07-24 16:51:47 +020011628 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011629 if (change)
11630 alc262_lenovo_3000_automute(codec, 0);
11631 return change;
11632}
11633
11634static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11635 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11636 {
11637 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11638 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011639 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011640 .info = snd_hda_mixer_amp_switch_info,
11641 .get = snd_hda_mixer_amp_switch_get,
11642 .put = alc262_lenovo_3000_master_sw_put,
11643 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11644 },
11645 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11646 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11647 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11650 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11651 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11652 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11653 { } /* end */
11654};
11655
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011656static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11657 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011658 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11660 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11661 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11662 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11663 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11664 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11665 { } /* end */
11666};
11667
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011668/* additional init verbs for Benq laptops */
11669static struct hda_verb alc262_EAPD_verbs[] = {
11670 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11671 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11672 {}
11673};
11674
Kailang Yang83c34212007-07-05 11:43:05 +020011675static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11676 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11677 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11678
11679 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11680 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11681 {}
11682};
11683
Tobin Davisf651b502007-10-26 12:40:47 +020011684/* Samsung Q1 Ultra Vista model setup */
11685static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011686 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11687 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11690 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011691 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011692 { } /* end */
11693};
11694
11695static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011696 /* output mixer */
11697 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11698 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11699 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11700 /* speaker */
11701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11704 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11705 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11709 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11710 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11711 /* internal mic */
11712 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11713 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11714 /* ADC, choose mic */
11715 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11716 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11717 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11718 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11719 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11720 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11721 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11722 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11723 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11724 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011725 {}
11726};
11727
Tobin Davisf651b502007-10-26 12:40:47 +020011728/* mute/unmute internal speaker according to the hp jack and mute state */
11729static void alc262_ultra_automute(struct hda_codec *codec)
11730{
11731 struct alc_spec *spec = codec->spec;
11732 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011733
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011734 mute = 0;
11735 /* auto-mute only when HP is used as HP */
11736 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011737 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011738 if (spec->jack_present)
11739 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011740 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011741 /* mute/unmute internal speaker */
11742 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11743 HDA_AMP_MUTE, mute);
11744 /* mute/unmute HP */
11745 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11746 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011747}
11748
11749/* unsolicited event for HP jack sensing */
11750static void alc262_ultra_unsol_event(struct hda_codec *codec,
11751 unsigned int res)
11752{
11753 if ((res >> 26) != ALC880_HP_EVENT)
11754 return;
11755 alc262_ultra_automute(codec);
11756}
11757
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011758static struct hda_input_mux alc262_ultra_capture_source = {
11759 .num_items = 2,
11760 .items = {
11761 { "Mic", 0x1 },
11762 { "Headphone", 0x7 },
11763 },
11764};
11765
11766static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11767 struct snd_ctl_elem_value *ucontrol)
11768{
11769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11770 struct alc_spec *spec = codec->spec;
11771 int ret;
11772
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011773 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011774 if (!ret)
11775 return 0;
11776 /* reprogram the HP pin as mic or HP according to the input source */
11777 snd_hda_codec_write_cache(codec, 0x15, 0,
11778 AC_VERB_SET_PIN_WIDGET_CONTROL,
11779 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11780 alc262_ultra_automute(codec); /* mute/unmute HP */
11781 return ret;
11782}
11783
11784static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11785 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11786 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11787 {
11788 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11789 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011790 .info = alc_mux_enum_info,
11791 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011792 .put = alc262_ultra_mux_enum_put,
11793 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011794 {
11795 .iface = NID_MAPPING,
11796 .name = "Capture Source",
11797 .private_value = 0x15,
11798 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011799 { } /* end */
11800};
11801
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011802/* We use two mixers depending on the output pin; 0x16 is a mono output
11803 * and thus it's bound with a different mixer.
11804 * This function returns which mixer amp should be used.
11805 */
11806static int alc262_check_volbit(hda_nid_t nid)
11807{
11808 if (!nid)
11809 return 0;
11810 else if (nid == 0x16)
11811 return 2;
11812 else
11813 return 1;
11814}
11815
11816static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11817 const char *pfx, int *vbits)
11818{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011819 unsigned long val;
11820 int vbit;
11821
11822 vbit = alc262_check_volbit(nid);
11823 if (!vbit)
11824 return 0;
11825 if (*vbits & vbit) /* a volume control for this mixer already there */
11826 return 0;
11827 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011828 if (vbit == 2)
11829 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11830 else
11831 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011832 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011833}
11834
11835static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11836 const char *pfx)
11837{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011838 unsigned long val;
11839
11840 if (!nid)
11841 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011842 if (nid == 0x16)
11843 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11844 else
11845 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011846 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011847}
11848
Kailang Yangdf694da2005-12-05 19:42:22 +010011849/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011850static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11851 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011852{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011853 const char *pfx;
11854 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011855 int err;
11856
11857 spec->multiout.num_dacs = 1; /* only use one dac */
11858 spec->multiout.dac_nids = spec->private_dac_nids;
11859 spec->multiout.dac_nids[0] = 2;
11860
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011861 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11862 pfx = "Master";
11863 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11864 pfx = "Speaker";
11865 else
11866 pfx = "Front";
11867 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11868 if (err < 0)
11869 return err;
11870 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11871 if (err < 0)
11872 return err;
11873 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11874 if (err < 0)
11875 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011876
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011877 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11878 alc262_check_volbit(cfg->speaker_pins[0]) |
11879 alc262_check_volbit(cfg->hp_pins[0]);
11880 if (vbits == 1 || vbits == 2)
11881 pfx = "Master"; /* only one mixer is used */
11882 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11883 pfx = "Speaker";
11884 else
11885 pfx = "Front";
11886 vbits = 0;
11887 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11888 if (err < 0)
11889 return err;
11890 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11891 &vbits);
11892 if (err < 0)
11893 return err;
11894 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11895 &vbits);
11896 if (err < 0)
11897 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011898 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011899}
11900
Takashi Iwai05f5f472009-08-25 13:10:18 +020011901#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011902 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011903
11904/*
11905 * generic initialization of ADC, input mixers and output mixers
11906 */
11907static struct hda_verb alc262_volume_init_verbs[] = {
11908 /*
11909 * Unmute ADC0-2 and set the default input to mic-in
11910 */
11911 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11912 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11913 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11914 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11915 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11916 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11917
Takashi Iwaicb53c622007-08-10 17:21:45 +020011918 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011919 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011920 * Note: PASD motherboards uses the Line In 2 as the input for
11921 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011922 */
11923 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011929
11930 /*
11931 * Set up output mixers (0x0c - 0x0f)
11932 */
11933 /* set vol=0 to output mixers */
11934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011937
Kailang Yangdf694da2005-12-05 19:42:22 +010011938 /* set up input amps for analog loopback */
11939 /* Amp Indices: DAC = 0, mixer = 1 */
11940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11946
11947 /* FIXME: use matrix-type input source selection */
11948 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11949 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11950 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11951 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11952 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11953 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11954 /* Input mixer2 */
11955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11957 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11958 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11959 /* Input mixer3 */
11960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11963 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11964
11965 { }
11966};
11967
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011968static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11969 /*
11970 * Unmute ADC0-2 and set the default input to mic-in
11971 */
11972 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11973 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11974 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11975 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11977 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11978
Takashi Iwaicb53c622007-08-10 17:21:45 +020011979 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011980 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011981 * Note: PASD motherboards uses the Line In 2 as the input for
11982 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011983 */
11984 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011985 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11986 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11987 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11988 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11989 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11990 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11991 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011992
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011993 /*
11994 * Set up output mixers (0x0c - 0x0e)
11995 */
11996 /* set vol=0 to output mixers */
11997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11999 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12000
12001 /* set up input amps for analog loopback */
12002 /* Amp Indices: DAC = 0, mixer = 1 */
12003 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12004 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12005 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12009
Takashi Iwaice875f02008-01-28 18:17:43 +010012010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12013
12014 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12015 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12016
12017 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12018 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12019
12020 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12021 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12024 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12025
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012026 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012029 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012030 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12031 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12032
12033
12034 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012035 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12036 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012037 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012038 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12039 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12040 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12041 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12042 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12043 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12044 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012046 /* Input mixer2 */
12047 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012048 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12049 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12054 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12055 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012056 /* Input mixer3 */
12057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12059 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12060 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12061 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12063 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012066
Takashi Iwaice875f02008-01-28 18:17:43 +010012067 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12068
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012069 { }
12070};
12071
Kailang Yangcd7509a2007-01-26 18:33:17 +010012072static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12073 /*
12074 * Unmute ADC0-2 and set the default input to mic-in
12075 */
12076 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12077 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12078 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12080 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12081 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12082
Takashi Iwaicb53c622007-08-10 17:21:45 +020012083 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012084 * mixer widget
12085 * Note: PASD motherboards uses the Line In 2 as the input for front
12086 * panel mic (mic 2)
12087 */
12088 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012089 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12090 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12091 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12092 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12093 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12094 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12095 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012097 /*
12098 * Set up output mixers (0x0c - 0x0e)
12099 */
12100 /* set vol=0 to output mixers */
12101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12102 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12103 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12104
12105 /* set up input amps for analog loopback */
12106 /* Amp Indices: DAC = 0, mixer = 1 */
12107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12112 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12113
12114
12115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12116 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12117 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12118 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12119 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12120 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12121 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12122
12123 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12124 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12125
12126 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12127 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12128
12129 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12131 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12132 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12133 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12134 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12135
12136 /* FIXME: use matrix-type input source selection */
12137 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12138 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12139 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12140 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12141 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12142 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12144 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12146 /* Input mixer2 */
12147 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12148 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12149 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12150 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12151 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12152 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12153 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12154 /* Input mixer3 */
12155 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12156 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12157 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12158 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12159 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12160 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12162
Takashi Iwaice875f02008-01-28 18:17:43 +010012163 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12164
Kailang Yangcd7509a2007-01-26 18:33:17 +010012165 { }
12166};
12167
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012168static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12169
12170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12171 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12172 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12173
12174 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12175 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12176 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12177 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12178
12179 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12180 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12181 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12182 {}
12183};
12184
12185
Takashi Iwaicb53c622007-08-10 17:21:45 +020012186#ifdef CONFIG_SND_HDA_POWER_SAVE
12187#define alc262_loopbacks alc880_loopbacks
12188#endif
12189
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012190/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012191#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12192#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12193#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12194#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12195
12196/*
12197 * BIOS auto configuration
12198 */
12199static int alc262_parse_auto_config(struct hda_codec *codec)
12200{
12201 struct alc_spec *spec = codec->spec;
12202 int err;
12203 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12204
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012205 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12206 alc262_ignore);
12207 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012208 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012209 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012210 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012211 spec->multiout.max_channels = 2;
12212 spec->no_analog = 1;
12213 goto dig_only;
12214 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012215 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012216 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012217 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12218 if (err < 0)
12219 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012220 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012221 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012222 return err;
12223
12224 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12225
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012226 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012227 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012228
Takashi Iwai603c4012008-07-30 15:01:44 +020012229 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012230 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012231
Takashi Iwaid88897e2008-10-31 15:01:37 +010012232 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012233 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012234 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012235
Takashi Iwai776e1842007-08-29 15:07:11 +020012236 err = alc_auto_add_mic_boost(codec);
12237 if (err < 0)
12238 return err;
12239
Kailang Yang6227cdc2010-02-25 08:36:52 +010012240 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012241
Kailang Yangdf694da2005-12-05 19:42:22 +010012242 return 1;
12243}
12244
12245#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12246#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12247#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012248#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012249
12250
12251/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012252static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012253{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012254 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012255 alc262_auto_init_multi_out(codec);
12256 alc262_auto_init_hp_out(codec);
12257 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012258 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012259 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012260 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012261 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012262}
12263
12264/*
12265 * configuration and preset
12266 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012267static const char *alc262_models[ALC262_MODEL_LAST] = {
12268 [ALC262_BASIC] = "basic",
12269 [ALC262_HIPPO] = "hippo",
12270 [ALC262_HIPPO_1] = "hippo_1",
12271 [ALC262_FUJITSU] = "fujitsu",
12272 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012273 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012274 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012275 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012276 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012277 [ALC262_BENQ_T31] = "benq-t31",
12278 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012279 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012280 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012281 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012282 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012283 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012284 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012285 [ALC262_AUTO] = "auto",
12286};
12287
12288static struct snd_pci_quirk alc262_cfg_tbl[] = {
12289 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012290 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012291 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12292 ALC262_HP_BPC),
12293 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12294 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012295 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12296 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012297 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012298 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012299 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012300 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012301 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012302 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012303 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012304 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012305 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12306 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12307 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012308 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12309 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012310 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012311 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012312 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012313 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012314 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012315 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012316 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012317 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012318#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012319 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12320 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012321#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012322 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012323 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012324 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012325 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012326 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012327 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012328 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12329 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012330 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012331 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012332 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012333 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012334 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012335 {}
12336};
12337
12338static struct alc_config_preset alc262_presets[] = {
12339 [ALC262_BASIC] = {
12340 .mixers = { alc262_base_mixer },
12341 .init_verbs = { alc262_init_verbs },
12342 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12343 .dac_nids = alc262_dac_nids,
12344 .hp_nid = 0x03,
12345 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12346 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012347 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012348 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012349 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012350 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012351 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012352 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12353 .dac_nids = alc262_dac_nids,
12354 .hp_nid = 0x03,
12355 .dig_out_nid = ALC262_DIGOUT_NID,
12356 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12357 .channel_mode = alc262_modes,
12358 .input_mux = &alc262_capture_source,
12359 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012360 .setup = alc262_hippo_setup,
12361 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012362 },
12363 [ALC262_HIPPO_1] = {
12364 .mixers = { alc262_hippo1_mixer },
12365 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12366 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12367 .dac_nids = alc262_dac_nids,
12368 .hp_nid = 0x02,
12369 .dig_out_nid = ALC262_DIGOUT_NID,
12370 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12371 .channel_mode = alc262_modes,
12372 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012373 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012374 .setup = alc262_hippo1_setup,
12375 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012376 },
Takashi Iwai834be882006-03-01 14:16:17 +010012377 [ALC262_FUJITSU] = {
12378 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012379 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12380 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012381 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12382 .dac_nids = alc262_dac_nids,
12383 .hp_nid = 0x03,
12384 .dig_out_nid = ALC262_DIGOUT_NID,
12385 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12386 .channel_mode = alc262_modes,
12387 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012388 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012389 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012390 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012391 [ALC262_HP_BPC] = {
12392 .mixers = { alc262_HP_BPC_mixer },
12393 .init_verbs = { alc262_HP_BPC_init_verbs },
12394 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12395 .dac_nids = alc262_dac_nids,
12396 .hp_nid = 0x03,
12397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12398 .channel_mode = alc262_modes,
12399 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012400 .unsol_event = alc262_hp_bpc_unsol_event,
12401 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012402 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012403 [ALC262_HP_BPC_D7000_WF] = {
12404 .mixers = { alc262_HP_BPC_WildWest_mixer },
12405 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12406 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12407 .dac_nids = alc262_dac_nids,
12408 .hp_nid = 0x03,
12409 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12410 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012411 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012412 .unsol_event = alc262_hp_wildwest_unsol_event,
12413 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012414 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012415 [ALC262_HP_BPC_D7000_WL] = {
12416 .mixers = { alc262_HP_BPC_WildWest_mixer,
12417 alc262_HP_BPC_WildWest_option_mixer },
12418 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12419 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12420 .dac_nids = alc262_dac_nids,
12421 .hp_nid = 0x03,
12422 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12423 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012424 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012425 .unsol_event = alc262_hp_wildwest_unsol_event,
12426 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012427 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012428 [ALC262_HP_TC_T5735] = {
12429 .mixers = { alc262_hp_t5735_mixer },
12430 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12431 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12432 .dac_nids = alc262_dac_nids,
12433 .hp_nid = 0x03,
12434 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12435 .channel_mode = alc262_modes,
12436 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012437 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012438 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012439 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012440 },
12441 [ALC262_HP_RP5700] = {
12442 .mixers = { alc262_hp_rp5700_mixer },
12443 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12444 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12445 .dac_nids = alc262_dac_nids,
12446 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12447 .channel_mode = alc262_modes,
12448 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012449 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012450 [ALC262_BENQ_ED8] = {
12451 .mixers = { alc262_base_mixer },
12452 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12453 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12454 .dac_nids = alc262_dac_nids,
12455 .hp_nid = 0x03,
12456 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12457 .channel_mode = alc262_modes,
12458 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012459 },
Kailang Yang272a5272007-05-14 11:00:38 +020012460 [ALC262_SONY_ASSAMD] = {
12461 .mixers = { alc262_sony_mixer },
12462 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12463 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12464 .dac_nids = alc262_dac_nids,
12465 .hp_nid = 0x02,
12466 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12467 .channel_mode = alc262_modes,
12468 .input_mux = &alc262_capture_source,
12469 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012470 .setup = alc262_hippo_setup,
12471 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012472 },
12473 [ALC262_BENQ_T31] = {
12474 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012475 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12476 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012477 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12478 .dac_nids = alc262_dac_nids,
12479 .hp_nid = 0x03,
12480 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12481 .channel_mode = alc262_modes,
12482 .input_mux = &alc262_capture_source,
12483 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012484 .setup = alc262_hippo_setup,
12485 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012486 },
Tobin Davisf651b502007-10-26 12:40:47 +020012487 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012488 .mixers = { alc262_ultra_mixer },
12489 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012490 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012491 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12492 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012493 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12494 .channel_mode = alc262_modes,
12495 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012496 .adc_nids = alc262_adc_nids, /* ADC0 */
12497 .capsrc_nids = alc262_capsrc_nids,
12498 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012499 .unsol_event = alc262_ultra_unsol_event,
12500 .init_hook = alc262_ultra_automute,
12501 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012502 [ALC262_LENOVO_3000] = {
12503 .mixers = { alc262_lenovo_3000_mixer },
12504 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012505 alc262_lenovo_3000_unsol_verbs,
12506 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012507 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12508 .dac_nids = alc262_dac_nids,
12509 .hp_nid = 0x03,
12510 .dig_out_nid = ALC262_DIGOUT_NID,
12511 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12512 .channel_mode = alc262_modes,
12513 .input_mux = &alc262_fujitsu_capture_source,
12514 .unsol_event = alc262_lenovo_3000_unsol_event,
12515 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012516 [ALC262_NEC] = {
12517 .mixers = { alc262_nec_mixer },
12518 .init_verbs = { alc262_nec_verbs },
12519 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12520 .dac_nids = alc262_dac_nids,
12521 .hp_nid = 0x03,
12522 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12523 .channel_mode = alc262_modes,
12524 .input_mux = &alc262_capture_source,
12525 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012526 [ALC262_TOSHIBA_S06] = {
12527 .mixers = { alc262_toshiba_s06_mixer },
12528 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12529 alc262_eapd_verbs },
12530 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12531 .capsrc_nids = alc262_dmic_capsrc_nids,
12532 .dac_nids = alc262_dac_nids,
12533 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012534 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012535 .dig_out_nid = ALC262_DIGOUT_NID,
12536 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12537 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012538 .unsol_event = alc_sku_unsol_event,
12539 .setup = alc262_toshiba_s06_setup,
12540 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012541 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012542 [ALC262_TOSHIBA_RX1] = {
12543 .mixers = { alc262_toshiba_rx1_mixer },
12544 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12545 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12546 .dac_nids = alc262_dac_nids,
12547 .hp_nid = 0x03,
12548 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12549 .channel_mode = alc262_modes,
12550 .input_mux = &alc262_capture_source,
12551 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012552 .setup = alc262_hippo_setup,
12553 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012554 },
Tony Vroonba340e82009-02-02 19:01:30 +000012555 [ALC262_TYAN] = {
12556 .mixers = { alc262_tyan_mixer },
12557 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12558 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12559 .dac_nids = alc262_dac_nids,
12560 .hp_nid = 0x02,
12561 .dig_out_nid = ALC262_DIGOUT_NID,
12562 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12563 .channel_mode = alc262_modes,
12564 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012565 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012566 .setup = alc262_tyan_setup,
12567 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012568 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012569};
12570
12571static int patch_alc262(struct hda_codec *codec)
12572{
12573 struct alc_spec *spec;
12574 int board_config;
12575 int err;
12576
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012577 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012578 if (spec == NULL)
12579 return -ENOMEM;
12580
12581 codec->spec = spec;
12582#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012583 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12584 * under-run
12585 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012586 {
12587 int tmp;
12588 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12589 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12590 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12591 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12592 }
12593#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012594 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012595
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012596 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12597
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012598 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12599 alc262_models,
12600 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012601
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012602 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012603 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12604 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012605 board_config = ALC262_AUTO;
12606 }
12607
12608 if (board_config == ALC262_AUTO) {
12609 /* automatic parse from the BIOS config */
12610 err = alc262_parse_auto_config(codec);
12611 if (err < 0) {
12612 alc_free(codec);
12613 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012614 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012615 printk(KERN_INFO
12616 "hda_codec: Cannot set up configuration "
12617 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012618 board_config = ALC262_BASIC;
12619 }
12620 }
12621
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012622 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012623 err = snd_hda_attach_beep_device(codec, 0x1);
12624 if (err < 0) {
12625 alc_free(codec);
12626 return err;
12627 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012628 }
12629
Kailang Yangdf694da2005-12-05 19:42:22 +010012630 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012631 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012632
Kailang Yangdf694da2005-12-05 19:42:22 +010012633 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12634 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012635
Kailang Yangdf694da2005-12-05 19:42:22 +010012636 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12637 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12638
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012639 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012640 int i;
12641 /* check whether the digital-mic has to be supported */
12642 for (i = 0; i < spec->input_mux->num_items; i++) {
12643 if (spec->input_mux->items[i].index >= 9)
12644 break;
12645 }
12646 if (i < spec->input_mux->num_items) {
12647 /* use only ADC0 */
12648 spec->adc_nids = alc262_dmic_adc_nids;
12649 spec->num_adc_nids = 1;
12650 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012651 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012652 /* all analog inputs */
12653 /* check whether NID 0x07 is valid */
12654 unsigned int wcap = get_wcaps(codec, 0x07);
12655
12656 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012657 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012658 if (wcap != AC_WID_AUD_IN) {
12659 spec->adc_nids = alc262_adc_nids_alt;
12660 spec->num_adc_nids =
12661 ARRAY_SIZE(alc262_adc_nids_alt);
12662 spec->capsrc_nids = alc262_capsrc_nids_alt;
12663 } else {
12664 spec->adc_nids = alc262_adc_nids;
12665 spec->num_adc_nids =
12666 ARRAY_SIZE(alc262_adc_nids);
12667 spec->capsrc_nids = alc262_capsrc_nids;
12668 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012669 }
12670 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012671 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012672 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012673 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012674 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012675
Takashi Iwai2134ea42008-01-10 16:53:55 +010012676 spec->vmaster_nid = 0x0c;
12677
Kailang Yangdf694da2005-12-05 19:42:22 +010012678 codec->patch_ops = alc_patch_ops;
12679 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012680 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012681#ifdef CONFIG_SND_HDA_POWER_SAVE
12682 if (!spec->loopback.amplist)
12683 spec->loopback.amplist = alc262_loopbacks;
12684#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012685
Kailang Yangdf694da2005-12-05 19:42:22 +010012686 return 0;
12687}
12688
Kailang Yangdf694da2005-12-05 19:42:22 +010012689/*
Kailang Yanga361d842007-06-05 12:30:55 +020012690 * ALC268 channel source setting (2 channel)
12691 */
12692#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12693#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012694
Kailang Yanga361d842007-06-05 12:30:55 +020012695static hda_nid_t alc268_dac_nids[2] = {
12696 /* front, hp */
12697 0x02, 0x03
12698};
12699
12700static hda_nid_t alc268_adc_nids[2] = {
12701 /* ADC0-1 */
12702 0x08, 0x07
12703};
12704
12705static hda_nid_t alc268_adc_nids_alt[1] = {
12706 /* ADC0 */
12707 0x08
12708};
12709
Takashi Iwaie1406342008-02-11 18:32:32 +010012710static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12711
Kailang Yanga361d842007-06-05 12:30:55 +020012712static struct snd_kcontrol_new alc268_base_mixer[] = {
12713 /* output mixer control */
12714 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12715 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12716 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12717 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012718 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12719 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12720 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012721 { }
12722};
12723
Takashi Iwai42171c12009-05-08 14:11:43 +020012724static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12725 /* output mixer control */
12726 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12727 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12728 ALC262_HIPPO_MASTER_SWITCH,
12729 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12730 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12731 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12732 { }
12733};
12734
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012735/* bind Beep switches of both NID 0x0f and 0x10 */
12736static struct hda_bind_ctls alc268_bind_beep_sw = {
12737 .ops = &snd_hda_bind_sw,
12738 .values = {
12739 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12740 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12741 0
12742 },
12743};
12744
12745static struct snd_kcontrol_new alc268_beep_mixer[] = {
12746 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12747 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12748 { }
12749};
12750
Kailang Yangd1a991a2007-08-15 16:21:59 +020012751static struct hda_verb alc268_eapd_verbs[] = {
12752 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12753 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12754 { }
12755};
12756
Takashi Iwaid2738092007-08-16 14:59:45 +020012757/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012758static struct hda_verb alc268_toshiba_verbs[] = {
12759 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12760 { } /* end */
12761};
12762
12763/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012764/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012765static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12766 .ops = &snd_hda_bind_vol,
12767 .values = {
12768 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12769 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12770 0
12771 },
12772};
12773
Takashi Iwai889c4392007-08-23 18:56:52 +020012774/* mute/unmute internal speaker according to the hp jack and mute state */
12775static void alc268_acer_automute(struct hda_codec *codec, int force)
12776{
12777 struct alc_spec *spec = codec->spec;
12778 unsigned int mute;
12779
12780 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012781 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012782 spec->sense_updated = 1;
12783 }
12784 if (spec->jack_present)
12785 mute = HDA_AMP_MUTE; /* mute internal speaker */
12786 else /* unmute internal speaker if necessary */
12787 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12788 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12789 HDA_AMP_MUTE, mute);
12790}
12791
12792
12793/* bind hp and internal speaker mute (with plug check) */
12794static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12795 struct snd_ctl_elem_value *ucontrol)
12796{
12797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12798 long *valp = ucontrol->value.integer.value;
12799 int change;
12800
Takashi Iwai8de56b72009-07-24 16:51:47 +020012801 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012802 if (change)
12803 alc268_acer_automute(codec, 0);
12804 return change;
12805}
Takashi Iwaid2738092007-08-16 14:59:45 +020012806
Kailang Yang8ef355d2008-08-26 13:10:22 +020012807static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12808 /* output mixer control */
12809 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12810 {
12811 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12812 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012813 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012814 .info = snd_hda_mixer_amp_switch_info,
12815 .get = snd_hda_mixer_amp_switch_get,
12816 .put = alc268_acer_master_sw_put,
12817 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12818 },
12819 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12820 { }
12821};
12822
Takashi Iwaid2738092007-08-16 14:59:45 +020012823static struct snd_kcontrol_new alc268_acer_mixer[] = {
12824 /* output mixer control */
12825 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12826 {
12827 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12828 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012829 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012830 .info = snd_hda_mixer_amp_switch_info,
12831 .get = snd_hda_mixer_amp_switch_get,
12832 .put = alc268_acer_master_sw_put,
12833 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12834 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012835 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12836 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12837 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012838 { }
12839};
12840
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012841static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12842 /* output mixer control */
12843 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12844 {
12845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12846 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012847 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012848 .info = snd_hda_mixer_amp_switch_info,
12849 .get = snd_hda_mixer_amp_switch_get,
12850 .put = alc268_acer_master_sw_put,
12851 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12852 },
12853 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12854 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12855 { }
12856};
12857
Kailang Yang8ef355d2008-08-26 13:10:22 +020012858static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12859 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12860 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12861 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12862 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12863 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12864 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12865 { }
12866};
12867
Takashi Iwaid2738092007-08-16 14:59:45 +020012868static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012869 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12870 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012871 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12872 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12874 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012875 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12876 { }
12877};
12878
12879/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012880#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012881#define alc268_toshiba_setup alc262_hippo_setup
12882#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012883
12884static void alc268_acer_unsol_event(struct hda_codec *codec,
12885 unsigned int res)
12886{
Takashi Iwai889c4392007-08-23 18:56:52 +020012887 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012888 return;
12889 alc268_acer_automute(codec, 1);
12890}
12891
Takashi Iwai889c4392007-08-23 18:56:52 +020012892static void alc268_acer_init_hook(struct hda_codec *codec)
12893{
12894 alc268_acer_automute(codec, 1);
12895}
12896
Kailang Yang8ef355d2008-08-26 13:10:22 +020012897/* toggle speaker-output according to the hp-jack state */
12898static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12899{
12900 unsigned int present;
12901 unsigned char bits;
12902
Wu Fengguang864f92b2009-11-18 12:38:02 +080012903 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012904 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012905 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012906 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012907 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012908 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012909}
12910
Kailang Yang8ef355d2008-08-26 13:10:22 +020012911static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12912 unsigned int res)
12913{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012914 switch (res >> 26) {
12915 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012916 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012917 break;
12918 case ALC880_MIC_EVENT:
12919 alc_mic_automute(codec);
12920 break;
12921 }
12922}
12923
12924static void alc268_acer_lc_setup(struct hda_codec *codec)
12925{
12926 struct alc_spec *spec = codec->spec;
12927 spec->ext_mic.pin = 0x18;
12928 spec->ext_mic.mux_idx = 0;
12929 spec->int_mic.pin = 0x12;
12930 spec->int_mic.mux_idx = 6;
12931 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012932}
12933
12934static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12935{
12936 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012937 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012938}
12939
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012940static struct snd_kcontrol_new alc268_dell_mixer[] = {
12941 /* output mixer control */
12942 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12943 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12944 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12945 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12946 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12947 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12948 { }
12949};
12950
12951static struct hda_verb alc268_dell_verbs[] = {
12952 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12953 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12954 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012955 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012956 { }
12957};
12958
12959/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012960static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012961{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012962 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012963
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012964 spec->autocfg.hp_pins[0] = 0x15;
12965 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012966 spec->ext_mic.pin = 0x18;
12967 spec->ext_mic.mux_idx = 0;
12968 spec->int_mic.pin = 0x19;
12969 spec->int_mic.mux_idx = 1;
12970 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012971}
12972
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012973static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12974 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12975 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12976 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12977 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12978 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12979 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12980 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12981 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12982 { }
12983};
12984
12985static struct hda_verb alc267_quanta_il1_verbs[] = {
12986 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12987 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12988 { }
12989};
12990
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012991static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012992{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012993 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012994 spec->autocfg.hp_pins[0] = 0x15;
12995 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012996 spec->ext_mic.pin = 0x18;
12997 spec->ext_mic.mux_idx = 0;
12998 spec->int_mic.pin = 0x19;
12999 spec->int_mic.mux_idx = 1;
13000 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013001}
13002
Kailang Yanga361d842007-06-05 12:30:55 +020013003/*
13004 * generic initialization of ADC, input mixers and output mixers
13005 */
13006static struct hda_verb alc268_base_init_verbs[] = {
13007 /* Unmute DAC0-1 and set vol = 0 */
13008 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013009 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013010
13011 /*
13012 * Set up output mixers (0x0c - 0x0e)
13013 */
13014 /* set vol=0 to output mixers */
13015 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013016 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13017
13018 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13019 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13020
13021 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13023 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13024 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13025 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13026 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13027 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13028 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13029
13030 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13031 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13033 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013035
13036 /* set PCBEEP vol = 0, mute connections */
13037 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13038 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13039 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013040
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013041 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013042
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013043 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13044 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13045 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013047
Kailang Yanga361d842007-06-05 12:30:55 +020013048 { }
13049};
13050
13051/*
13052 * generic initialization of ADC, input mixers and output mixers
13053 */
13054static struct hda_verb alc268_volume_init_verbs[] = {
13055 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013056 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13057 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013058
13059 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13060 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13061 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13062 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13063 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13064
Kailang Yanga361d842007-06-05 12:30:55 +020013065 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013066 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13067 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13068
13069 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013070 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013071
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013072 /* set PCBEEP vol = 0, mute connections */
13073 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13074 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13075 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013076
13077 { }
13078};
13079
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013080static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13081 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13082 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13083 { } /* end */
13084};
13085
Kailang Yanga361d842007-06-05 12:30:55 +020013086static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13087 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13088 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013089 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013090 { } /* end */
13091};
13092
13093static struct snd_kcontrol_new alc268_capture_mixer[] = {
13094 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13095 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13096 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13097 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013098 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013099 { } /* end */
13100};
13101
13102static struct hda_input_mux alc268_capture_source = {
13103 .num_items = 4,
13104 .items = {
13105 { "Mic", 0x0 },
13106 { "Front Mic", 0x1 },
13107 { "Line", 0x2 },
13108 { "CD", 0x3 },
13109 },
13110};
13111
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013112static struct hda_input_mux alc268_acer_capture_source = {
13113 .num_items = 3,
13114 .items = {
13115 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013116 { "Internal Mic", 0x1 },
13117 { "Line", 0x2 },
13118 },
13119};
13120
13121static struct hda_input_mux alc268_acer_dmic_capture_source = {
13122 .num_items = 3,
13123 .items = {
13124 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013125 { "Internal Mic", 0x6 },
13126 { "Line", 0x2 },
13127 },
13128};
13129
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013130#ifdef CONFIG_SND_DEBUG
13131static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013132 /* Volume widgets */
13133 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13134 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13135 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13136 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13137 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13138 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13139 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13140 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13141 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13142 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13143 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13144 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13145 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013146 /* The below appears problematic on some hardwares */
13147 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013148 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13149 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13150 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13151 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13152
13153 /* Modes for retasking pin widgets */
13154 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13155 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13156 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13157 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13158
13159 /* Controls for GPIO pins, assuming they are configured as outputs */
13160 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13161 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13162 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13163 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13164
13165 /* Switches to allow the digital SPDIF output pin to be enabled.
13166 * The ALC268 does not have an SPDIF input.
13167 */
13168 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13169
13170 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13171 * this output to turn on an external amplifier.
13172 */
13173 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13174 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13175
13176 { } /* end */
13177};
13178#endif
13179
Kailang Yanga361d842007-06-05 12:30:55 +020013180/* create input playback/capture controls for the given pin */
13181static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13182 const char *ctlname, int idx)
13183{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013184 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013185 int err;
13186
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013187 switch (nid) {
13188 case 0x14:
13189 case 0x16:
13190 dac = 0x02;
13191 break;
13192 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013193 case 0x1a: /* ALC259/269 only */
13194 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013195 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013196 dac = 0x03;
13197 break;
13198 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013199 snd_printd(KERN_WARNING "hda_codec: "
13200 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013201 return 0;
13202 }
13203 if (spec->multiout.dac_nids[0] != dac &&
13204 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013205 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013206 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013207 HDA_OUTPUT));
13208 if (err < 0)
13209 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013210 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13211 }
13212
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013213 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013214 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013215 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013216 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013217 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013218 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013219 if (err < 0)
13220 return err;
13221 return 0;
13222}
13223
13224/* add playback controls from the parsed DAC table */
13225static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13226 const struct auto_pin_cfg *cfg)
13227{
13228 hda_nid_t nid;
13229 int err;
13230
Kailang Yanga361d842007-06-05 12:30:55 +020013231 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013232
13233 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013234 if (nid) {
13235 const char *name;
13236 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13237 name = "Speaker";
13238 else
13239 name = "Front";
13240 err = alc268_new_analog_output(spec, nid, name, 0);
13241 if (err < 0)
13242 return err;
13243 }
Kailang Yanga361d842007-06-05 12:30:55 +020013244
13245 nid = cfg->speaker_pins[0];
13246 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013247 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013248 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13249 if (err < 0)
13250 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013251 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013252 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13253 if (err < 0)
13254 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013255 }
13256 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013257 if (nid) {
13258 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13259 if (err < 0)
13260 return err;
13261 }
Kailang Yanga361d842007-06-05 12:30:55 +020013262
13263 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13264 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013265 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013266 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013267 if (err < 0)
13268 return err;
13269 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013270 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013271}
13272
13273/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013274static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013275 const struct auto_pin_cfg *cfg)
13276{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013277 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013278}
13279
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013280static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13281 hda_nid_t nid, int pin_type)
13282{
13283 int idx;
13284
13285 alc_set_pin_output(codec, nid, pin_type);
13286 if (nid == 0x14 || nid == 0x16)
13287 idx = 0;
13288 else
13289 idx = 1;
13290 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13291}
13292
13293static void alc268_auto_init_multi_out(struct hda_codec *codec)
13294{
13295 struct alc_spec *spec = codec->spec;
13296 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13297 if (nid) {
13298 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13299 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13300 }
13301}
13302
13303static void alc268_auto_init_hp_out(struct hda_codec *codec)
13304{
13305 struct alc_spec *spec = codec->spec;
13306 hda_nid_t pin;
13307
13308 pin = spec->autocfg.hp_pins[0];
13309 if (pin)
13310 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13311 pin = spec->autocfg.speaker_pins[0];
13312 if (pin)
13313 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13314}
13315
Kailang Yanga361d842007-06-05 12:30:55 +020013316static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13317{
13318 struct alc_spec *spec = codec->spec;
13319 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13320 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13321 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13322 unsigned int dac_vol1, dac_vol2;
13323
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013324 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013325 snd_hda_codec_write(codec, speaker_nid, 0,
13326 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013327 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013328 snd_hda_codec_write(codec, 0x0f, 0,
13329 AC_VERB_SET_AMP_GAIN_MUTE,
13330 AMP_IN_UNMUTE(1));
13331 snd_hda_codec_write(codec, 0x10, 0,
13332 AC_VERB_SET_AMP_GAIN_MUTE,
13333 AMP_IN_UNMUTE(1));
13334 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013335 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013336 snd_hda_codec_write(codec, 0x0f, 0,
13337 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13338 snd_hda_codec_write(codec, 0x10, 0,
13339 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13340 }
13341
13342 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013343 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013344 dac_vol2 = AMP_OUT_ZERO;
13345 else if (line_nid == 0x15)
13346 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013347 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013348 dac_vol2 = AMP_OUT_ZERO;
13349 else if (hp_nid == 0x15)
13350 dac_vol1 = AMP_OUT_ZERO;
13351 if (line_nid != 0x16 || hp_nid != 0x16 ||
13352 spec->autocfg.line_out_pins[1] != 0x16 ||
13353 spec->autocfg.line_out_pins[2] != 0x16)
13354 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13355
13356 snd_hda_codec_write(codec, 0x02, 0,
13357 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13358 snd_hda_codec_write(codec, 0x03, 0,
13359 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13360}
13361
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013362/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013363#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13364#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013365#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013366#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13367
13368/*
13369 * BIOS auto configuration
13370 */
13371static int alc268_parse_auto_config(struct hda_codec *codec)
13372{
13373 struct alc_spec *spec = codec->spec;
13374 int err;
13375 static hda_nid_t alc268_ignore[] = { 0 };
13376
13377 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13378 alc268_ignore);
13379 if (err < 0)
13380 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013381 if (!spec->autocfg.line_outs) {
13382 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13383 spec->multiout.max_channels = 2;
13384 spec->no_analog = 1;
13385 goto dig_only;
13386 }
Kailang Yanga361d842007-06-05 12:30:55 +020013387 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013388 }
Kailang Yanga361d842007-06-05 12:30:55 +020013389 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13390 if (err < 0)
13391 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013392 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013393 if (err < 0)
13394 return err;
13395
13396 spec->multiout.max_channels = 2;
13397
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013398 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013399 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013400 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013401 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013402 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013403
Takashi Iwai892981f2009-03-02 08:04:35 +010013404 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013405 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013406
Takashi Iwaid88897e2008-10-31 15:01:37 +010013407 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013408 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013409 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013410
Takashi Iwai776e1842007-08-29 15:07:11 +020013411 err = alc_auto_add_mic_boost(codec);
13412 if (err < 0)
13413 return err;
13414
Kailang Yang6227cdc2010-02-25 08:36:52 +010013415 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013416
Kailang Yanga361d842007-06-05 12:30:55 +020013417 return 1;
13418}
13419
Kailang Yanga361d842007-06-05 12:30:55 +020013420#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13421
13422/* init callback for auto-configuration model -- overriding the default init */
13423static void alc268_auto_init(struct hda_codec *codec)
13424{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013425 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013426 alc268_auto_init_multi_out(codec);
13427 alc268_auto_init_hp_out(codec);
13428 alc268_auto_init_mono_speaker_out(codec);
13429 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013430 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013431 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013432 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013433}
13434
13435/*
13436 * configuration and preset
13437 */
13438static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013439 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013440 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013441 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013442 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013443 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013444 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013445 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013446 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013447#ifdef CONFIG_SND_DEBUG
13448 [ALC268_TEST] = "test",
13449#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013450 [ALC268_AUTO] = "auto",
13451};
13452
13453static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013454 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013455 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013456 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013457 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013458 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013459 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13460 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013461 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013462 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13463 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013464 /* almost compatible with toshiba but with optional digital outs;
13465 * auto-probing seems working fine
13466 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013467 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013468 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013469 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013470 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013471 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013472 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013473 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013474 {}
13475};
13476
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013477/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13478static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13479 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13480 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13481 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13482 ALC268_TOSHIBA),
13483 {}
13484};
13485
Kailang Yanga361d842007-06-05 12:30:55 +020013486static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013487 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013488 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13489 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013490 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13491 alc267_quanta_il1_verbs },
13492 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13493 .dac_nids = alc268_dac_nids,
13494 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13495 .adc_nids = alc268_adc_nids_alt,
13496 .hp_nid = 0x03,
13497 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13498 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013499 .unsol_event = alc_sku_unsol_event,
13500 .setup = alc267_quanta_il1_setup,
13501 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013502 },
Kailang Yanga361d842007-06-05 12:30:55 +020013503 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013504 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13505 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013506 .init_verbs = { alc268_base_init_verbs },
13507 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13508 .dac_nids = alc268_dac_nids,
13509 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13510 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013511 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013512 .hp_nid = 0x03,
13513 .dig_out_nid = ALC268_DIGOUT_NID,
13514 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13515 .channel_mode = alc268_modes,
13516 .input_mux = &alc268_capture_source,
13517 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013518 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013519 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013520 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013521 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13522 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013523 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13524 .dac_nids = alc268_dac_nids,
13525 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13526 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013527 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013528 .hp_nid = 0x03,
13529 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13530 .channel_mode = alc268_modes,
13531 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013532 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013533 .setup = alc268_toshiba_setup,
13534 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013535 },
13536 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013537 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013538 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013539 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13540 alc268_acer_verbs },
13541 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13542 .dac_nids = alc268_dac_nids,
13543 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13544 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013545 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013546 .hp_nid = 0x02,
13547 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13548 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013549 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013550 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013551 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013552 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013553 [ALC268_ACER_DMIC] = {
13554 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13555 alc268_beep_mixer },
13556 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13557 alc268_acer_verbs },
13558 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13559 .dac_nids = alc268_dac_nids,
13560 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13561 .adc_nids = alc268_adc_nids_alt,
13562 .capsrc_nids = alc268_capsrc_nids,
13563 .hp_nid = 0x02,
13564 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13565 .channel_mode = alc268_modes,
13566 .input_mux = &alc268_acer_dmic_capture_source,
13567 .unsol_event = alc268_acer_unsol_event,
13568 .init_hook = alc268_acer_init_hook,
13569 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013570 [ALC268_ACER_ASPIRE_ONE] = {
13571 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013572 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013573 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013574 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13575 alc268_acer_aspire_one_verbs },
13576 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13577 .dac_nids = alc268_dac_nids,
13578 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13579 .adc_nids = alc268_adc_nids_alt,
13580 .capsrc_nids = alc268_capsrc_nids,
13581 .hp_nid = 0x03,
13582 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13583 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013584 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013585 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013586 .init_hook = alc268_acer_lc_init_hook,
13587 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013588 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013589 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13590 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013591 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13592 alc268_dell_verbs },
13593 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13594 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013595 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13596 .adc_nids = alc268_adc_nids_alt,
13597 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013598 .hp_nid = 0x02,
13599 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13600 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013601 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013602 .setup = alc268_dell_setup,
13603 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013604 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013605 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013606 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13607 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013608 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13609 alc268_toshiba_verbs },
13610 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13611 .dac_nids = alc268_dac_nids,
13612 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13613 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013614 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013615 .hp_nid = 0x03,
13616 .dig_out_nid = ALC268_DIGOUT_NID,
13617 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13618 .channel_mode = alc268_modes,
13619 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013620 .setup = alc268_toshiba_setup,
13621 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013622 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013623#ifdef CONFIG_SND_DEBUG
13624 [ALC268_TEST] = {
13625 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13626 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13627 alc268_volume_init_verbs },
13628 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13629 .dac_nids = alc268_dac_nids,
13630 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13631 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013632 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013633 .hp_nid = 0x03,
13634 .dig_out_nid = ALC268_DIGOUT_NID,
13635 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13636 .channel_mode = alc268_modes,
13637 .input_mux = &alc268_capture_source,
13638 },
13639#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013640};
13641
13642static int patch_alc268(struct hda_codec *codec)
13643{
13644 struct alc_spec *spec;
13645 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013646 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013647
Julia Lawallef86f582009-12-19 08:18:03 +010013648 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013649 if (spec == NULL)
13650 return -ENOMEM;
13651
13652 codec->spec = spec;
13653
13654 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13655 alc268_models,
13656 alc268_cfg_tbl);
13657
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013658 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13659 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013660 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013661
Kailang Yanga361d842007-06-05 12:30:55 +020013662 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013663 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13664 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013665 board_config = ALC268_AUTO;
13666 }
13667
13668 if (board_config == ALC268_AUTO) {
13669 /* automatic parse from the BIOS config */
13670 err = alc268_parse_auto_config(codec);
13671 if (err < 0) {
13672 alc_free(codec);
13673 return err;
13674 } else if (!err) {
13675 printk(KERN_INFO
13676 "hda_codec: Cannot set up configuration "
13677 "from BIOS. Using base mode...\n");
13678 board_config = ALC268_3ST;
13679 }
13680 }
13681
13682 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013683 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013684
Kailang Yanga361d842007-06-05 12:30:55 +020013685 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13686 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013687 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013688
Kailang Yanga361d842007-06-05 12:30:55 +020013689 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13690
Takashi Iwai22971e32009-02-10 11:56:44 +010013691 has_beep = 0;
13692 for (i = 0; i < spec->num_mixers; i++) {
13693 if (spec->mixers[i] == alc268_beep_mixer) {
13694 has_beep = 1;
13695 break;
13696 }
13697 }
13698
13699 if (has_beep) {
13700 err = snd_hda_attach_beep_device(codec, 0x1);
13701 if (err < 0) {
13702 alc_free(codec);
13703 return err;
13704 }
13705 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13706 /* override the amp caps for beep generator */
13707 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013708 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13709 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13710 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13711 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013712 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013713
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013714 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013715 /* check whether NID 0x07 is valid */
13716 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013717 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013718
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013719 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013720 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013721 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013722 if (spec->auto_mic ||
13723 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013724 spec->adc_nids = alc268_adc_nids_alt;
13725 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013726 if (spec->auto_mic)
13727 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013728 if (spec->auto_mic || spec->input_mux->num_items == 1)
13729 add_mixer(spec, alc268_capture_nosrc_mixer);
13730 else
13731 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013732 } else {
13733 spec->adc_nids = alc268_adc_nids;
13734 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013735 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013736 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013737 /* set default input source */
13738 for (i = 0; i < spec->num_adc_nids; i++)
13739 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13740 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013741 i < spec->num_mux_defs ?
13742 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013743 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013744 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013745
13746 spec->vmaster_nid = 0x02;
13747
Kailang Yanga361d842007-06-05 12:30:55 +020013748 codec->patch_ops = alc_patch_ops;
13749 if (board_config == ALC268_AUTO)
13750 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013751
Kailang Yanga361d842007-06-05 12:30:55 +020013752 return 0;
13753}
13754
13755/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013756 * ALC269 channel source setting (2 channel)
13757 */
13758#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13759
13760#define alc269_dac_nids alc260_dac_nids
13761
13762static hda_nid_t alc269_adc_nids[1] = {
13763 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013764 0x08,
13765};
13766
Takashi Iwaie01bf502008-08-21 16:25:07 +020013767static hda_nid_t alc269_capsrc_nids[1] = {
13768 0x23,
13769};
13770
Kailang Yang84898e82010-02-04 14:16:14 +010013771static hda_nid_t alc269vb_adc_nids[1] = {
13772 /* ADC1 */
13773 0x09,
13774};
13775
13776static hda_nid_t alc269vb_capsrc_nids[1] = {
13777 0x22,
13778};
13779
Takashi Iwai66946352010-03-29 17:21:45 +020013780static hda_nid_t alc269_adc_candidates[] = {
13781 0x08, 0x09, 0x07,
13782};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013783
Kailang Yangf6a92242007-12-13 16:52:54 +010013784#define alc269_modes alc260_modes
13785#define alc269_capture_source alc880_lg_lw_capture_source
13786
13787static struct snd_kcontrol_new alc269_base_mixer[] = {
13788 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13789 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13790 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13791 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13792 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13793 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13794 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13795 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13796 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13797 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13798 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13799 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13800 { } /* end */
13801};
13802
Kailang Yang60db6b52008-08-26 13:13:00 +020013803static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13804 /* output mixer control */
13805 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13806 {
13807 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13808 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013809 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013810 .info = snd_hda_mixer_amp_switch_info,
13811 .get = snd_hda_mixer_amp_switch_get,
13812 .put = alc268_acer_master_sw_put,
13813 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13814 },
13815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13816 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13817 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13818 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13819 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13820 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013821 { }
13822};
13823
Tony Vroon64154832008-11-06 15:08:49 +000013824static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13825 /* output mixer control */
13826 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13827 {
13828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13829 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013830 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013831 .info = snd_hda_mixer_amp_switch_info,
13832 .get = snd_hda_mixer_amp_switch_get,
13833 .put = alc268_acer_master_sw_put,
13834 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13835 },
13836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13838 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13839 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13840 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13841 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13842 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13843 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13844 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013845 { }
13846};
13847
Kailang Yang84898e82010-02-04 14:16:14 +010013848static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013849 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013850 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013851 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013853 { } /* end */
13854};
13855
Kailang Yang84898e82010-02-04 14:16:14 +010013856static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13857 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13858 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13859 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13860 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13861 { } /* end */
13862};
13863
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020013864static struct snd_kcontrol_new alc269_asus_mixer[] = {
13865 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13866 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
13867 { } /* end */
13868};
13869
Kailang Yangf6a92242007-12-13 16:52:54 +010013870/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013871static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13872 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13873 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13874 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13875 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13876 { } /* end */
13877};
13878
13879static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013880 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13881 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013882 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13883 { } /* end */
13884};
13885
Kailang Yang84898e82010-02-04 14:16:14 +010013886static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13887 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13888 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13890 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13891 { } /* end */
13892};
13893
13894static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13895 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13896 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13898 { } /* end */
13899};
13900
Takashi Iwai26f5df22008-11-03 17:39:46 +010013901/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013902#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013903
Kailang Yang60db6b52008-08-26 13:13:00 +020013904static struct hda_verb alc269_quanta_fl1_verbs[] = {
13905 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13908 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13909 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13910 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13911 { }
13912};
13913
Tony Vroon64154832008-11-06 15:08:49 +000013914static struct hda_verb alc269_lifebook_verbs[] = {
13915 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13916 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13917 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13919 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13922 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13923 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13924 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13925 { }
13926};
13927
Kailang Yang60db6b52008-08-26 13:13:00 +020013928/* toggle speaker-output according to the hp-jack state */
13929static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13930{
13931 unsigned int present;
13932 unsigned char bits;
13933
Wu Fengguang864f92b2009-11-18 12:38:02 +080013934 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013935 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013936 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013937 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013938 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013939 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013940
13941 snd_hda_codec_write(codec, 0x20, 0,
13942 AC_VERB_SET_COEF_INDEX, 0x0c);
13943 snd_hda_codec_write(codec, 0x20, 0,
13944 AC_VERB_SET_PROC_COEF, 0x680);
13945
13946 snd_hda_codec_write(codec, 0x20, 0,
13947 AC_VERB_SET_COEF_INDEX, 0x0c);
13948 snd_hda_codec_write(codec, 0x20, 0,
13949 AC_VERB_SET_PROC_COEF, 0x480);
13950}
13951
Tony Vroon64154832008-11-06 15:08:49 +000013952/* toggle speaker-output according to the hp-jacks state */
13953static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13954{
13955 unsigned int present;
13956 unsigned char bits;
13957
13958 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013959 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013960
13961 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013962 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013963
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013964 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013965 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013966 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013967 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013968 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013969
13970 snd_hda_codec_write(codec, 0x20, 0,
13971 AC_VERB_SET_COEF_INDEX, 0x0c);
13972 snd_hda_codec_write(codec, 0x20, 0,
13973 AC_VERB_SET_PROC_COEF, 0x680);
13974
13975 snd_hda_codec_write(codec, 0x20, 0,
13976 AC_VERB_SET_COEF_INDEX, 0x0c);
13977 snd_hda_codec_write(codec, 0x20, 0,
13978 AC_VERB_SET_PROC_COEF, 0x480);
13979}
13980
Tony Vroon64154832008-11-06 15:08:49 +000013981static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13982{
13983 unsigned int present_laptop;
13984 unsigned int present_dock;
13985
Wu Fengguang864f92b2009-11-18 12:38:02 +080013986 present_laptop = snd_hda_jack_detect(codec, 0x18);
13987 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013988
13989 /* Laptop mic port overrides dock mic port, design decision */
13990 if (present_dock)
13991 snd_hda_codec_write(codec, 0x23, 0,
13992 AC_VERB_SET_CONNECT_SEL, 0x3);
13993 if (present_laptop)
13994 snd_hda_codec_write(codec, 0x23, 0,
13995 AC_VERB_SET_CONNECT_SEL, 0x0);
13996 if (!present_dock && !present_laptop)
13997 snd_hda_codec_write(codec, 0x23, 0,
13998 AC_VERB_SET_CONNECT_SEL, 0x1);
13999}
14000
Kailang Yang60db6b52008-08-26 13:13:00 +020014001static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14002 unsigned int res)
14003{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014004 switch (res >> 26) {
14005 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014006 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014007 break;
14008 case ALC880_MIC_EVENT:
14009 alc_mic_automute(codec);
14010 break;
14011 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014012}
14013
Tony Vroon64154832008-11-06 15:08:49 +000014014static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14015 unsigned int res)
14016{
14017 if ((res >> 26) == ALC880_HP_EVENT)
14018 alc269_lifebook_speaker_automute(codec);
14019 if ((res >> 26) == ALC880_MIC_EVENT)
14020 alc269_lifebook_mic_autoswitch(codec);
14021}
14022
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014023static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14024{
14025 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014026 spec->autocfg.hp_pins[0] = 0x15;
14027 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014028 spec->ext_mic.pin = 0x18;
14029 spec->ext_mic.mux_idx = 0;
14030 spec->int_mic.pin = 0x19;
14031 spec->int_mic.mux_idx = 1;
14032 spec->auto_mic = 1;
14033}
14034
Kailang Yang60db6b52008-08-26 13:13:00 +020014035static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14036{
14037 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014038 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014039}
14040
Tony Vroon64154832008-11-06 15:08:49 +000014041static void alc269_lifebook_init_hook(struct hda_codec *codec)
14042{
14043 alc269_lifebook_speaker_automute(codec);
14044 alc269_lifebook_mic_autoswitch(codec);
14045}
14046
Kailang Yang84898e82010-02-04 14:16:14 +010014047static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014048 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14049 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14050 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14052 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14054 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14055 {}
14056};
14057
Kailang Yang84898e82010-02-04 14:16:14 +010014058static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014059 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14060 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14061 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14063 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14064 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14065 {}
14066};
14067
Kailang Yang84898e82010-02-04 14:16:14 +010014068static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14069 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14070 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14071 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14073 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14074 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14075 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14076 {}
14077};
14078
14079static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14080 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14081 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14082 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14084 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14085 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14086 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14087 {}
14088};
14089
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014090static struct hda_verb alc271_acer_dmic_verbs[] = {
14091 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14092 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14093 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14094 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14095 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14096 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14097 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14098 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14099 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14100 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14101 { }
14102};
14103
Kailang Yang60db6b52008-08-26 13:13:00 +020014104/* toggle speaker-output according to the hp-jack state */
14105static void alc269_speaker_automute(struct hda_codec *codec)
14106{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014107 struct alc_spec *spec = codec->spec;
14108 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014109 unsigned int present;
14110 unsigned char bits;
14111
Kailang Yangebb83ee2009-12-17 12:23:00 +010014112 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014113 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014114 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014115 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014116 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014117 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014118}
14119
Kailang Yang60db6b52008-08-26 13:13:00 +020014120/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014121static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014122 unsigned int res)
14123{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014124 switch (res >> 26) {
14125 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014126 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014127 break;
14128 case ALC880_MIC_EVENT:
14129 alc_mic_automute(codec);
14130 break;
14131 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014132}
14133
Kailang Yang226b1ec2010-04-09 11:01:20 +020014134static void alc269_laptop_amic_setup(struct hda_codec *codec)
14135{
14136 struct alc_spec *spec = codec->spec;
14137 spec->autocfg.hp_pins[0] = 0x15;
14138 spec->autocfg.speaker_pins[0] = 0x14;
14139 spec->ext_mic.pin = 0x18;
14140 spec->ext_mic.mux_idx = 0;
14141 spec->int_mic.pin = 0x19;
14142 spec->int_mic.mux_idx = 1;
14143 spec->auto_mic = 1;
14144}
14145
Kailang Yang84898e82010-02-04 14:16:14 +010014146static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014147{
14148 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014149 spec->autocfg.hp_pins[0] = 0x15;
14150 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014151 spec->ext_mic.pin = 0x18;
14152 spec->ext_mic.mux_idx = 0;
14153 spec->int_mic.pin = 0x12;
14154 spec->int_mic.mux_idx = 5;
14155 spec->auto_mic = 1;
14156}
14157
Kailang Yang226b1ec2010-04-09 11:01:20 +020014158static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014159{
14160 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014161 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014162 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014163 spec->ext_mic.pin = 0x18;
14164 spec->ext_mic.mux_idx = 0;
14165 spec->int_mic.pin = 0x19;
14166 spec->int_mic.mux_idx = 1;
14167 spec->auto_mic = 1;
14168}
14169
Kailang Yang226b1ec2010-04-09 11:01:20 +020014170static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14171{
14172 struct alc_spec *spec = codec->spec;
14173 spec->autocfg.hp_pins[0] = 0x21;
14174 spec->autocfg.speaker_pins[0] = 0x14;
14175 spec->ext_mic.pin = 0x18;
14176 spec->ext_mic.mux_idx = 0;
14177 spec->int_mic.pin = 0x12;
14178 spec->int_mic.mux_idx = 6;
14179 spec->auto_mic = 1;
14180}
14181
Kailang Yang84898e82010-02-04 14:16:14 +010014182static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014183{
14184 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014185 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014186}
14187
Kailang Yangf6a92242007-12-13 16:52:54 +010014188/*
14189 * generic initialization of ADC, input mixers and output mixers
14190 */
14191static struct hda_verb alc269_init_verbs[] = {
14192 /*
14193 * Unmute ADC0 and set the default input to mic-in
14194 */
Kailang Yang84898e82010-02-04 14:16:14 +010014195 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014196
14197 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014198 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014199 */
14200 /* set vol=0 to output mixers */
14201 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14202 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14203
14204 /* set up input amps for analog loopback */
14205 /* Amp Indices: DAC = 0, mixer = 1 */
14206 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14207 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14208 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14209 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14210 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14211 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14212
14213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14215 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14216 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14217 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14218 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14219 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14220
14221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014223
Kailang Yang84898e82010-02-04 14:16:14 +010014224 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014225 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14226 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014227 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014228
14229 /* set EAPD */
14230 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014231 { }
14232};
14233
14234static struct hda_verb alc269vb_init_verbs[] = {
14235 /*
14236 * Unmute ADC0 and set the default input to mic-in
14237 */
14238 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14239
14240 /*
14241 * Set up output mixers (0x02 - 0x03)
14242 */
14243 /* set vol=0 to output mixers */
14244 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14245 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14246
14247 /* set up input amps for analog loopback */
14248 /* Amp Indices: DAC = 0, mixer = 1 */
14249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14251 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14252 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14253 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14254 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14255
14256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14257 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14259 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14261 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14262 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14263
14264 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14265 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14266
14267 /* FIXME: use Mux-type input source selection */
14268 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14269 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14270 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14271
14272 /* set EAPD */
14273 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014274 { }
14275};
14276
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014277#define alc269_auto_create_multi_out_ctls \
14278 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014279#define alc269_auto_create_input_ctls \
14280 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014281
14282#ifdef CONFIG_SND_HDA_POWER_SAVE
14283#define alc269_loopbacks alc880_loopbacks
14284#endif
14285
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014286/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014287#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14288#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14289#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14290#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14291
Takashi Iwaif03d3112009-03-05 14:18:16 +010014292static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14293 .substreams = 1,
14294 .channels_min = 2,
14295 .channels_max = 8,
14296 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14297 /* NID is set in alc_build_pcms */
14298 .ops = {
14299 .open = alc880_playback_pcm_open,
14300 .prepare = alc880_playback_pcm_prepare,
14301 .cleanup = alc880_playback_pcm_cleanup
14302 },
14303};
14304
14305static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14306 .substreams = 1,
14307 .channels_min = 2,
14308 .channels_max = 2,
14309 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14310 /* NID is set in alc_build_pcms */
14311};
14312
Takashi Iwaiad358792010-03-30 18:00:59 +020014313#ifdef CONFIG_SND_HDA_POWER_SAVE
14314static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14315{
14316 switch (codec->subsystem_id) {
14317 case 0x103c1586:
14318 return 1;
14319 }
14320 return 0;
14321}
14322
14323static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14324{
14325 /* update mute-LED according to the speaker mute state */
14326 if (nid == 0x01 || nid == 0x14) {
14327 int pinval;
14328 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14329 HDA_AMP_MUTE)
14330 pinval = 0x24;
14331 else
14332 pinval = 0x20;
14333 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014334 snd_hda_codec_update_cache(codec, 0x19, 0,
14335 AC_VERB_SET_PIN_WIDGET_CONTROL,
14336 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014337 }
14338 return alc_check_power_status(codec, nid);
14339}
14340#endif /* CONFIG_SND_HDA_POWER_SAVE */
14341
Takashi Iwai840b64c2010-07-13 22:49:01 +020014342static int alc275_setup_dual_adc(struct hda_codec *codec)
14343{
14344 struct alc_spec *spec = codec->spec;
14345
14346 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14347 return 0;
14348 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14349 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14350 if (spec->ext_mic.pin <= 0x12) {
14351 spec->private_adc_nids[0] = 0x08;
14352 spec->private_adc_nids[1] = 0x11;
14353 spec->private_capsrc_nids[0] = 0x23;
14354 spec->private_capsrc_nids[1] = 0x22;
14355 } else {
14356 spec->private_adc_nids[0] = 0x11;
14357 spec->private_adc_nids[1] = 0x08;
14358 spec->private_capsrc_nids[0] = 0x22;
14359 spec->private_capsrc_nids[1] = 0x23;
14360 }
14361 spec->adc_nids = spec->private_adc_nids;
14362 spec->capsrc_nids = spec->private_capsrc_nids;
14363 spec->num_adc_nids = 2;
14364 spec->dual_adc_switch = 1;
14365 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14366 spec->adc_nids[0], spec->adc_nids[1]);
14367 return 1;
14368 }
14369 return 0;
14370}
14371
Kailang Yangf6a92242007-12-13 16:52:54 +010014372/*
14373 * BIOS auto configuration
14374 */
14375static int alc269_parse_auto_config(struct hda_codec *codec)
14376{
14377 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014378 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014379 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14380
14381 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14382 alc269_ignore);
14383 if (err < 0)
14384 return err;
14385
14386 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14387 if (err < 0)
14388 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014389 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014390 if (err < 0)
14391 return err;
14392
14393 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14394
Takashi Iwai757899a2010-07-30 10:48:14 +020014395 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014396
Takashi Iwai603c4012008-07-30 15:01:44 +020014397 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014398 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014399
Kailang Yang84898e82010-02-04 14:16:14 +010014400 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14401 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014402 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014403 } else {
14404 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014405 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014406 }
14407
Kailang Yangf6a92242007-12-13 16:52:54 +010014408 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014409 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014410
14411 if (!alc275_setup_dual_adc(codec))
14412 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14413 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014414
Takashi Iwaie01bf502008-08-21 16:25:07 +020014415 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014416 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014417 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14418 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014419
14420 err = alc_auto_add_mic_boost(codec);
14421 if (err < 0)
14422 return err;
14423
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014424 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014425 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014426
Kailang Yangf6a92242007-12-13 16:52:54 +010014427 return 1;
14428}
14429
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014430#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14431#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014432#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14433
14434
14435/* init callback for auto-configuration model -- overriding the default init */
14436static void alc269_auto_init(struct hda_codec *codec)
14437{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014438 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014439 alc269_auto_init_multi_out(codec);
14440 alc269_auto_init_hp_out(codec);
14441 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014442 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014443 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014444 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014445}
14446
Takashi Iwaiff818c22010-04-12 08:59:25 +020014447enum {
14448 ALC269_FIXUP_SONY_VAIO,
14449};
14450
Takashi Iwaiff818c22010-04-12 08:59:25 +020014451static const struct alc_fixup alc269_fixups[] = {
14452 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014453 .verbs = (const struct hda_verb[]) {
14454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14455 {}
14456 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014457 },
14458};
14459
14460static struct snd_pci_quirk alc269_fixup_tbl[] = {
14461 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014462 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014463 {}
14464};
14465
14466
Kailang Yangf6a92242007-12-13 16:52:54 +010014467/*
14468 * configuration and preset
14469 */
14470static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014471 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014472 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014473 [ALC269_AMIC] = "laptop-amic",
14474 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014475 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014476 [ALC269_LIFEBOOK] = "lifebook",
14477 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014478};
14479
14480static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014481 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014482 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014483 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014484 ALC269_AMIC),
14485 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14486 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14487 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14488 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14489 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14490 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14491 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14492 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14493 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14494 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14495 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14496 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14497 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14498 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14499 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14500 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14501 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14502 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14503 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14504 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14505 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14506 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14507 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14508 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14509 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14510 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14511 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14512 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14513 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14514 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14515 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14516 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14517 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14518 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14519 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14520 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014521 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014522 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014523 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014524 ALC269_DMIC),
14525 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14526 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014527 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014528 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014529 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14530 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14531 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14532 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14533 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14534 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014535 {}
14536};
14537
14538static struct alc_config_preset alc269_presets[] = {
14539 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014540 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014541 .init_verbs = { alc269_init_verbs },
14542 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14543 .dac_nids = alc269_dac_nids,
14544 .hp_nid = 0x03,
14545 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14546 .channel_mode = alc269_modes,
14547 .input_mux = &alc269_capture_source,
14548 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014549 [ALC269_QUANTA_FL1] = {
14550 .mixers = { alc269_quanta_fl1_mixer },
14551 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14552 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14553 .dac_nids = alc269_dac_nids,
14554 .hp_nid = 0x03,
14555 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14556 .channel_mode = alc269_modes,
14557 .input_mux = &alc269_capture_source,
14558 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014559 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014560 .init_hook = alc269_quanta_fl1_init_hook,
14561 },
Kailang Yang84898e82010-02-04 14:16:14 +010014562 [ALC269_AMIC] = {
14563 .mixers = { alc269_laptop_mixer },
14564 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014565 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014566 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014567 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14568 .dac_nids = alc269_dac_nids,
14569 .hp_nid = 0x03,
14570 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14571 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014572 .unsol_event = alc269_laptop_unsol_event,
14573 .setup = alc269_laptop_amic_setup,
14574 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014575 },
Kailang Yang84898e82010-02-04 14:16:14 +010014576 [ALC269_DMIC] = {
14577 .mixers = { alc269_laptop_mixer },
14578 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014579 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014580 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014581 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14582 .dac_nids = alc269_dac_nids,
14583 .hp_nid = 0x03,
14584 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14585 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014586 .unsol_event = alc269_laptop_unsol_event,
14587 .setup = alc269_laptop_dmic_setup,
14588 .init_hook = alc269_laptop_inithook,
14589 },
14590 [ALC269VB_AMIC] = {
14591 .mixers = { alc269vb_laptop_mixer },
14592 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14593 .init_verbs = { alc269vb_init_verbs,
14594 alc269vb_laptop_amic_init_verbs },
14595 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14596 .dac_nids = alc269_dac_nids,
14597 .hp_nid = 0x03,
14598 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14599 .channel_mode = alc269_modes,
14600 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014601 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014602 .init_hook = alc269_laptop_inithook,
14603 },
14604 [ALC269VB_DMIC] = {
14605 .mixers = { alc269vb_laptop_mixer },
14606 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14607 .init_verbs = { alc269vb_init_verbs,
14608 alc269vb_laptop_dmic_init_verbs },
14609 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14610 .dac_nids = alc269_dac_nids,
14611 .hp_nid = 0x03,
14612 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14613 .channel_mode = alc269_modes,
14614 .unsol_event = alc269_laptop_unsol_event,
14615 .setup = alc269vb_laptop_dmic_setup,
14616 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014617 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014618 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014619 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014620 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014621 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014622 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014623 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14624 .dac_nids = alc269_dac_nids,
14625 .hp_nid = 0x03,
14626 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14627 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014628 .unsol_event = alc269_laptop_unsol_event,
14629 .setup = alc269_laptop_dmic_setup,
14630 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014631 },
Tony Vroon64154832008-11-06 15:08:49 +000014632 [ALC269_LIFEBOOK] = {
14633 .mixers = { alc269_lifebook_mixer },
14634 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14635 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14636 .dac_nids = alc269_dac_nids,
14637 .hp_nid = 0x03,
14638 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14639 .channel_mode = alc269_modes,
14640 .input_mux = &alc269_capture_source,
14641 .unsol_event = alc269_lifebook_unsol_event,
14642 .init_hook = alc269_lifebook_init_hook,
14643 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014644 [ALC271_ACER] = {
14645 .mixers = { alc269_asus_mixer },
14646 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14647 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14648 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14649 .dac_nids = alc269_dac_nids,
14650 .adc_nids = alc262_dmic_adc_nids,
14651 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14652 .capsrc_nids = alc262_dmic_capsrc_nids,
14653 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14654 .channel_mode = alc269_modes,
14655 .input_mux = &alc269_capture_source,
14656 .dig_out_nid = ALC880_DIGOUT_NID,
14657 .unsol_event = alc_sku_unsol_event,
14658 .setup = alc269vb_laptop_dmic_setup,
14659 .init_hook = alc_inithook,
14660 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014661};
14662
14663static int patch_alc269(struct hda_codec *codec)
14664{
14665 struct alc_spec *spec;
14666 int board_config;
14667 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014668 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014669
14670 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14671 if (spec == NULL)
14672 return -ENOMEM;
14673
14674 codec->spec = spec;
14675
Kailang Yangda00c242010-03-19 11:23:45 +010014676 alc_auto_parse_customize_define(codec);
14677
Kailang Yang274693f2009-12-03 10:07:50 +010014678 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014679 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14680 spec->cdefine.platform_type == 1)
14681 alc_codec_rename(codec, "ALC271X");
14682 else
14683 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014684 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014685 } else
14686 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014687
Kailang Yangf6a92242007-12-13 16:52:54 +010014688 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14689 alc269_models,
14690 alc269_cfg_tbl);
14691
14692 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014693 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14694 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014695 board_config = ALC269_AUTO;
14696 }
14697
Takashi Iwaiff818c22010-04-12 08:59:25 +020014698 if (board_config == ALC269_AUTO)
14699 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14700
Kailang Yangf6a92242007-12-13 16:52:54 +010014701 if (board_config == ALC269_AUTO) {
14702 /* automatic parse from the BIOS config */
14703 err = alc269_parse_auto_config(codec);
14704 if (err < 0) {
14705 alc_free(codec);
14706 return err;
14707 } else if (!err) {
14708 printk(KERN_INFO
14709 "hda_codec: Cannot set up configuration "
14710 "from BIOS. Using base mode...\n");
14711 board_config = ALC269_BASIC;
14712 }
14713 }
14714
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014715 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014716 err = snd_hda_attach_beep_device(codec, 0x1);
14717 if (err < 0) {
14718 alc_free(codec);
14719 return err;
14720 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014721 }
14722
Kailang Yangf6a92242007-12-13 16:52:54 +010014723 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014724 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014725
Kailang Yang84898e82010-02-04 14:16:14 +010014726 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014727 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14728 * fix the sample rate of analog I/O to 44.1kHz
14729 */
14730 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14731 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014732 } else if (spec->dual_adc_switch) {
14733 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14734 /* switch ADC dynamically */
14735 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014736 } else {
14737 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14738 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14739 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014740 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14741 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14742
Takashi Iwai66946352010-03-29 17:21:45 +020014743 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14744 if (!is_alc269vb) {
14745 spec->adc_nids = alc269_adc_nids;
14746 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14747 spec->capsrc_nids = alc269_capsrc_nids;
14748 } else {
14749 spec->adc_nids = alc269vb_adc_nids;
14750 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14751 spec->capsrc_nids = alc269vb_capsrc_nids;
14752 }
Kailang Yang84898e82010-02-04 14:16:14 +010014753 }
14754
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014755 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014756 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014757 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014758 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014759
Takashi Iwaiff818c22010-04-12 08:59:25 +020014760 if (board_config == ALC269_AUTO)
14761 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14762
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014763 spec->vmaster_nid = 0x02;
14764
Kailang Yangf6a92242007-12-13 16:52:54 +010014765 codec->patch_ops = alc_patch_ops;
14766 if (board_config == ALC269_AUTO)
14767 spec->init_hook = alc269_auto_init;
14768#ifdef CONFIG_SND_HDA_POWER_SAVE
14769 if (!spec->loopback.amplist)
14770 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014771 if (alc269_mic2_for_mute_led(codec))
14772 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014773#endif
14774
14775 return 0;
14776}
14777
14778/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014779 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14780 */
14781
14782/*
14783 * set the path ways for 2 channel output
14784 * need to set the codec line out and mic 1 pin widgets to inputs
14785 */
14786static struct hda_verb alc861_threestack_ch2_init[] = {
14787 /* set pin widget 1Ah (line in) for input */
14788 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014789 /* set pin widget 18h (mic1/2) for input, for mic also enable
14790 * the vref
14791 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014792 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14793
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014794 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14795#if 0
14796 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14797 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14798#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014799 { } /* end */
14800};
14801/*
14802 * 6ch mode
14803 * need to set the codec line out and mic 1 pin widgets to outputs
14804 */
14805static struct hda_verb alc861_threestack_ch6_init[] = {
14806 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14807 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14808 /* set pin widget 18h (mic1) for output (CLFE)*/
14809 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14810
14811 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014812 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014813
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014814 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14815#if 0
14816 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14817 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14818#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014819 { } /* end */
14820};
14821
14822static struct hda_channel_mode alc861_threestack_modes[2] = {
14823 { 2, alc861_threestack_ch2_init },
14824 { 6, alc861_threestack_ch6_init },
14825};
Takashi Iwai22309c32006-08-09 16:57:28 +020014826/* Set mic1 as input and unmute the mixer */
14827static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14828 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14829 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14830 { } /* end */
14831};
14832/* Set mic1 as output and mute mixer */
14833static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14834 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14835 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14836 { } /* end */
14837};
14838
14839static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14840 { 2, alc861_uniwill_m31_ch2_init },
14841 { 4, alc861_uniwill_m31_ch4_init },
14842};
Kailang Yangdf694da2005-12-05 19:42:22 +010014843
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014844/* Set mic1 and line-in as input and unmute the mixer */
14845static struct hda_verb alc861_asus_ch2_init[] = {
14846 /* set pin widget 1Ah (line in) for input */
14847 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014848 /* set pin widget 18h (mic1/2) for input, for mic also enable
14849 * the vref
14850 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014851 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14852
14853 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14854#if 0
14855 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14856 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14857#endif
14858 { } /* end */
14859};
14860/* Set mic1 nad line-in as output and mute mixer */
14861static struct hda_verb alc861_asus_ch6_init[] = {
14862 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14863 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14864 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14865 /* set pin widget 18h (mic1) for output (CLFE)*/
14866 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14867 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14868 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14869 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14870
14871 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14872#if 0
14873 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14874 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14875#endif
14876 { } /* end */
14877};
14878
14879static struct hda_channel_mode alc861_asus_modes[2] = {
14880 { 2, alc861_asus_ch2_init },
14881 { 6, alc861_asus_ch6_init },
14882};
14883
Kailang Yangdf694da2005-12-05 19:42:22 +010014884/* patch-ALC861 */
14885
14886static struct snd_kcontrol_new alc861_base_mixer[] = {
14887 /* output mixer control */
14888 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14889 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14890 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14891 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14892 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14893
14894 /*Input mixer control */
14895 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14896 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14897 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14898 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14899 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14900 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14901 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14902 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14903 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014905
Kailang Yangdf694da2005-12-05 19:42:22 +010014906 { } /* end */
14907};
14908
14909static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14910 /* output mixer control */
14911 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14912 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14913 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14914 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14915 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14916
14917 /* Input mixer control */
14918 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14919 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14920 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14921 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14922 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14923 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14925 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14926 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14927 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014928
Kailang Yangdf694da2005-12-05 19:42:22 +010014929 {
14930 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14931 .name = "Channel Mode",
14932 .info = alc_ch_mode_info,
14933 .get = alc_ch_mode_get,
14934 .put = alc_ch_mode_put,
14935 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14936 },
14937 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014938};
14939
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014940static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014941 /* output mixer control */
14942 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14943 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14944 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014945
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014946 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014947};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014948
Takashi Iwai22309c32006-08-09 16:57:28 +020014949static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14950 /* output mixer control */
14951 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14952 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14953 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14954 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14955 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14956
14957 /* Input mixer control */
14958 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14959 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14960 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14961 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14962 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14963 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14964 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14965 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14967 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014968
Takashi Iwai22309c32006-08-09 16:57:28 +020014969 {
14970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14971 .name = "Channel Mode",
14972 .info = alc_ch_mode_info,
14973 .get = alc_ch_mode_get,
14974 .put = alc_ch_mode_put,
14975 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14976 },
14977 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014978};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014979
14980static struct snd_kcontrol_new alc861_asus_mixer[] = {
14981 /* output mixer control */
14982 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14983 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14984 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14985 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14986 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14987
14988 /* Input mixer control */
14989 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14990 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14991 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14992 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14993 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14994 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14995 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14996 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014998 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14999
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015000 {
15001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15002 .name = "Channel Mode",
15003 .info = alc_ch_mode_info,
15004 .get = alc_ch_mode_get,
15005 .put = alc_ch_mode_put,
15006 .private_value = ARRAY_SIZE(alc861_asus_modes),
15007 },
15008 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015009};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015010
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015011/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015012static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015013 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15014 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015015 { }
15016};
15017
Kailang Yangdf694da2005-12-05 19:42:22 +010015018/*
15019 * generic initialization of ADC, input mixers and output mixers
15020 */
15021static struct hda_verb alc861_base_init_verbs[] = {
15022 /*
15023 * Unmute ADC0 and set the default input to mic-in
15024 */
15025 /* port-A for surround (rear panel) */
15026 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15027 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15028 /* port-B for mic-in (rear panel) with vref */
15029 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15030 /* port-C for line-in (rear panel) */
15031 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15032 /* port-D for Front */
15033 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15034 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15035 /* port-E for HP out (front panel) */
15036 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15037 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015038 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015039 /* port-F for mic-in (front panel) with vref */
15040 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15041 /* port-G for CLFE (rear panel) */
15042 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15043 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15044 /* port-H for side (rear panel) */
15045 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15046 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15047 /* CD-in */
15048 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15049 /* route front mic to ADC1*/
15050 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015052
Kailang Yangdf694da2005-12-05 19:42:22 +010015053 /* Unmute DAC0~3 & spdif out*/
15054 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15055 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15056 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15057 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015059
Kailang Yangdf694da2005-12-05 19:42:22 +010015060 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15061 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15062 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15063 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15064 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015065
Kailang Yangdf694da2005-12-05 19:42:22 +010015066 /* Unmute Stereo Mixer 15 */
15067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15069 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015070 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015071
15072 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15073 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15075 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15076 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15077 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15078 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15079 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015080 /* hp used DAC 3 (Front) */
15081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015082 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15083
15084 { }
15085};
15086
15087static struct hda_verb alc861_threestack_init_verbs[] = {
15088 /*
15089 * Unmute ADC0 and set the default input to mic-in
15090 */
15091 /* port-A for surround (rear panel) */
15092 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15093 /* port-B for mic-in (rear panel) with vref */
15094 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15095 /* port-C for line-in (rear panel) */
15096 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15097 /* port-D for Front */
15098 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15099 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15100 /* port-E for HP out (front panel) */
15101 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15102 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015103 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015104 /* port-F for mic-in (front panel) with vref */
15105 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15106 /* port-G for CLFE (rear panel) */
15107 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15108 /* port-H for side (rear panel) */
15109 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15110 /* CD-in */
15111 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15112 /* route front mic to ADC1*/
15113 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15115 /* Unmute DAC0~3 & spdif out*/
15116 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15117 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15118 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15119 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015121
Kailang Yangdf694da2005-12-05 19:42:22 +010015122 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15123 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15124 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15125 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15126 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015127
Kailang Yangdf694da2005-12-05 19:42:22 +010015128 /* Unmute Stereo Mixer 15 */
15129 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15130 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15131 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015133
15134 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15135 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15136 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15137 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15138 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15139 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15140 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15141 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015142 /* hp used DAC 3 (Front) */
15143 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015144 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15145 { }
15146};
Takashi Iwai22309c32006-08-09 16:57:28 +020015147
15148static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15149 /*
15150 * Unmute ADC0 and set the default input to mic-in
15151 */
15152 /* port-A for surround (rear panel) */
15153 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15154 /* port-B for mic-in (rear panel) with vref */
15155 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15156 /* port-C for line-in (rear panel) */
15157 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15158 /* port-D for Front */
15159 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15160 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15161 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015162 /* this has to be set to VREF80 */
15163 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015164 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015165 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015166 /* port-F for mic-in (front panel) with vref */
15167 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15168 /* port-G for CLFE (rear panel) */
15169 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15170 /* port-H for side (rear panel) */
15171 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15172 /* CD-in */
15173 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15174 /* route front mic to ADC1*/
15175 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15177 /* Unmute DAC0~3 & spdif out*/
15178 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15179 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15180 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15181 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15182 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015183
Takashi Iwai22309c32006-08-09 16:57:28 +020015184 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15185 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15186 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15187 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15188 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015189
Takashi Iwai22309c32006-08-09 16:57:28 +020015190 /* Unmute Stereo Mixer 15 */
15191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015195
15196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15197 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15198 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15199 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15201 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15202 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15203 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015204 /* hp used DAC 3 (Front) */
15205 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015206 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15207 { }
15208};
15209
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015210static struct hda_verb alc861_asus_init_verbs[] = {
15211 /*
15212 * Unmute ADC0 and set the default input to mic-in
15213 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015214 /* port-A for surround (rear panel)
15215 * according to codec#0 this is the HP jack
15216 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015217 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15218 /* route front PCM to HP */
15219 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15220 /* port-B for mic-in (rear panel) with vref */
15221 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15222 /* port-C for line-in (rear panel) */
15223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15224 /* port-D for Front */
15225 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15226 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15227 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015228 /* this has to be set to VREF80 */
15229 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015230 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015231 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015232 /* port-F for mic-in (front panel) with vref */
15233 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15234 /* port-G for CLFE (rear panel) */
15235 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15236 /* port-H for side (rear panel) */
15237 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15238 /* CD-in */
15239 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15240 /* route front mic to ADC1*/
15241 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15243 /* Unmute DAC0~3 & spdif out*/
15244 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15245 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15246 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15247 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15249 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15250 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15251 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15252 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15253 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015254
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015255 /* Unmute Stereo Mixer 15 */
15256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15257 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015260
15261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15262 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15264 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015269 /* hp used DAC 3 (Front) */
15270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015271 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15272 { }
15273};
15274
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015275/* additional init verbs for ASUS laptops */
15276static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15277 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15278 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15279 { }
15280};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015281
Kailang Yangdf694da2005-12-05 19:42:22 +010015282/*
15283 * generic initialization of ADC, input mixers and output mixers
15284 */
15285static struct hda_verb alc861_auto_init_verbs[] = {
15286 /*
15287 * Unmute ADC0 and set the default input to mic-in
15288 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015289 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015291
Kailang Yangdf694da2005-12-05 19:42:22 +010015292 /* Unmute DAC0~3 & spdif out*/
15293 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15294 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15295 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15296 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15297 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015298
Kailang Yangdf694da2005-12-05 19:42:22 +010015299 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15300 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15301 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15302 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15303 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015304
Kailang Yangdf694da2005-12-05 19:42:22 +010015305 /* Unmute Stereo Mixer 15 */
15306 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15307 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15308 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15309 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15310
Takashi Iwai1c209302009-07-22 15:17:45 +020015311 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15312 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15313 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15314 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15315 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15316 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15317 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15318 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015319
15320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15321 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015322 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15323 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015324 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15327 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015328
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015329 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015330
15331 { }
15332};
15333
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015334static struct hda_verb alc861_toshiba_init_verbs[] = {
15335 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015336
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015337 { }
15338};
15339
15340/* toggle speaker-output according to the hp-jack state */
15341static void alc861_toshiba_automute(struct hda_codec *codec)
15342{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015343 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015344
Takashi Iwai47fd8302007-08-10 17:11:07 +020015345 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15346 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15347 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15348 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015349}
15350
15351static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15352 unsigned int res)
15353{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015354 if ((res >> 26) == ALC880_HP_EVENT)
15355 alc861_toshiba_automute(codec);
15356}
15357
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015358/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015359#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15360#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15361#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15362#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15363
15364
15365#define ALC861_DIGOUT_NID 0x07
15366
15367static struct hda_channel_mode alc861_8ch_modes[1] = {
15368 { 8, NULL }
15369};
15370
15371static hda_nid_t alc861_dac_nids[4] = {
15372 /* front, surround, clfe, side */
15373 0x03, 0x06, 0x05, 0x04
15374};
15375
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015376static hda_nid_t alc660_dac_nids[3] = {
15377 /* front, clfe, surround */
15378 0x03, 0x05, 0x06
15379};
15380
Kailang Yangdf694da2005-12-05 19:42:22 +010015381static hda_nid_t alc861_adc_nids[1] = {
15382 /* ADC0-2 */
15383 0x08,
15384};
15385
15386static struct hda_input_mux alc861_capture_source = {
15387 .num_items = 5,
15388 .items = {
15389 { "Mic", 0x0 },
15390 { "Front Mic", 0x3 },
15391 { "Line", 0x1 },
15392 { "CD", 0x4 },
15393 { "Mixer", 0x5 },
15394 },
15395};
15396
Takashi Iwai1c209302009-07-22 15:17:45 +020015397static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15398{
15399 struct alc_spec *spec = codec->spec;
15400 hda_nid_t mix, srcs[5];
15401 int i, j, num;
15402
15403 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15404 return 0;
15405 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15406 if (num < 0)
15407 return 0;
15408 for (i = 0; i < num; i++) {
15409 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015410 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015411 if (type != AC_WID_AUD_OUT)
15412 continue;
15413 for (j = 0; j < spec->multiout.num_dacs; j++)
15414 if (spec->multiout.dac_nids[j] == srcs[i])
15415 break;
15416 if (j >= spec->multiout.num_dacs)
15417 return srcs[i];
15418 }
15419 return 0;
15420}
15421
Kailang Yangdf694da2005-12-05 19:42:22 +010015422/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015423static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015424 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015425{
Takashi Iwai1c209302009-07-22 15:17:45 +020015426 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015427 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015428 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015429
15430 spec->multiout.dac_nids = spec->private_dac_nids;
15431 for (i = 0; i < cfg->line_outs; i++) {
15432 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015433 dac = alc861_look_for_dac(codec, nid);
15434 if (!dac)
15435 continue;
15436 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015437 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015438 return 0;
15439}
15440
Takashi Iwai1c209302009-07-22 15:17:45 +020015441static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15442 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015443{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015444 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015445 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15446}
15447
15448/* add playback controls from the parsed DAC table */
15449static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15450 const struct auto_pin_cfg *cfg)
15451{
15452 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015453 static const char *chname[4] = {
15454 "Front", "Surround", NULL /*CLFE*/, "Side"
15455 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015456 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015457 int i, err;
15458
15459 if (cfg->line_outs == 1) {
15460 const char *pfx = NULL;
15461 if (!cfg->hp_outs)
15462 pfx = "Master";
15463 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15464 pfx = "Speaker";
15465 if (pfx) {
15466 nid = spec->multiout.dac_nids[0];
15467 return alc861_create_out_sw(codec, pfx, nid, 3);
15468 }
15469 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015470
15471 for (i = 0; i < cfg->line_outs; i++) {
15472 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015473 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015474 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015475 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015476 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015477 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015478 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015479 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015480 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015481 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015482 return err;
15483 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015484 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015485 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015486 return err;
15487 }
15488 }
15489 return 0;
15490}
15491
Takashi Iwai1c209302009-07-22 15:17:45 +020015492static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015493{
Takashi Iwai1c209302009-07-22 15:17:45 +020015494 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015495 int err;
15496 hda_nid_t nid;
15497
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015498 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015499 return 0;
15500
15501 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015502 nid = alc861_look_for_dac(codec, pin);
15503 if (nid) {
15504 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15505 if (err < 0)
15506 return err;
15507 spec->multiout.hp_nid = nid;
15508 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015509 }
15510 return 0;
15511}
15512
15513/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015514static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015515 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015516{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015517 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015518}
15519
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015520static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15521 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015522 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015523{
Takashi Iwai1c209302009-07-22 15:17:45 +020015524 hda_nid_t mix, srcs[5];
15525 int i, num;
15526
Jacek Luczak564c5be2008-05-03 18:41:23 +020015527 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15528 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015529 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015530 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015531 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15532 return;
15533 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15534 if (num < 0)
15535 return;
15536 for (i = 0; i < num; i++) {
15537 unsigned int mute;
15538 if (srcs[i] == dac || srcs[i] == 0x15)
15539 mute = AMP_IN_UNMUTE(i);
15540 else
15541 mute = AMP_IN_MUTE(i);
15542 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15543 mute);
15544 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015545}
15546
15547static void alc861_auto_init_multi_out(struct hda_codec *codec)
15548{
15549 struct alc_spec *spec = codec->spec;
15550 int i;
15551
15552 for (i = 0; i < spec->autocfg.line_outs; i++) {
15553 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015554 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015555 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015556 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015557 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015558 }
15559}
15560
15561static void alc861_auto_init_hp_out(struct hda_codec *codec)
15562{
15563 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015564
Takashi Iwai15870f02009-10-05 08:25:13 +020015565 if (spec->autocfg.hp_outs)
15566 alc861_auto_set_output_and_unmute(codec,
15567 spec->autocfg.hp_pins[0],
15568 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015569 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015570 if (spec->autocfg.speaker_outs)
15571 alc861_auto_set_output_and_unmute(codec,
15572 spec->autocfg.speaker_pins[0],
15573 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015574 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015575}
15576
15577static void alc861_auto_init_analog_input(struct hda_codec *codec)
15578{
15579 struct alc_spec *spec = codec->spec;
15580 int i;
15581
15582 for (i = 0; i < AUTO_PIN_LAST; i++) {
15583 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015584 if (nid >= 0x0c && nid <= 0x11)
15585 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015586 }
15587}
15588
15589/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015590/* return 1 if successful, 0 if the proper config is not found,
15591 * or a negative error code
15592 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015593static int alc861_parse_auto_config(struct hda_codec *codec)
15594{
15595 struct alc_spec *spec = codec->spec;
15596 int err;
15597 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15598
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015599 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15600 alc861_ignore);
15601 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015602 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015603 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015604 return 0; /* can't find valid BIOS pin config */
15605
Takashi Iwai1c209302009-07-22 15:17:45 +020015606 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015607 if (err < 0)
15608 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015609 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015610 if (err < 0)
15611 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015612 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015613 if (err < 0)
15614 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015615 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015616 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015617 return err;
15618
15619 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15620
Takashi Iwai757899a2010-07-30 10:48:14 +020015621 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015622
Takashi Iwai603c4012008-07-30 15:01:44 +020015623 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015624 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015625
Takashi Iwaid88897e2008-10-31 15:01:37 +010015626 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015627
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015628 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015629 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015630
15631 spec->adc_nids = alc861_adc_nids;
15632 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015633 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015634
Kailang Yang6227cdc2010-02-25 08:36:52 +010015635 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015636
Kailang Yangdf694da2005-12-05 19:42:22 +010015637 return 1;
15638}
15639
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015640/* additional initialization for auto-configuration model */
15641static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015642{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015643 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015644 alc861_auto_init_multi_out(codec);
15645 alc861_auto_init_hp_out(codec);
15646 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015647 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015648 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015649 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015650}
15651
Takashi Iwaicb53c622007-08-10 17:21:45 +020015652#ifdef CONFIG_SND_HDA_POWER_SAVE
15653static struct hda_amp_list alc861_loopbacks[] = {
15654 { 0x15, HDA_INPUT, 0 },
15655 { 0x15, HDA_INPUT, 1 },
15656 { 0x15, HDA_INPUT, 2 },
15657 { 0x15, HDA_INPUT, 3 },
15658 { } /* end */
15659};
15660#endif
15661
Kailang Yangdf694da2005-12-05 19:42:22 +010015662
15663/*
15664 * configuration and preset
15665 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015666static const char *alc861_models[ALC861_MODEL_LAST] = {
15667 [ALC861_3ST] = "3stack",
15668 [ALC660_3ST] = "3stack-660",
15669 [ALC861_3ST_DIG] = "3stack-dig",
15670 [ALC861_6ST_DIG] = "6stack-dig",
15671 [ALC861_UNIWILL_M31] = "uniwill-m31",
15672 [ALC861_TOSHIBA] = "toshiba",
15673 [ALC861_ASUS] = "asus",
15674 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15675 [ALC861_AUTO] = "auto",
15676};
15677
15678static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015679 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015680 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15681 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15682 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015683 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015684 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015685 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015686 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15687 * Any other models that need this preset?
15688 */
15689 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015690 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15691 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015692 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15693 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15694 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15695 /* FIXME: the below seems conflict */
15696 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15697 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15698 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015699 {}
15700};
15701
15702static struct alc_config_preset alc861_presets[] = {
15703 [ALC861_3ST] = {
15704 .mixers = { alc861_3ST_mixer },
15705 .init_verbs = { alc861_threestack_init_verbs },
15706 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15707 .dac_nids = alc861_dac_nids,
15708 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15709 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015710 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015711 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15712 .adc_nids = alc861_adc_nids,
15713 .input_mux = &alc861_capture_source,
15714 },
15715 [ALC861_3ST_DIG] = {
15716 .mixers = { alc861_base_mixer },
15717 .init_verbs = { alc861_threestack_init_verbs },
15718 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15719 .dac_nids = alc861_dac_nids,
15720 .dig_out_nid = ALC861_DIGOUT_NID,
15721 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15722 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015723 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015724 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15725 .adc_nids = alc861_adc_nids,
15726 .input_mux = &alc861_capture_source,
15727 },
15728 [ALC861_6ST_DIG] = {
15729 .mixers = { alc861_base_mixer },
15730 .init_verbs = { alc861_base_init_verbs },
15731 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15732 .dac_nids = alc861_dac_nids,
15733 .dig_out_nid = ALC861_DIGOUT_NID,
15734 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15735 .channel_mode = alc861_8ch_modes,
15736 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15737 .adc_nids = alc861_adc_nids,
15738 .input_mux = &alc861_capture_source,
15739 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015740 [ALC660_3ST] = {
15741 .mixers = { alc861_3ST_mixer },
15742 .init_verbs = { alc861_threestack_init_verbs },
15743 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15744 .dac_nids = alc660_dac_nids,
15745 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15746 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015747 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015748 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15749 .adc_nids = alc861_adc_nids,
15750 .input_mux = &alc861_capture_source,
15751 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015752 [ALC861_UNIWILL_M31] = {
15753 .mixers = { alc861_uniwill_m31_mixer },
15754 .init_verbs = { alc861_uniwill_m31_init_verbs },
15755 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15756 .dac_nids = alc861_dac_nids,
15757 .dig_out_nid = ALC861_DIGOUT_NID,
15758 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15759 .channel_mode = alc861_uniwill_m31_modes,
15760 .need_dac_fix = 1,
15761 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15762 .adc_nids = alc861_adc_nids,
15763 .input_mux = &alc861_capture_source,
15764 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015765 [ALC861_TOSHIBA] = {
15766 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015767 .init_verbs = { alc861_base_init_verbs,
15768 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015769 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15770 .dac_nids = alc861_dac_nids,
15771 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15772 .channel_mode = alc883_3ST_2ch_modes,
15773 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15774 .adc_nids = alc861_adc_nids,
15775 .input_mux = &alc861_capture_source,
15776 .unsol_event = alc861_toshiba_unsol_event,
15777 .init_hook = alc861_toshiba_automute,
15778 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015779 [ALC861_ASUS] = {
15780 .mixers = { alc861_asus_mixer },
15781 .init_verbs = { alc861_asus_init_verbs },
15782 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15783 .dac_nids = alc861_dac_nids,
15784 .dig_out_nid = ALC861_DIGOUT_NID,
15785 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15786 .channel_mode = alc861_asus_modes,
15787 .need_dac_fix = 1,
15788 .hp_nid = 0x06,
15789 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15790 .adc_nids = alc861_adc_nids,
15791 .input_mux = &alc861_capture_source,
15792 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015793 [ALC861_ASUS_LAPTOP] = {
15794 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15795 .init_verbs = { alc861_asus_init_verbs,
15796 alc861_asus_laptop_init_verbs },
15797 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15798 .dac_nids = alc861_dac_nids,
15799 .dig_out_nid = ALC861_DIGOUT_NID,
15800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15801 .channel_mode = alc883_3ST_2ch_modes,
15802 .need_dac_fix = 1,
15803 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15804 .adc_nids = alc861_adc_nids,
15805 .input_mux = &alc861_capture_source,
15806 },
15807};
Kailang Yangdf694da2005-12-05 19:42:22 +010015808
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015809/* Pin config fixes */
15810enum {
15811 PINFIX_FSC_AMILO_PI1505,
15812};
15813
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015814static const struct alc_fixup alc861_fixups[] = {
15815 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020015816 .pins = (const struct alc_pincfg[]) {
15817 { 0x0b, 0x0221101f }, /* HP */
15818 { 0x0f, 0x90170310 }, /* speaker */
15819 { }
15820 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015821 },
15822};
15823
15824static struct snd_pci_quirk alc861_fixup_tbl[] = {
15825 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15826 {}
15827};
Kailang Yangdf694da2005-12-05 19:42:22 +010015828
15829static int patch_alc861(struct hda_codec *codec)
15830{
15831 struct alc_spec *spec;
15832 int board_config;
15833 int err;
15834
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015835 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015836 if (spec == NULL)
15837 return -ENOMEM;
15838
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015839 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015840
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015841 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15842 alc861_models,
15843 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015844
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015845 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015846 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15847 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015848 board_config = ALC861_AUTO;
15849 }
15850
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015851 if (board_config == ALC861_AUTO)
15852 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015853
Kailang Yangdf694da2005-12-05 19:42:22 +010015854 if (board_config == ALC861_AUTO) {
15855 /* automatic parse from the BIOS config */
15856 err = alc861_parse_auto_config(codec);
15857 if (err < 0) {
15858 alc_free(codec);
15859 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015860 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015861 printk(KERN_INFO
15862 "hda_codec: Cannot set up configuration "
15863 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015864 board_config = ALC861_3ST_DIG;
15865 }
15866 }
15867
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015868 err = snd_hda_attach_beep_device(codec, 0x23);
15869 if (err < 0) {
15870 alc_free(codec);
15871 return err;
15872 }
15873
Kailang Yangdf694da2005-12-05 19:42:22 +010015874 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015875 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015876
Kailang Yangdf694da2005-12-05 19:42:22 +010015877 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15878 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15879
Kailang Yangdf694da2005-12-05 19:42:22 +010015880 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15881 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15882
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015883 if (!spec->cap_mixer)
15884 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015885 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15886
Takashi Iwai2134ea42008-01-10 16:53:55 +010015887 spec->vmaster_nid = 0x03;
15888
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015889 if (board_config == ALC861_AUTO)
15890 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15891
Kailang Yangdf694da2005-12-05 19:42:22 +010015892 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015893 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015894 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015895#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015896 spec->power_hook = alc_power_eapd;
15897#endif
15898 }
15899#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015900 if (!spec->loopback.amplist)
15901 spec->loopback.amplist = alc861_loopbacks;
15902#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015903
Kailang Yangdf694da2005-12-05 19:42:22 +010015904 return 0;
15905}
15906
15907/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015908 * ALC861-VD support
15909 *
15910 * Based on ALC882
15911 *
15912 * In addition, an independent DAC
15913 */
15914#define ALC861VD_DIGOUT_NID 0x06
15915
15916static hda_nid_t alc861vd_dac_nids[4] = {
15917 /* front, surr, clfe, side surr */
15918 0x02, 0x03, 0x04, 0x05
15919};
15920
15921/* dac_nids for ALC660vd are in a different order - according to
15922 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015923 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015924 * of ALC660vd codecs, but for now there is only 3stack mixer
15925 * - and it is the same as in 861vd.
15926 * adc_nids in ALC660vd are (is) the same as in 861vd
15927 */
15928static hda_nid_t alc660vd_dac_nids[3] = {
15929 /* front, rear, clfe, rear_surr */
15930 0x02, 0x04, 0x03
15931};
15932
15933static hda_nid_t alc861vd_adc_nids[1] = {
15934 /* ADC0 */
15935 0x09,
15936};
15937
Takashi Iwaie1406342008-02-11 18:32:32 +010015938static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15939
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015940/* input MUX */
15941/* FIXME: should be a matrix-type input source selection */
15942static struct hda_input_mux alc861vd_capture_source = {
15943 .num_items = 4,
15944 .items = {
15945 { "Mic", 0x0 },
15946 { "Front Mic", 0x1 },
15947 { "Line", 0x2 },
15948 { "CD", 0x4 },
15949 },
15950};
15951
Kailang Yang272a5272007-05-14 11:00:38 +020015952static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015953 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015954 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015955 { "Ext Mic", 0x0 },
15956 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015957 },
15958};
15959
Kailang Yangd1a991a2007-08-15 16:21:59 +020015960static struct hda_input_mux alc861vd_hp_capture_source = {
15961 .num_items = 2,
15962 .items = {
15963 { "Front Mic", 0x0 },
15964 { "ATAPI Mic", 0x1 },
15965 },
15966};
15967
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015968/*
15969 * 2ch mode
15970 */
15971static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15972 { 2, NULL }
15973};
15974
15975/*
15976 * 6ch mode
15977 */
15978static struct hda_verb alc861vd_6stack_ch6_init[] = {
15979 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15980 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15981 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15982 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15983 { } /* end */
15984};
15985
15986/*
15987 * 8ch mode
15988 */
15989static struct hda_verb alc861vd_6stack_ch8_init[] = {
15990 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
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
15997static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15998 { 6, alc861vd_6stack_ch6_init },
15999 { 8, alc861vd_6stack_ch8_init },
16000};
16001
16002static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16003 {
16004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16005 .name = "Channel Mode",
16006 .info = alc_ch_mode_info,
16007 .get = alc_ch_mode_get,
16008 .put = alc_ch_mode_put,
16009 },
16010 { } /* end */
16011};
16012
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016013/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16014 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16015 */
16016static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16017 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16019
16020 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16021 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16022
16023 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16024 HDA_OUTPUT),
16025 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16026 HDA_OUTPUT),
16027 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16028 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16029
16030 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16031 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16032
16033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16034
16035 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16036 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16037 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16038
16039 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16040 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16041 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16042
16043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16045
16046 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16047 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16048
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016049 { } /* end */
16050};
16051
16052static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16053 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16054 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16055
16056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16057
16058 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16059 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16060 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16061
16062 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16063 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16064 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16065
16066 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16067 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16068
16069 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16070 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16071
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016072 { } /* end */
16073};
16074
Kailang Yangbdd148a2007-05-08 15:19:08 +020016075static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16076 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16077 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16078 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16079
16080 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16081
16082 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16085
16086 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16087 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16089
16090 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16091 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16092
16093 { } /* end */
16094};
16095
Tobin Davisb419f342008-03-07 11:57:51 +010016096/* Pin assignment: Speaker=0x14, HP = 0x15,
16097 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016098 */
16099static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016100 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16101 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16103 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016104 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16105 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16106 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16107 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16108 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16109 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016110 { } /* end */
16111};
16112
Kailang Yangd1a991a2007-08-15 16:21:59 +020016113/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16114 * Front Mic=0x18, ATAPI Mic = 0x19,
16115 */
16116static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16117 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16119 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16120 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16121 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16122 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16123 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16124 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016125
Kailang Yangd1a991a2007-08-15 16:21:59 +020016126 { } /* end */
16127};
16128
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016129/*
16130 * generic initialization of ADC, input mixers and output mixers
16131 */
16132static struct hda_verb alc861vd_volume_init_verbs[] = {
16133 /*
16134 * Unmute ADC0 and set the default input to mic-in
16135 */
16136 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16137 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16138
16139 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16140 * the analog-loopback mixer widget
16141 */
16142 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016148
16149 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016150 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16151 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16152 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016153 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016154
16155 /*
16156 * Set up output mixers (0x02 - 0x05)
16157 */
16158 /* set vol=0 to output mixers */
16159 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16160 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16161 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16162 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16163
16164 /* set up input amps for analog loopback */
16165 /* Amp Indices: DAC = 0, mixer = 1 */
16166 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16167 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16172 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16173 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16174
16175 { }
16176};
16177
16178/*
16179 * 3-stack pin configuration:
16180 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16181 */
16182static struct hda_verb alc861vd_3stack_init_verbs[] = {
16183 /*
16184 * Set pin mode and muting
16185 */
16186 /* set front pin widgets 0x14 for output */
16187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16189 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16190
16191 /* Mic (rear) pin: input vref at 80% */
16192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16194 /* Front Mic pin: input vref at 80% */
16195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16197 /* Line In pin: input */
16198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16200 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16203 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16204 /* CD pin widget for input */
16205 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16206
16207 { }
16208};
16209
16210/*
16211 * 6-stack pin configuration:
16212 */
16213static struct hda_verb alc861vd_6stack_init_verbs[] = {
16214 /*
16215 * Set pin mode and muting
16216 */
16217 /* set front pin widgets 0x14 for output */
16218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16220 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16221
16222 /* Rear Pin: output 1 (0x0d) */
16223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16226 /* CLFE Pin: output 2 (0x0e) */
16227 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16228 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16229 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16230 /* Side Pin: output 3 (0x0f) */
16231 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16232 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16233 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16234
16235 /* Mic (rear) pin: input vref at 80% */
16236 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16237 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16238 /* Front Mic pin: input vref at 80% */
16239 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16240 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16241 /* Line In pin: input */
16242 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16243 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16244 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16245 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16246 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16247 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16248 /* CD pin widget for input */
16249 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16250
16251 { }
16252};
16253
Kailang Yangbdd148a2007-05-08 15:19:08 +020016254static struct hda_verb alc861vd_eapd_verbs[] = {
16255 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16256 { }
16257};
16258
Kailang Yangf9423e72008-05-27 12:32:25 +020016259static struct hda_verb alc660vd_eapd_verbs[] = {
16260 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16261 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16262 { }
16263};
16264
Kailang Yangbdd148a2007-05-08 15:19:08 +020016265static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16269 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016270 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016271 {}
16272};
16273
Kailang Yangbdd148a2007-05-08 15:19:08 +020016274static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16275{
16276 unsigned int present;
16277 unsigned char bits;
16278
Wu Fengguang864f92b2009-11-18 12:38:02 +080016279 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016280 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016281
Takashi Iwai47fd8302007-08-10 17:11:07 +020016282 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16283 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016284}
16285
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016286static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016287{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016288 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016289 spec->autocfg.hp_pins[0] = 0x1b;
16290 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016291}
16292
16293static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16294{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016295 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016296 alc861vd_lenovo_mic_automute(codec);
16297}
16298
16299static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16300 unsigned int res)
16301{
16302 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016303 case ALC880_MIC_EVENT:
16304 alc861vd_lenovo_mic_automute(codec);
16305 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016306 default:
16307 alc_automute_amp_unsol_event(codec, res);
16308 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016309 }
16310}
16311
Kailang Yang272a5272007-05-14 11:00:38 +020016312static struct hda_verb alc861vd_dallas_verbs[] = {
16313 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16314 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16315 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16316 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16317
16318 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16319 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16320 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16321 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16322 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16323 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16324 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16325 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016326
Kailang Yang272a5272007-05-14 11:00:38 +020016327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16328 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16329 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16331 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16332 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16333 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16334 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16335
16336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16342 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16343 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16344
16345 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16346 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16347 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16348 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16349
16350 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016351 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016352 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16353
16354 { } /* end */
16355};
16356
16357/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016358static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016359{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016360 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016361
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016362 spec->autocfg.hp_pins[0] = 0x15;
16363 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016364}
16365
Takashi Iwaicb53c622007-08-10 17:21:45 +020016366#ifdef CONFIG_SND_HDA_POWER_SAVE
16367#define alc861vd_loopbacks alc880_loopbacks
16368#endif
16369
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016370/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016371#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16372#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16373#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16374#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16375
16376/*
16377 * configuration and preset
16378 */
16379static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16380 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016381 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016382 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016383 [ALC861VD_3ST] = "3stack",
16384 [ALC861VD_3ST_DIG] = "3stack-digout",
16385 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016386 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016387 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016388 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016389 [ALC861VD_AUTO] = "auto",
16390};
16391
16392static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016393 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16394 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016395 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016396 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016397 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016398 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016399 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016400 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016401 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016402 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016403 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016404 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016405 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016406 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016407 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016408 {}
16409};
16410
16411static struct alc_config_preset alc861vd_presets[] = {
16412 [ALC660VD_3ST] = {
16413 .mixers = { alc861vd_3st_mixer },
16414 .init_verbs = { alc861vd_volume_init_verbs,
16415 alc861vd_3stack_init_verbs },
16416 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16417 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016418 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16419 .channel_mode = alc861vd_3stack_2ch_modes,
16420 .input_mux = &alc861vd_capture_source,
16421 },
Mike Crash6963f842007-06-25 12:12:51 +020016422 [ALC660VD_3ST_DIG] = {
16423 .mixers = { alc861vd_3st_mixer },
16424 .init_verbs = { alc861vd_volume_init_verbs,
16425 alc861vd_3stack_init_verbs },
16426 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16427 .dac_nids = alc660vd_dac_nids,
16428 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016429 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16430 .channel_mode = alc861vd_3stack_2ch_modes,
16431 .input_mux = &alc861vd_capture_source,
16432 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016433 [ALC861VD_3ST] = {
16434 .mixers = { alc861vd_3st_mixer },
16435 .init_verbs = { alc861vd_volume_init_verbs,
16436 alc861vd_3stack_init_verbs },
16437 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16438 .dac_nids = alc861vd_dac_nids,
16439 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16440 .channel_mode = alc861vd_3stack_2ch_modes,
16441 .input_mux = &alc861vd_capture_source,
16442 },
16443 [ALC861VD_3ST_DIG] = {
16444 .mixers = { alc861vd_3st_mixer },
16445 .init_verbs = { alc861vd_volume_init_verbs,
16446 alc861vd_3stack_init_verbs },
16447 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16448 .dac_nids = alc861vd_dac_nids,
16449 .dig_out_nid = ALC861VD_DIGOUT_NID,
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_6ST_DIG] = {
16455 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16456 .init_verbs = { alc861vd_volume_init_verbs,
16457 alc861vd_6stack_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_6stack_modes),
16462 .channel_mode = alc861vd_6stack_modes,
16463 .input_mux = &alc861vd_capture_source,
16464 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016465 [ALC861VD_LENOVO] = {
16466 .mixers = { alc861vd_lenovo_mixer },
16467 .init_verbs = { alc861vd_volume_init_verbs,
16468 alc861vd_3stack_init_verbs,
16469 alc861vd_eapd_verbs,
16470 alc861vd_lenovo_unsol_verbs },
16471 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16472 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016473 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16474 .channel_mode = alc861vd_3stack_2ch_modes,
16475 .input_mux = &alc861vd_capture_source,
16476 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016477 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016478 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016479 },
Kailang Yang272a5272007-05-14 11:00:38 +020016480 [ALC861VD_DALLAS] = {
16481 .mixers = { alc861vd_dallas_mixer },
16482 .init_verbs = { alc861vd_dallas_verbs },
16483 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16484 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016485 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16486 .channel_mode = alc861vd_3stack_2ch_modes,
16487 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016488 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016489 .setup = alc861vd_dallas_setup,
16490 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016491 },
16492 [ALC861VD_HP] = {
16493 .mixers = { alc861vd_hp_mixer },
16494 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16495 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16496 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016497 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016498 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16499 .channel_mode = alc861vd_3stack_2ch_modes,
16500 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016501 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016502 .setup = alc861vd_dallas_setup,
16503 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016504 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016505 [ALC660VD_ASUS_V1S] = {
16506 .mixers = { alc861vd_lenovo_mixer },
16507 .init_verbs = { alc861vd_volume_init_verbs,
16508 alc861vd_3stack_init_verbs,
16509 alc861vd_eapd_verbs,
16510 alc861vd_lenovo_unsol_verbs },
16511 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16512 .dac_nids = alc660vd_dac_nids,
16513 .dig_out_nid = ALC861VD_DIGOUT_NID,
16514 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16515 .channel_mode = alc861vd_3stack_2ch_modes,
16516 .input_mux = &alc861vd_capture_source,
16517 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016518 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016519 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016520 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016521};
16522
16523/*
16524 * BIOS auto configuration
16525 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016526static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16527 const struct auto_pin_cfg *cfg)
16528{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016529 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016530}
16531
16532
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016533static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16534 hda_nid_t nid, int pin_type, int dac_idx)
16535{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016536 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016537}
16538
16539static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16540{
16541 struct alc_spec *spec = codec->spec;
16542 int i;
16543
16544 for (i = 0; i <= HDA_SIDE; i++) {
16545 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016546 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016547 if (nid)
16548 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016549 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016550 }
16551}
16552
16553
16554static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16555{
16556 struct alc_spec *spec = codec->spec;
16557 hda_nid_t pin;
16558
16559 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016560 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016561 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016562 pin = spec->autocfg.speaker_pins[0];
16563 if (pin)
16564 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016565}
16566
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016567#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16568
16569static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16570{
16571 struct alc_spec *spec = codec->spec;
16572 int i;
16573
16574 for (i = 0; i < AUTO_PIN_LAST; i++) {
16575 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016576 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016577 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016578 if (nid != ALC861VD_PIN_CD_NID &&
16579 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016580 snd_hda_codec_write(codec, nid, 0,
16581 AC_VERB_SET_AMP_GAIN_MUTE,
16582 AMP_OUT_MUTE);
16583 }
16584 }
16585}
16586
Takashi Iwaif511b012008-08-15 16:46:42 +020016587#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16588
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016589#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16590#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16591
16592/* add playback controls from the parsed DAC table */
16593/* Based on ALC880 version. But ALC861VD has separate,
16594 * different NIDs for mute/unmute switch and volume control */
16595static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16596 const struct auto_pin_cfg *cfg)
16597{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016598 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16599 hda_nid_t nid_v, nid_s;
16600 int i, err;
16601
16602 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016603 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016604 continue;
16605 nid_v = alc861vd_idx_to_mixer_vol(
16606 alc880_dac_to_idx(
16607 spec->multiout.dac_nids[i]));
16608 nid_s = alc861vd_idx_to_mixer_switch(
16609 alc880_dac_to_idx(
16610 spec->multiout.dac_nids[i]));
16611
16612 if (i == 2) {
16613 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016614 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16615 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016616 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16617 HDA_OUTPUT));
16618 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016619 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016620 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16621 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016622 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16623 HDA_OUTPUT));
16624 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016625 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016626 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16627 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016628 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16629 HDA_INPUT));
16630 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016631 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016632 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16633 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016634 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16635 HDA_INPUT));
16636 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016637 return err;
16638 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016639 const char *pfx;
16640 if (cfg->line_outs == 1 &&
16641 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16642 if (!cfg->hp_pins)
16643 pfx = "Speaker";
16644 else
16645 pfx = "PCM";
16646 } else
16647 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016648 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016649 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16650 HDA_OUTPUT));
16651 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016652 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016653 if (cfg->line_outs == 1 &&
16654 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16655 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016656 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016657 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016658 HDA_INPUT));
16659 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016660 return err;
16661 }
16662 }
16663 return 0;
16664}
16665
16666/* add playback controls for speaker and HP outputs */
16667/* Based on ALC880 version. But ALC861VD has separate,
16668 * different NIDs for mute/unmute switch and volume control */
16669static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16670 hda_nid_t pin, const char *pfx)
16671{
16672 hda_nid_t nid_v, nid_s;
16673 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016674
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016675 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016676 return 0;
16677
16678 if (alc880_is_fixed_pin(pin)) {
16679 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16680 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016681 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016682 spec->multiout.hp_nid = nid_v;
16683 else
16684 spec->multiout.extra_out_nid[0] = nid_v;
16685 /* control HP volume/switch on the output mixer amp */
16686 nid_v = alc861vd_idx_to_mixer_vol(
16687 alc880_fixed_pin_idx(pin));
16688 nid_s = alc861vd_idx_to_mixer_switch(
16689 alc880_fixed_pin_idx(pin));
16690
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016691 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016692 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16693 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016694 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016695 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016696 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16697 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016698 return err;
16699 } else if (alc880_is_multi_pin(pin)) {
16700 /* set manual connection */
16701 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016702 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016703 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16704 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016705 return err;
16706 }
16707 return 0;
16708}
16709
16710/* parse the BIOS configuration and set up the alc_spec
16711 * return 1 if successful, 0 if the proper config is not found,
16712 * or a negative error code
16713 * Based on ALC880 version - had to change it to override
16714 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16715static int alc861vd_parse_auto_config(struct hda_codec *codec)
16716{
16717 struct alc_spec *spec = codec->spec;
16718 int err;
16719 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16720
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016721 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16722 alc861vd_ignore);
16723 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016724 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016725 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016726 return 0; /* can't find valid BIOS pin config */
16727
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016728 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16729 if (err < 0)
16730 return err;
16731 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16732 if (err < 0)
16733 return err;
16734 err = alc861vd_auto_create_extra_out(spec,
16735 spec->autocfg.speaker_pins[0],
16736 "Speaker");
16737 if (err < 0)
16738 return err;
16739 err = alc861vd_auto_create_extra_out(spec,
16740 spec->autocfg.hp_pins[0],
16741 "Headphone");
16742 if (err < 0)
16743 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016744 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016745 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016746 return err;
16747
16748 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16749
Takashi Iwai757899a2010-07-30 10:48:14 +020016750 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016751
Takashi Iwai603c4012008-07-30 15:01:44 +020016752 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016753 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016754
Takashi Iwaid88897e2008-10-31 15:01:37 +010016755 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016756
16757 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016758 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016759
Takashi Iwai776e1842007-08-29 15:07:11 +020016760 err = alc_auto_add_mic_boost(codec);
16761 if (err < 0)
16762 return err;
16763
Kailang Yang6227cdc2010-02-25 08:36:52 +010016764 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016765
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016766 return 1;
16767}
16768
16769/* additional initialization for auto-configuration model */
16770static void alc861vd_auto_init(struct hda_codec *codec)
16771{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016772 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016773 alc861vd_auto_init_multi_out(codec);
16774 alc861vd_auto_init_hp_out(codec);
16775 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016776 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016777 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016778 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016779 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016780}
16781
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016782enum {
16783 ALC660VD_FIX_ASUS_GPIO1
16784};
16785
16786/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016787static const struct alc_fixup alc861vd_fixups[] = {
16788 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016789 .verbs = (const struct hda_verb[]) {
16790 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16791 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16792 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16793 { }
16794 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016795 },
16796};
16797
16798static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16799 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16800 {}
16801};
16802
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016803static int patch_alc861vd(struct hda_codec *codec)
16804{
16805 struct alc_spec *spec;
16806 int err, board_config;
16807
16808 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16809 if (spec == NULL)
16810 return -ENOMEM;
16811
16812 codec->spec = spec;
16813
16814 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16815 alc861vd_models,
16816 alc861vd_cfg_tbl);
16817
16818 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016819 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16820 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016821 board_config = ALC861VD_AUTO;
16822 }
16823
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016824 if (board_config == ALC861VD_AUTO)
16825 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016826
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016827 if (board_config == ALC861VD_AUTO) {
16828 /* automatic parse from the BIOS config */
16829 err = alc861vd_parse_auto_config(codec);
16830 if (err < 0) {
16831 alc_free(codec);
16832 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016833 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016834 printk(KERN_INFO
16835 "hda_codec: Cannot set up configuration "
16836 "from BIOS. Using base mode...\n");
16837 board_config = ALC861VD_3ST;
16838 }
16839 }
16840
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016841 err = snd_hda_attach_beep_device(codec, 0x23);
16842 if (err < 0) {
16843 alc_free(codec);
16844 return err;
16845 }
16846
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016847 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016848 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016849
Kailang Yang2f893282008-05-27 12:14:47 +020016850 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016851 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016852 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016853 }
16854
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016855 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16856 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16857
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016858 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16859 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16860
Takashi Iwaidd704692009-08-11 08:45:11 +020016861 if (!spec->adc_nids) {
16862 spec->adc_nids = alc861vd_adc_nids;
16863 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16864 }
16865 if (!spec->capsrc_nids)
16866 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016867
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016868 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016869 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016870
Takashi Iwai2134ea42008-01-10 16:53:55 +010016871 spec->vmaster_nid = 0x02;
16872
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016873 if (board_config == ALC861VD_AUTO)
16874 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16875
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016876 codec->patch_ops = alc_patch_ops;
16877
16878 if (board_config == ALC861VD_AUTO)
16879 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016880#ifdef CONFIG_SND_HDA_POWER_SAVE
16881 if (!spec->loopback.amplist)
16882 spec->loopback.amplist = alc861vd_loopbacks;
16883#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016884
16885 return 0;
16886}
16887
16888/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016889 * ALC662 support
16890 *
16891 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16892 * configuration. Each pin widget can choose any input DACs and a mixer.
16893 * Each ADC is connected from a mixer of all inputs. This makes possible
16894 * 6-channel independent captures.
16895 *
16896 * In addition, an independent DAC for the multi-playback (not used in this
16897 * driver yet).
16898 */
16899#define ALC662_DIGOUT_NID 0x06
16900#define ALC662_DIGIN_NID 0x0a
16901
16902static hda_nid_t alc662_dac_nids[4] = {
16903 /* front, rear, clfe, rear_surr */
16904 0x02, 0x03, 0x04
16905};
16906
Kailang Yang622e84c2009-04-21 07:39:04 +020016907static hda_nid_t alc272_dac_nids[2] = {
16908 0x02, 0x03
16909};
16910
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016911static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016912 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016913 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016914};
Takashi Iwaie1406342008-02-11 18:32:32 +010016915
Kailang Yang622e84c2009-04-21 07:39:04 +020016916static hda_nid_t alc272_adc_nids[1] = {
16917 /* ADC1-2 */
16918 0x08,
16919};
16920
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016921static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016922static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16923
Takashi Iwaie1406342008-02-11 18:32:32 +010016924
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016925/* input MUX */
16926/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016927static struct hda_input_mux alc662_capture_source = {
16928 .num_items = 4,
16929 .items = {
16930 { "Mic", 0x0 },
16931 { "Front Mic", 0x1 },
16932 { "Line", 0x2 },
16933 { "CD", 0x4 },
16934 },
16935};
16936
16937static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16938 .num_items = 2,
16939 .items = {
16940 { "Mic", 0x1 },
16941 { "Line", 0x2 },
16942 },
16943};
Kailang Yang291702f2007-10-16 14:28:03 +020016944
Kailang Yang6dda9f42008-05-27 12:05:31 +020016945static struct hda_input_mux alc663_capture_source = {
16946 .num_items = 3,
16947 .items = {
16948 { "Mic", 0x0 },
16949 { "Front Mic", 0x1 },
16950 { "Line", 0x2 },
16951 },
16952};
16953
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016954#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016955static struct hda_input_mux alc272_nc10_capture_source = {
16956 .num_items = 16,
16957 .items = {
16958 { "Autoselect Mic", 0x0 },
16959 { "Internal Mic", 0x1 },
16960 { "In-0x02", 0x2 },
16961 { "In-0x03", 0x3 },
16962 { "In-0x04", 0x4 },
16963 { "In-0x05", 0x5 },
16964 { "In-0x06", 0x6 },
16965 { "In-0x07", 0x7 },
16966 { "In-0x08", 0x8 },
16967 { "In-0x09", 0x9 },
16968 { "In-0x0a", 0x0a },
16969 { "In-0x0b", 0x0b },
16970 { "In-0x0c", 0x0c },
16971 { "In-0x0d", 0x0d },
16972 { "In-0x0e", 0x0e },
16973 { "In-0x0f", 0x0f },
16974 },
16975};
16976#endif
16977
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016978/*
16979 * 2ch mode
16980 */
16981static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16982 { 2, NULL }
16983};
16984
16985/*
16986 * 2ch mode
16987 */
16988static struct hda_verb alc662_3ST_ch2_init[] = {
16989 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16990 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16991 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16992 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16993 { } /* end */
16994};
16995
16996/*
16997 * 6ch mode
16998 */
16999static struct hda_verb alc662_3ST_ch6_init[] = {
17000 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17001 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17002 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17003 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17004 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17005 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17006 { } /* end */
17007};
17008
17009static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17010 { 2, alc662_3ST_ch2_init },
17011 { 6, alc662_3ST_ch6_init },
17012};
17013
17014/*
17015 * 2ch mode
17016 */
17017static struct hda_verb alc662_sixstack_ch6_init[] = {
17018 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17019 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17020 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17021 { } /* end */
17022};
17023
17024/*
17025 * 6ch mode
17026 */
17027static struct hda_verb alc662_sixstack_ch8_init[] = {
17028 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17029 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17030 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17031 { } /* end */
17032};
17033
17034static struct hda_channel_mode alc662_5stack_modes[2] = {
17035 { 2, alc662_sixstack_ch6_init },
17036 { 6, alc662_sixstack_ch8_init },
17037};
17038
17039/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17040 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17041 */
17042
17043static struct snd_kcontrol_new alc662_base_mixer[] = {
17044 /* output mixer control */
17045 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017046 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017047 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017048 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017049 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17050 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017051 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17052 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17054
17055 /*Input mixer control */
17056 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17057 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17058 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17059 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17060 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17061 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17062 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17063 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017064 { } /* end */
17065};
17066
17067static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17068 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017069 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017070 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17071 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17072 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17077 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17078 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017079 { } /* end */
17080};
17081
17082static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17083 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017084 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017085 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017086 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017087 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17088 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017089 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17090 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017091 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17092 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17093 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17096 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17097 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17098 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17099 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017100 { } /* end */
17101};
17102
17103static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17104 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17105 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017106 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17107 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017108 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17109 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17110 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17111 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17112 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017113 { } /* end */
17114};
17115
Kailang Yang291702f2007-10-16 14:28:03 +020017116static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017117 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17118 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017119
17120 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17121 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17122 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17123
17124 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17125 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17126 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17127 { } /* end */
17128};
17129
Kailang Yang8c427222008-01-10 13:03:59 +010017130static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017131 ALC262_HIPPO_MASTER_SWITCH,
17132 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017133 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017134 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17135 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017136 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17137 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17138 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17141 { } /* end */
17142};
17143
Kailang Yangf1d4e282008-08-26 14:03:29 +020017144static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17145 .ops = &snd_hda_bind_vol,
17146 .values = {
17147 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17148 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17149 0
17150 },
17151};
17152
17153static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17154 .ops = &snd_hda_bind_sw,
17155 .values = {
17156 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17157 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17158 0
17159 },
17160};
17161
Kailang Yang6dda9f42008-05-27 12:05:31 +020017162static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017163 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17164 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17165 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17166 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17167 { } /* end */
17168};
17169
17170static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17171 .ops = &snd_hda_bind_sw,
17172 .values = {
17173 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17174 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17175 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17176 0
17177 },
17178};
17179
17180static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17181 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17182 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17185 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17186 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17187
17188 { } /* end */
17189};
17190
17191static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17192 .ops = &snd_hda_bind_sw,
17193 .values = {
17194 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17195 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17196 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17197 0
17198 },
17199};
17200
17201static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17202 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17203 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17204 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17205 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17206 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17207 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17208 { } /* end */
17209};
17210
17211static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017212 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17213 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017214 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17215 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17217 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17218 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17219 { } /* end */
17220};
17221
17222static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17223 .ops = &snd_hda_bind_vol,
17224 .values = {
17225 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17226 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17227 0
17228 },
17229};
17230
17231static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17232 .ops = &snd_hda_bind_sw,
17233 .values = {
17234 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17235 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17236 0
17237 },
17238};
17239
17240static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17241 HDA_BIND_VOL("Master Playback Volume",
17242 &alc663_asus_two_bind_master_vol),
17243 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17244 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017245 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017248 { } /* end */
17249};
17250
17251static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17252 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17253 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17254 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17257 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017258 { } /* end */
17259};
17260
17261static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17262 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17263 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17264 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17265 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17267
17268 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17269 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17270 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17271 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17272 { } /* end */
17273};
17274
17275static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17276 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17277 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17279
17280 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17281 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17282 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17283 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17284 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17285 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17286 { } /* end */
17287};
17288
Kailang Yangebb83ee2009-12-17 12:23:00 +010017289static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17290 .ops = &snd_hda_bind_sw,
17291 .values = {
17292 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17293 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17294 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17295 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17296 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17297 0
17298 },
17299};
17300
17301static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17302 .ops = &snd_hda_bind_sw,
17303 .values = {
17304 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17305 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17306 0
17307 },
17308};
17309
17310static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17311 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17312 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17313 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17314 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17315 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17316 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17317 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17320 { } /* end */
17321};
17322
17323static struct snd_kcontrol_new alc663_mode8_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", 0x15, 0x0, HDA_OUTPUT),
17328 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17331 { } /* end */
17332};
17333
17334
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017335static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17336 {
17337 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17338 .name = "Channel Mode",
17339 .info = alc_ch_mode_info,
17340 .get = alc_ch_mode_get,
17341 .put = alc_ch_mode_put,
17342 },
17343 { } /* end */
17344};
17345
17346static struct hda_verb alc662_init_verbs[] = {
17347 /* ADC: mute amp left and right */
17348 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17349 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017350
Kailang Yangb60dd392007-09-20 12:50:29 +020017351 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17352 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17353 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17354 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17355 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17356 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017357
17358 /* Front Pin: output 0 (0x0c) */
17359 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17360 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17361
17362 /* Rear Pin: output 1 (0x0d) */
17363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17365
17366 /* CLFE Pin: output 2 (0x0e) */
17367 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17368 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17369
17370 /* Mic (rear) pin: input vref at 80% */
17371 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17372 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17373 /* Front Mic pin: input vref at 80% */
17374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17376 /* Line In pin: input */
17377 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17379 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17380 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17381 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17382 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17383 /* CD pin widget for input */
17384 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17385
17386 /* FIXME: use matrix-type input source selection */
17387 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17388 /* Input mixer */
17389 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017390 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017391
17392 /* always trun on EAPD */
17393 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17394 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17395
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017396 { }
17397};
17398
Kailang Yangcec27c82010-02-04 14:18:18 +010017399static struct hda_verb alc663_init_verbs[] = {
17400 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17401 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17402 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17403 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17404 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17405 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17406 { }
17407};
17408
17409static struct hda_verb alc272_init_verbs[] = {
17410 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17411 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17412 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17413 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17414 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17415 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17417 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17418 { }
17419};
17420
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421static struct hda_verb alc662_sue_init_verbs[] = {
17422 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17423 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017424 {}
17425};
17426
17427static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17428 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17429 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17430 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017431};
17432
Kailang Yang8c427222008-01-10 13:03:59 +010017433/* Set Unsolicited Event*/
17434static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17435 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17436 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17437 {}
17438};
17439
Kailang Yang6dda9f42008-05-27 12:05:31 +020017440static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017441 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17442 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017443 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17444 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017445 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17446 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017448 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17449 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17450 {}
17451};
17452
Kailang Yangf1d4e282008-08-26 14:03:29 +020017453static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17454 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17455 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17456 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17459 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17460 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17461 {}
17462};
17463
17464static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17465 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17466 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17467 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17468 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17470 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17471 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17472 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17473 {}
17474};
17475
17476static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17478 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17479 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17482 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17483 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17484 {}
17485};
17486
17487static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17488 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17489 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17490 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17491 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17496 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17497 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17498 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17499 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17500 {}
17501};
17502
17503static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17504 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17505 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17506 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17507 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17509 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17510 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17513 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17514 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17515 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17516 {}
17517};
17518
Kailang Yang6dda9f42008-05-27 12:05:31 +020017519static struct hda_verb alc663_g71v_init_verbs[] = {
17520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17521 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17522 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17523
17524 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17525 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17526 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17527
17528 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17529 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17530 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17531 {}
17532};
17533
17534static struct hda_verb alc663_g50v_init_verbs[] = {
17535 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17536 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17537 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17538
17539 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17540 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17541 {}
17542};
17543
Kailang Yangf1d4e282008-08-26 14:03:29 +020017544static struct hda_verb alc662_ecs_init_verbs[] = {
17545 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17547 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17548 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17549 {}
17550};
17551
Kailang Yang622e84c2009-04-21 07:39:04 +020017552static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17553 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17554 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17555 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17556 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17557 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17558 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17559 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17560 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17561 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17562 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17563 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17564 {}
17565};
17566
17567static struct hda_verb alc272_dell_init_verbs[] = {
17568 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17569 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17571 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17572 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17573 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17574 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17575 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17576 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17578 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17579 {}
17580};
17581
Kailang Yangebb83ee2009-12-17 12:23:00 +010017582static struct hda_verb alc663_mode7_init_verbs[] = {
17583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17584 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17585 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17586 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17588 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17589 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17590 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17591 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17592 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17595 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17596 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17597 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17598 {}
17599};
17600
17601static struct hda_verb alc663_mode8_init_verbs[] = {
17602 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17606 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17607 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17609 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17610 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17611 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17612 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17615 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17616 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17617 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17618 {}
17619};
17620
Kailang Yangf1d4e282008-08-26 14:03:29 +020017621static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17622 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17623 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17624 { } /* end */
17625};
17626
Kailang Yang622e84c2009-04-21 07:39:04 +020017627static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17628 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17629 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17630 { } /* end */
17631};
17632
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017633static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17634{
17635 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017636 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017637
Wu Fengguang864f92b2009-11-18 12:38:02 +080017638 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017639 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017640
Takashi Iwai47fd8302007-08-10 17:11:07 +020017641 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17642 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017643}
17644
17645static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17646{
17647 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017648 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649
Wu Fengguang864f92b2009-11-18 12:38:02 +080017650 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017651 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017652
Takashi Iwai47fd8302007-08-10 17:11:07 +020017653 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17654 HDA_AMP_MUTE, bits);
17655 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17656 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017657}
17658
17659static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17660 unsigned int res)
17661{
17662 if ((res >> 26) == ALC880_HP_EVENT)
17663 alc662_lenovo_101e_all_automute(codec);
17664 if ((res >> 26) == ALC880_FRONT_EVENT)
17665 alc662_lenovo_101e_ispeaker_automute(codec);
17666}
17667
Kailang Yang291702f2007-10-16 14:28:03 +020017668/* unsolicited event for HP jack sensing */
17669static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17670 unsigned int res)
17671{
Kailang Yang291702f2007-10-16 14:28:03 +020017672 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017673 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017674 else
17675 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017676}
17677
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017678static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017679{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017680 struct alc_spec *spec = codec->spec;
17681
17682 alc262_hippo1_setup(codec);
17683 spec->ext_mic.pin = 0x18;
17684 spec->ext_mic.mux_idx = 0;
17685 spec->int_mic.pin = 0x19;
17686 spec->int_mic.mux_idx = 1;
17687 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017688}
17689
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017690static void alc662_eeepc_inithook(struct hda_codec *codec)
17691{
17692 alc262_hippo_automute(codec);
17693 alc_mic_automute(codec);
17694}
17695
17696static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017697{
Takashi Iwai42171c12009-05-08 14:11:43 +020017698 struct alc_spec *spec = codec->spec;
17699
17700 spec->autocfg.hp_pins[0] = 0x14;
17701 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017702}
17703
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017704#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17705
Kailang Yang6dda9f42008-05-27 12:05:31 +020017706static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17707{
17708 unsigned int present;
17709 unsigned char bits;
17710
Wu Fengguang864f92b2009-11-18 12:38:02 +080017711 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017712 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017713 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017714 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017715 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017716 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017717}
17718
17719static void alc663_21jd_two_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 Yangf1d4e282008-08-26 14:03:29 +020017725 bits = present ? HDA_AMP_MUTE : 0;
17726 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 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017731 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017732 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017733 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017734}
17735
17736static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17737{
17738 unsigned int present;
17739 unsigned char bits;
17740
Wu Fengguang864f92b2009-11-18 12:38:02 +080017741 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017742 bits = present ? HDA_AMP_MUTE : 0;
17743 snd_hda_codec_amp_stereo(codec, 0x0c, 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, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017746 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017747 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017748 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017749 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017750 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017751}
17752
17753static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17754{
17755 unsigned int present;
17756 unsigned char bits;
17757
Wu Fengguang864f92b2009-11-18 12:38:02 +080017758 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017759 bits = present ? 0 : PIN_OUT;
17760 snd_hda_codec_write(codec, 0x14, 0,
17761 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17762}
17763
17764static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17765{
17766 unsigned int present1, present2;
17767
Wu Fengguang864f92b2009-11-18 12:38:02 +080017768 present1 = snd_hda_jack_detect(codec, 0x21);
17769 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017770
17771 if (present1 || present2) {
17772 snd_hda_codec_write_cache(codec, 0x14, 0,
17773 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17774 } else {
17775 snd_hda_codec_write_cache(codec, 0x14, 0,
17776 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17777 }
17778}
17779
17780static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17781{
17782 unsigned int present1, present2;
17783
Wu Fengguang864f92b2009-11-18 12:38:02 +080017784 present1 = snd_hda_jack_detect(codec, 0x1b);
17785 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017786
17787 if (present1 || present2) {
17788 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017789 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017790 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017791 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017792 } else {
17793 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017794 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017795 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017796 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017797 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017798}
17799
Kailang Yangebb83ee2009-12-17 12:23:00 +010017800static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17801{
17802 unsigned int present1, present2;
17803
17804 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17805 AC_VERB_GET_PIN_SENSE, 0)
17806 & AC_PINSENSE_PRESENCE;
17807 present2 = snd_hda_codec_read(codec, 0x21, 0,
17808 AC_VERB_GET_PIN_SENSE, 0)
17809 & AC_PINSENSE_PRESENCE;
17810
17811 if (present1 || present2) {
17812 snd_hda_codec_write_cache(codec, 0x14, 0,
17813 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17814 snd_hda_codec_write_cache(codec, 0x17, 0,
17815 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17816 } else {
17817 snd_hda_codec_write_cache(codec, 0x14, 0,
17818 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17819 snd_hda_codec_write_cache(codec, 0x17, 0,
17820 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17821 }
17822}
17823
17824static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17825{
17826 unsigned int present1, present2;
17827
17828 present1 = snd_hda_codec_read(codec, 0x21, 0,
17829 AC_VERB_GET_PIN_SENSE, 0)
17830 & AC_PINSENSE_PRESENCE;
17831 present2 = snd_hda_codec_read(codec, 0x15, 0,
17832 AC_VERB_GET_PIN_SENSE, 0)
17833 & AC_PINSENSE_PRESENCE;
17834
17835 if (present1 || present2) {
17836 snd_hda_codec_write_cache(codec, 0x14, 0,
17837 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17838 snd_hda_codec_write_cache(codec, 0x17, 0,
17839 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17840 } else {
17841 snd_hda_codec_write_cache(codec, 0x14, 0,
17842 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17843 snd_hda_codec_write_cache(codec, 0x17, 0,
17844 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17845 }
17846}
17847
Kailang Yang6dda9f42008-05-27 12:05:31 +020017848static void alc663_m51va_unsol_event(struct hda_codec *codec,
17849 unsigned int res)
17850{
17851 switch (res >> 26) {
17852 case ALC880_HP_EVENT:
17853 alc663_m51va_speaker_automute(codec);
17854 break;
17855 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017856 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017857 break;
17858 }
17859}
17860
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017861static void alc663_m51va_setup(struct hda_codec *codec)
17862{
17863 struct alc_spec *spec = codec->spec;
17864 spec->ext_mic.pin = 0x18;
17865 spec->ext_mic.mux_idx = 0;
17866 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017867 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017868 spec->auto_mic = 1;
17869}
17870
Kailang Yang6dda9f42008-05-27 12:05:31 +020017871static void alc663_m51va_inithook(struct hda_codec *codec)
17872{
17873 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017874 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017875}
17876
Kailang Yangf1d4e282008-08-26 14:03:29 +020017877/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017878#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017879
17880static void alc663_mode1_setup(struct hda_codec *codec)
17881{
17882 struct alc_spec *spec = codec->spec;
17883 spec->ext_mic.pin = 0x18;
17884 spec->ext_mic.mux_idx = 0;
17885 spec->int_mic.pin = 0x19;
17886 spec->int_mic.mux_idx = 1;
17887 spec->auto_mic = 1;
17888}
17889
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017890#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017891
Kailang Yangf1d4e282008-08-26 14:03:29 +020017892/* ***************** Mode2 ******************************/
17893static void alc662_mode2_unsol_event(struct hda_codec *codec,
17894 unsigned int res)
17895{
17896 switch (res >> 26) {
17897 case ALC880_HP_EVENT:
17898 alc662_f5z_speaker_automute(codec);
17899 break;
17900 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017901 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017902 break;
17903 }
17904}
17905
Kailang Yangebb83ee2009-12-17 12:23:00 +010017906#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017907
Kailang Yangf1d4e282008-08-26 14:03:29 +020017908static void alc662_mode2_inithook(struct hda_codec *codec)
17909{
17910 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017911 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017912}
17913/* ***************** Mode3 ******************************/
17914static void alc663_mode3_unsol_event(struct hda_codec *codec,
17915 unsigned int res)
17916{
17917 switch (res >> 26) {
17918 case ALC880_HP_EVENT:
17919 alc663_two_hp_m1_speaker_automute(codec);
17920 break;
17921 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017922 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017923 break;
17924 }
17925}
17926
Kailang Yangebb83ee2009-12-17 12:23:00 +010017927#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017928
Kailang Yangf1d4e282008-08-26 14:03:29 +020017929static void alc663_mode3_inithook(struct hda_codec *codec)
17930{
17931 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017932 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017933}
17934/* ***************** Mode4 ******************************/
17935static void alc663_mode4_unsol_event(struct hda_codec *codec,
17936 unsigned int res)
17937{
17938 switch (res >> 26) {
17939 case ALC880_HP_EVENT:
17940 alc663_21jd_two_speaker_automute(codec);
17941 break;
17942 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017943 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017944 break;
17945 }
17946}
17947
Kailang Yangebb83ee2009-12-17 12:23:00 +010017948#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017949
Kailang Yangf1d4e282008-08-26 14:03:29 +020017950static void alc663_mode4_inithook(struct hda_codec *codec)
17951{
17952 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017953 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017954}
17955/* ***************** Mode5 ******************************/
17956static void alc663_mode5_unsol_event(struct hda_codec *codec,
17957 unsigned int res)
17958{
17959 switch (res >> 26) {
17960 case ALC880_HP_EVENT:
17961 alc663_15jd_two_speaker_automute(codec);
17962 break;
17963 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017964 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017965 break;
17966 }
17967}
17968
Kailang Yangebb83ee2009-12-17 12:23:00 +010017969#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017970
Kailang Yangf1d4e282008-08-26 14:03:29 +020017971static void alc663_mode5_inithook(struct hda_codec *codec)
17972{
17973 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017974 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017975}
17976/* ***************** Mode6 ******************************/
17977static void alc663_mode6_unsol_event(struct hda_codec *codec,
17978 unsigned int res)
17979{
17980 switch (res >> 26) {
17981 case ALC880_HP_EVENT:
17982 alc663_two_hp_m2_speaker_automute(codec);
17983 break;
17984 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017985 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017986 break;
17987 }
17988}
17989
Kailang Yangebb83ee2009-12-17 12:23:00 +010017990#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017991
Kailang Yangf1d4e282008-08-26 14:03:29 +020017992static void alc663_mode6_inithook(struct hda_codec *codec)
17993{
17994 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017995 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017996}
17997
Kailang Yangebb83ee2009-12-17 12:23:00 +010017998/* ***************** Mode7 ******************************/
17999static void alc663_mode7_unsol_event(struct hda_codec *codec,
18000 unsigned int res)
18001{
18002 switch (res >> 26) {
18003 case ALC880_HP_EVENT:
18004 alc663_two_hp_m7_speaker_automute(codec);
18005 break;
18006 case ALC880_MIC_EVENT:
18007 alc_mic_automute(codec);
18008 break;
18009 }
18010}
18011
18012#define alc663_mode7_setup alc663_mode1_setup
18013
18014static void alc663_mode7_inithook(struct hda_codec *codec)
18015{
18016 alc663_two_hp_m7_speaker_automute(codec);
18017 alc_mic_automute(codec);
18018}
18019
18020/* ***************** Mode8 ******************************/
18021static void alc663_mode8_unsol_event(struct hda_codec *codec,
18022 unsigned int res)
18023{
18024 switch (res >> 26) {
18025 case ALC880_HP_EVENT:
18026 alc663_two_hp_m8_speaker_automute(codec);
18027 break;
18028 case ALC880_MIC_EVENT:
18029 alc_mic_automute(codec);
18030 break;
18031 }
18032}
18033
18034#define alc663_mode8_setup alc663_m51va_setup
18035
18036static void alc663_mode8_inithook(struct hda_codec *codec)
18037{
18038 alc663_two_hp_m8_speaker_automute(codec);
18039 alc_mic_automute(codec);
18040}
18041
Kailang Yang6dda9f42008-05-27 12:05:31 +020018042static void alc663_g71v_hp_automute(struct hda_codec *codec)
18043{
18044 unsigned int present;
18045 unsigned char bits;
18046
Wu Fengguang864f92b2009-11-18 12:38:02 +080018047 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018048 bits = present ? HDA_AMP_MUTE : 0;
18049 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18050 HDA_AMP_MUTE, bits);
18051 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18052 HDA_AMP_MUTE, bits);
18053}
18054
18055static void alc663_g71v_front_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, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018061 bits = present ? HDA_AMP_MUTE : 0;
18062 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18063 HDA_AMP_MUTE, bits);
18064}
18065
18066static void alc663_g71v_unsol_event(struct hda_codec *codec,
18067 unsigned int res)
18068{
18069 switch (res >> 26) {
18070 case ALC880_HP_EVENT:
18071 alc663_g71v_hp_automute(codec);
18072 break;
18073 case ALC880_FRONT_EVENT:
18074 alc663_g71v_front_automute(codec);
18075 break;
18076 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018077 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018078 break;
18079 }
18080}
18081
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018082#define alc663_g71v_setup alc663_m51va_setup
18083
Kailang Yang6dda9f42008-05-27 12:05:31 +020018084static void alc663_g71v_inithook(struct hda_codec *codec)
18085{
18086 alc663_g71v_front_automute(codec);
18087 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018088 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018089}
18090
18091static void alc663_g50v_unsol_event(struct hda_codec *codec,
18092 unsigned int res)
18093{
18094 switch (res >> 26) {
18095 case ALC880_HP_EVENT:
18096 alc663_m51va_speaker_automute(codec);
18097 break;
18098 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018099 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018100 break;
18101 }
18102}
18103
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018104#define alc663_g50v_setup alc663_m51va_setup
18105
Kailang Yang6dda9f42008-05-27 12:05:31 +020018106static void alc663_g50v_inithook(struct hda_codec *codec)
18107{
18108 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018109 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018110}
18111
Kailang Yangf1d4e282008-08-26 14:03:29 +020018112static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18113 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018114 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018115
18116 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18117 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18118 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18119
18120 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18121 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18122 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18123 { } /* end */
18124};
18125
Chris Pockelé9541ba12009-05-12 08:08:53 +020018126static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18127 /* Master Playback automatically created from Speaker and Headphone */
18128 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18129 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18130 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18132
18133 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18134 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18135 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18136
18137 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18138 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18139 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18140 { } /* end */
18141};
18142
Takashi Iwaicb53c622007-08-10 17:21:45 +020018143#ifdef CONFIG_SND_HDA_POWER_SAVE
18144#define alc662_loopbacks alc880_loopbacks
18145#endif
18146
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018147
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018148/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018149#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18150#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18151#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18152#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18153
18154/*
18155 * configuration and preset
18156 */
18157static const char *alc662_models[ALC662_MODEL_LAST] = {
18158 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18159 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18160 [ALC662_3ST_6ch] = "3stack-6ch",
18161 [ALC662_5ST_DIG] = "6stack-dig",
18162 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018163 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018164 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018165 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018166 [ALC663_ASUS_M51VA] = "m51va",
18167 [ALC663_ASUS_G71V] = "g71v",
18168 [ALC663_ASUS_H13] = "h13",
18169 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018170 [ALC663_ASUS_MODE1] = "asus-mode1",
18171 [ALC662_ASUS_MODE2] = "asus-mode2",
18172 [ALC663_ASUS_MODE3] = "asus-mode3",
18173 [ALC663_ASUS_MODE4] = "asus-mode4",
18174 [ALC663_ASUS_MODE5] = "asus-mode5",
18175 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018176 [ALC663_ASUS_MODE7] = "asus-mode7",
18177 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018178 [ALC272_DELL] = "dell",
18179 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018180 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018181 [ALC662_AUTO] = "auto",
18182};
18183
18184static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018185 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018186 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18187 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018188 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18189 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018190 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018191 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18192 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18193 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18194 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018195 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18196 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018197 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018198 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18199 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18200 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18201 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18202 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018203 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018204 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18205 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018206 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18207 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18208 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18209 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018210 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018211 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18212 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18213 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018214 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18215 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18216 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18217 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018218 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018219 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18220 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018221 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018222 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18223 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18224 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018225 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018226 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018227 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18228 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018229 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18230 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18231 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018232 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018233 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18234 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018235 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018236 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018237 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018238 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18239 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18240 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018241 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018242 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18243 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018244 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018245 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018246 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018247 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018248 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18249 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018250 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018251 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018252 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18253 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018254 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018255 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018256 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018257 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018258 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018259 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018260 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18261 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018262 {}
18263};
18264
18265static struct alc_config_preset alc662_presets[] = {
18266 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018267 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018268 .init_verbs = { alc662_init_verbs },
18269 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18270 .dac_nids = alc662_dac_nids,
18271 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018272 .dig_in_nid = ALC662_DIGIN_NID,
18273 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18274 .channel_mode = alc662_3ST_2ch_modes,
18275 .input_mux = &alc662_capture_source,
18276 },
18277 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018278 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018279 .init_verbs = { alc662_init_verbs },
18280 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18281 .dac_nids = alc662_dac_nids,
18282 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018283 .dig_in_nid = ALC662_DIGIN_NID,
18284 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18285 .channel_mode = alc662_3ST_6ch_modes,
18286 .need_dac_fix = 1,
18287 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018288 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018289 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018290 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018291 .init_verbs = { alc662_init_verbs },
18292 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18293 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018294 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18295 .channel_mode = alc662_3ST_6ch_modes,
18296 .need_dac_fix = 1,
18297 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018298 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018299 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018300 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018301 .init_verbs = { alc662_init_verbs },
18302 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18303 .dac_nids = alc662_dac_nids,
18304 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018305 .dig_in_nid = ALC662_DIGIN_NID,
18306 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18307 .channel_mode = alc662_5stack_modes,
18308 .input_mux = &alc662_capture_source,
18309 },
18310 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018311 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018312 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18313 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18314 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018315 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18316 .channel_mode = alc662_3ST_2ch_modes,
18317 .input_mux = &alc662_lenovo_101e_capture_source,
18318 .unsol_event = alc662_lenovo_101e_unsol_event,
18319 .init_hook = alc662_lenovo_101e_all_automute,
18320 },
Kailang Yang291702f2007-10-16 14:28:03 +020018321 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018322 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018323 .init_verbs = { alc662_init_verbs,
18324 alc662_eeepc_sue_init_verbs },
18325 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18326 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018327 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18328 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018329 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018330 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018331 .init_hook = alc662_eeepc_inithook,
18332 },
Kailang Yang8c427222008-01-10 13:03:59 +010018333 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018334 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018335 alc662_chmode_mixer },
18336 .init_verbs = { alc662_init_verbs,
18337 alc662_eeepc_ep20_sue_init_verbs },
18338 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18339 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018340 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18341 .channel_mode = alc662_3ST_6ch_modes,
18342 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018343 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018344 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018345 .init_hook = alc662_eeepc_ep20_inithook,
18346 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018347 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018348 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018349 .init_verbs = { alc662_init_verbs,
18350 alc662_ecs_init_verbs },
18351 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18352 .dac_nids = alc662_dac_nids,
18353 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18354 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018355 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018356 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018357 .init_hook = alc662_eeepc_inithook,
18358 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018359 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018360 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018361 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18362 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18363 .dac_nids = alc662_dac_nids,
18364 .dig_out_nid = ALC662_DIGOUT_NID,
18365 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18366 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018367 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018368 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018369 .init_hook = alc663_m51va_inithook,
18370 },
18371 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018372 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018373 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18374 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18375 .dac_nids = alc662_dac_nids,
18376 .dig_out_nid = ALC662_DIGOUT_NID,
18377 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18378 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018379 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018381 .init_hook = alc663_g71v_inithook,
18382 },
18383 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018384 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018385 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18386 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18387 .dac_nids = alc662_dac_nids,
18388 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18389 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018390 .unsol_event = alc663_m51va_unsol_event,
18391 .init_hook = alc663_m51va_inithook,
18392 },
18393 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018394 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018395 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18396 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18397 .dac_nids = alc662_dac_nids,
18398 .dig_out_nid = ALC662_DIGOUT_NID,
18399 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18400 .channel_mode = alc662_3ST_6ch_modes,
18401 .input_mux = &alc663_capture_source,
18402 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018403 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018404 .init_hook = alc663_g50v_inithook,
18405 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018406 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018407 .mixers = { alc663_m51va_mixer },
18408 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018409 .init_verbs = { alc662_init_verbs,
18410 alc663_21jd_amic_init_verbs },
18411 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18412 .hp_nid = 0x03,
18413 .dac_nids = alc662_dac_nids,
18414 .dig_out_nid = ALC662_DIGOUT_NID,
18415 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18416 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018417 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018418 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018419 .init_hook = alc663_mode1_inithook,
18420 },
18421 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018422 .mixers = { alc662_1bjd_mixer },
18423 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018424 .init_verbs = { alc662_init_verbs,
18425 alc662_1bjd_amic_init_verbs },
18426 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18427 .dac_nids = alc662_dac_nids,
18428 .dig_out_nid = ALC662_DIGOUT_NID,
18429 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18430 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018431 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018432 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018433 .init_hook = alc662_mode2_inithook,
18434 },
18435 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018436 .mixers = { alc663_two_hp_m1_mixer },
18437 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018438 .init_verbs = { alc662_init_verbs,
18439 alc663_two_hp_amic_m1_init_verbs },
18440 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18441 .hp_nid = 0x03,
18442 .dac_nids = alc662_dac_nids,
18443 .dig_out_nid = ALC662_DIGOUT_NID,
18444 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18445 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018446 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018447 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018448 .init_hook = alc663_mode3_inithook,
18449 },
18450 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018451 .mixers = { alc663_asus_21jd_clfe_mixer },
18452 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018453 .init_verbs = { alc662_init_verbs,
18454 alc663_21jd_amic_init_verbs},
18455 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18456 .hp_nid = 0x03,
18457 .dac_nids = alc662_dac_nids,
18458 .dig_out_nid = ALC662_DIGOUT_NID,
18459 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18460 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018461 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018462 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018463 .init_hook = alc663_mode4_inithook,
18464 },
18465 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018466 .mixers = { alc663_asus_15jd_clfe_mixer },
18467 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018468 .init_verbs = { alc662_init_verbs,
18469 alc663_15jd_amic_init_verbs },
18470 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18471 .hp_nid = 0x03,
18472 .dac_nids = alc662_dac_nids,
18473 .dig_out_nid = ALC662_DIGOUT_NID,
18474 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18475 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018476 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018478 .init_hook = alc663_mode5_inithook,
18479 },
18480 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018481 .mixers = { alc663_two_hp_m2_mixer },
18482 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018483 .init_verbs = { alc662_init_verbs,
18484 alc663_two_hp_amic_m2_init_verbs },
18485 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18486 .hp_nid = 0x03,
18487 .dac_nids = alc662_dac_nids,
18488 .dig_out_nid = ALC662_DIGOUT_NID,
18489 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18490 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018491 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018492 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018493 .init_hook = alc663_mode6_inithook,
18494 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018495 [ALC663_ASUS_MODE7] = {
18496 .mixers = { alc663_mode7_mixer },
18497 .cap_mixer = alc662_auto_capture_mixer,
18498 .init_verbs = { alc662_init_verbs,
18499 alc663_mode7_init_verbs },
18500 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18501 .hp_nid = 0x03,
18502 .dac_nids = alc662_dac_nids,
18503 .dig_out_nid = ALC662_DIGOUT_NID,
18504 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18505 .channel_mode = alc662_3ST_2ch_modes,
18506 .unsol_event = alc663_mode7_unsol_event,
18507 .setup = alc663_mode7_setup,
18508 .init_hook = alc663_mode7_inithook,
18509 },
18510 [ALC663_ASUS_MODE8] = {
18511 .mixers = { alc663_mode8_mixer },
18512 .cap_mixer = alc662_auto_capture_mixer,
18513 .init_verbs = { alc662_init_verbs,
18514 alc663_mode8_init_verbs },
18515 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18516 .hp_nid = 0x03,
18517 .dac_nids = alc662_dac_nids,
18518 .dig_out_nid = ALC662_DIGOUT_NID,
18519 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18520 .channel_mode = alc662_3ST_2ch_modes,
18521 .unsol_event = alc663_mode8_unsol_event,
18522 .setup = alc663_mode8_setup,
18523 .init_hook = alc663_mode8_inithook,
18524 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018525 [ALC272_DELL] = {
18526 .mixers = { alc663_m51va_mixer },
18527 .cap_mixer = alc272_auto_capture_mixer,
18528 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18529 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18530 .dac_nids = alc662_dac_nids,
18531 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18532 .adc_nids = alc272_adc_nids,
18533 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18534 .capsrc_nids = alc272_capsrc_nids,
18535 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018536 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018537 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018538 .init_hook = alc663_m51va_inithook,
18539 },
18540 [ALC272_DELL_ZM1] = {
18541 .mixers = { alc663_m51va_mixer },
18542 .cap_mixer = alc662_auto_capture_mixer,
18543 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18544 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18545 .dac_nids = alc662_dac_nids,
18546 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18547 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018548 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018549 .capsrc_nids = alc662_capsrc_nids,
18550 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018551 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018552 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018553 .init_hook = alc663_m51va_inithook,
18554 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018555 [ALC272_SAMSUNG_NC10] = {
18556 .mixers = { alc272_nc10_mixer },
18557 .init_verbs = { alc662_init_verbs,
18558 alc663_21jd_amic_init_verbs },
18559 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18560 .dac_nids = alc272_dac_nids,
18561 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18562 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018563 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018564 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018565 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018566 .init_hook = alc663_mode4_inithook,
18567 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018568};
18569
18570
18571/*
18572 * BIOS auto configuration
18573 */
18574
Takashi Iwai7085ec12009-10-02 09:03:58 +020018575/* convert from MIX nid to DAC */
18576static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18577{
18578 if (nid == 0x0f)
18579 return 0x02;
18580 else if (nid >= 0x0c && nid <= 0x0e)
18581 return nid - 0x0c + 0x02;
18582 else
18583 return 0;
18584}
18585
18586/* get MIX nid connected to the given pin targeted to DAC */
18587static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18588 hda_nid_t dac)
18589{
18590 hda_nid_t mix[4];
18591 int i, num;
18592
18593 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18594 for (i = 0; i < num; i++) {
18595 if (alc662_mix_to_dac(mix[i]) == dac)
18596 return mix[i];
18597 }
18598 return 0;
18599}
18600
18601/* look for an empty DAC slot */
18602static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18603{
18604 struct alc_spec *spec = codec->spec;
18605 hda_nid_t srcs[5];
18606 int i, j, num;
18607
18608 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18609 if (num < 0)
18610 return 0;
18611 for (i = 0; i < num; i++) {
18612 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18613 if (!nid)
18614 continue;
18615 for (j = 0; j < spec->multiout.num_dacs; j++)
18616 if (spec->multiout.dac_nids[j] == nid)
18617 break;
18618 if (j >= spec->multiout.num_dacs)
18619 return nid;
18620 }
18621 return 0;
18622}
18623
18624/* fill in the dac_nids table from the parsed pin configuration */
18625static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18626 const struct auto_pin_cfg *cfg)
18627{
18628 struct alc_spec *spec = codec->spec;
18629 int i;
18630 hda_nid_t dac;
18631
18632 spec->multiout.dac_nids = spec->private_dac_nids;
18633 for (i = 0; i < cfg->line_outs; i++) {
18634 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18635 if (!dac)
18636 continue;
18637 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18638 }
18639 return 0;
18640}
18641
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018642static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018643 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018644{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018645 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018646 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18647}
18648
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018649static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018650 hda_nid_t nid, unsigned int chs)
18651{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018652 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018653 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18654}
18655
18656#define alc662_add_stereo_vol(spec, pfx, nid) \
18657 alc662_add_vol_ctl(spec, pfx, nid, 3)
18658#define alc662_add_stereo_sw(spec, pfx, nid) \
18659 alc662_add_sw_ctl(spec, pfx, nid, 3)
18660
18661/* add playback controls from the parsed DAC table */
18662static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18663 const struct auto_pin_cfg *cfg)
18664{
18665 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018666 static const char *chname[4] = {
18667 "Front", "Surround", NULL /*CLFE*/, "Side"
18668 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018669 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018670 int i, err;
18671
18672 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018673 nid = spec->multiout.dac_nids[i];
18674 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018675 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018676 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18677 if (!mix)
18678 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018679 if (i == 2) {
18680 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018681 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018682 if (err < 0)
18683 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018684 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018685 if (err < 0)
18686 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018687 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018688 if (err < 0)
18689 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018690 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018691 if (err < 0)
18692 return err;
18693 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018694 const char *pfx;
18695 if (cfg->line_outs == 1 &&
18696 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018697 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018698 pfx = "Speaker";
18699 else
18700 pfx = "PCM";
18701 } else
18702 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018703 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704 if (err < 0)
18705 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018706 if (cfg->line_outs == 1 &&
18707 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18708 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018709 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018710 if (err < 0)
18711 return err;
18712 }
18713 }
18714 return 0;
18715}
18716
18717/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018718/* return DAC nid if any new DAC is assigned */
18719static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018720 const char *pfx)
18721{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018722 struct alc_spec *spec = codec->spec;
18723 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018724 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018725
18726 if (!pin)
18727 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018728 nid = alc662_look_for_dac(codec, pin);
18729 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018730 /* the corresponding DAC is already occupied */
18731 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18732 return 0; /* no way */
18733 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018734 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018735 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18736 }
18737
18738 mix = alc662_dac_to_mix(codec, pin, nid);
18739 if (!mix)
18740 return 0;
18741 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18742 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018743 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018744 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18745 if (err < 0)
18746 return err;
18747 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018748}
18749
18750/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018751#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018752 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018753
18754static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18755 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018756 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018757{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018758 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020018759 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018760
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018761 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018762 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018763 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18764 if (num <= 1)
18765 return;
18766 for (i = 0; i < num; i++) {
18767 if (alc662_mix_to_dac(srcs[i]) != dac)
18768 continue;
18769 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18770 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018771 }
18772}
18773
18774static void alc662_auto_init_multi_out(struct hda_codec *codec)
18775{
18776 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018777 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018778 int i;
18779
18780 for (i = 0; i <= HDA_SIDE; i++) {
18781 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18782 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018783 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018784 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018785 }
18786}
18787
18788static void alc662_auto_init_hp_out(struct hda_codec *codec)
18789{
18790 struct alc_spec *spec = codec->spec;
18791 hda_nid_t pin;
18792
18793 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018794 if (pin)
18795 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18796 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018797 pin = spec->autocfg.speaker_pins[0];
18798 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018799 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18800 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018801}
18802
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018803#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18804
18805static void alc662_auto_init_analog_input(struct hda_codec *codec)
18806{
18807 struct alc_spec *spec = codec->spec;
18808 int i;
18809
18810 for (i = 0; i < AUTO_PIN_LAST; i++) {
18811 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018812 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018813 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018814 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018815 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018816 snd_hda_codec_write(codec, nid, 0,
18817 AC_VERB_SET_AMP_GAIN_MUTE,
18818 AMP_OUT_MUTE);
18819 }
18820 }
18821}
18822
Takashi Iwaif511b012008-08-15 16:46:42 +020018823#define alc662_auto_init_input_src alc882_auto_init_input_src
18824
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018825static int alc662_parse_auto_config(struct hda_codec *codec)
18826{
18827 struct alc_spec *spec = codec->spec;
18828 int err;
18829 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18830
18831 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18832 alc662_ignore);
18833 if (err < 0)
18834 return err;
18835 if (!spec->autocfg.line_outs)
18836 return 0; /* can't find valid BIOS pin config */
18837
Takashi Iwai7085ec12009-10-02 09:03:58 +020018838 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018839 if (err < 0)
18840 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018841 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018842 if (err < 0)
18843 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018844 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018845 spec->autocfg.speaker_pins[0],
18846 "Speaker");
18847 if (err < 0)
18848 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018849 if (err)
18850 spec->multiout.extra_out_nid[0] = err;
18851 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018852 "Headphone");
18853 if (err < 0)
18854 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018855 if (err)
18856 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018857 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018858 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018859 return err;
18860
18861 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18862
Takashi Iwai757899a2010-07-30 10:48:14 +020018863 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018864
Takashi Iwai603c4012008-07-30 15:01:44 +020018865 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018866 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018867
18868 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018869 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018870
Kailang Yangcec27c82010-02-04 14:18:18 +010018871 add_verb(spec, alc662_init_verbs);
18872 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020018873 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010018874 add_verb(spec, alc663_init_verbs);
18875
18876 if (codec->vendor_id == 0x10ec0272)
18877 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018878
18879 err = alc_auto_add_mic_boost(codec);
18880 if (err < 0)
18881 return err;
18882
Kailang Yang6227cdc2010-02-25 08:36:52 +010018883 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18884 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18885 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18886 else
18887 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018888
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018889 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018890}
18891
18892/* additional initialization for auto-configuration model */
18893static void alc662_auto_init(struct hda_codec *codec)
18894{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018895 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018896 alc662_auto_init_multi_out(codec);
18897 alc662_auto_init_hp_out(codec);
18898 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018899 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020018900 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018901 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018902 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018903}
18904
18905static int patch_alc662(struct hda_codec *codec)
18906{
18907 struct alc_spec *spec;
18908 int err, board_config;
18909
18910 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18911 if (!spec)
18912 return -ENOMEM;
18913
18914 codec->spec = spec;
18915
Kailang Yangda00c242010-03-19 11:23:45 +010018916 alc_auto_parse_customize_define(codec);
18917
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018918 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18919
Kailang Yangc027ddc2010-03-19 11:33:06 +010018920 if (alc_read_coef_idx(codec, 0) == 0x8020)
18921 alc_codec_rename(codec, "ALC661");
18922 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18923 codec->bus->pci->subsystem_vendor == 0x1025 &&
18924 spec->cdefine.platform_type == 1)
18925 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018926
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018927 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18928 alc662_models,
18929 alc662_cfg_tbl);
18930 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018931 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18932 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018933 board_config = ALC662_AUTO;
18934 }
18935
18936 if (board_config == ALC662_AUTO) {
18937 /* automatic parse from the BIOS config */
18938 err = alc662_parse_auto_config(codec);
18939 if (err < 0) {
18940 alc_free(codec);
18941 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018942 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018943 printk(KERN_INFO
18944 "hda_codec: Cannot set up configuration "
18945 "from BIOS. Using base mode...\n");
18946 board_config = ALC662_3ST_2ch_DIG;
18947 }
18948 }
18949
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018950 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020018951 err = snd_hda_attach_beep_device(codec, 0x1);
18952 if (err < 0) {
18953 alc_free(codec);
18954 return err;
18955 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018956 }
18957
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018958 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018959 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018960
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018961 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18962 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18963
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018964 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18965 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18966
Takashi Iwaidd704692009-08-11 08:45:11 +020018967 if (!spec->adc_nids) {
18968 spec->adc_nids = alc662_adc_nids;
18969 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18970 }
18971 if (!spec->capsrc_nids)
18972 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018973
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018974 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018975 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018976
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018977 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010018978 switch (codec->vendor_id) {
18979 case 0x10ec0662:
18980 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18981 break;
18982 case 0x10ec0272:
18983 case 0x10ec0663:
18984 case 0x10ec0665:
18985 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18986 break;
18987 case 0x10ec0273:
18988 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18989 break;
18990 }
Kailang Yangcec27c82010-02-04 14:18:18 +010018991 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018992 spec->vmaster_nid = 0x02;
18993
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018994 codec->patch_ops = alc_patch_ops;
18995 if (board_config == ALC662_AUTO)
18996 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018997#ifdef CONFIG_SND_HDA_POWER_SAVE
18998 if (!spec->loopback.amplist)
18999 spec->loopback.amplist = alc662_loopbacks;
19000#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019001
19002 return 0;
19003}
19004
Kailang Yang274693f2009-12-03 10:07:50 +010019005static int patch_alc888(struct hda_codec *codec)
19006{
19007 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19008 kfree(codec->chip_name);
19009 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019010 if (!codec->chip_name) {
19011 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019012 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019013 }
19014 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019015 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019016 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019017}
19018
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019019/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019020 * ALC680 support
19021 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019022#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019023#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19024#define alc680_modes alc260_modes
19025
19026static hda_nid_t alc680_dac_nids[3] = {
19027 /* Lout1, Lout2, hp */
19028 0x02, 0x03, 0x04
19029};
19030
19031static hda_nid_t alc680_adc_nids[3] = {
19032 /* ADC0-2 */
19033 /* DMIC, MIC, Line-in*/
19034 0x07, 0x08, 0x09
19035};
19036
Kailang Yangc69aefa2010-08-17 10:39:22 +020019037/*
19038 * Analog capture ADC cgange
19039 */
19040static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19041 struct hda_codec *codec,
19042 unsigned int stream_tag,
19043 unsigned int format,
19044 struct snd_pcm_substream *substream)
19045{
19046 struct alc_spec *spec = codec->spec;
19047 struct auto_pin_cfg *cfg = &spec->autocfg;
19048 unsigned int pre_mic, pre_line;
19049
19050 pre_mic = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]);
19051 pre_line = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_LINE]);
19052
19053 spec->cur_adc_stream_tag = stream_tag;
19054 spec->cur_adc_format = format;
19055
19056 if (pre_mic || pre_line) {
19057 if (pre_mic)
19058 snd_hda_codec_setup_stream(codec, 0x08, stream_tag, 0,
19059 format);
19060 else
19061 snd_hda_codec_setup_stream(codec, 0x09, stream_tag, 0,
19062 format);
19063 } else
19064 snd_hda_codec_setup_stream(codec, 0x07, stream_tag, 0, format);
19065 return 0;
19066}
19067
19068static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19069 struct hda_codec *codec,
19070 struct snd_pcm_substream *substream)
19071{
19072 snd_hda_codec_cleanup_stream(codec, 0x07);
19073 snd_hda_codec_cleanup_stream(codec, 0x08);
19074 snd_hda_codec_cleanup_stream(codec, 0x09);
19075 return 0;
19076}
19077
19078static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19079 .substreams = 1, /* can be overridden */
19080 .channels_min = 2,
19081 .channels_max = 2,
19082 /* NID is set in alc_build_pcms */
19083 .ops = {
19084 .prepare = alc680_capture_pcm_prepare,
19085 .cleanup = alc680_capture_pcm_cleanup
19086 },
19087};
19088
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019089static struct snd_kcontrol_new alc680_base_mixer[] = {
19090 /* output mixer control */
19091 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19092 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19093 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19094 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019095 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019097 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019098 { }
19099};
19100
Kailang Yangc69aefa2010-08-17 10:39:22 +020019101static struct hda_bind_ctls alc680_bind_cap_vol = {
19102 .ops = &snd_hda_bind_vol,
19103 .values = {
19104 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19105 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19106 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19107 0
19108 },
19109};
19110
19111static struct hda_bind_ctls alc680_bind_cap_switch = {
19112 .ops = &snd_hda_bind_sw,
19113 .values = {
19114 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19115 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19116 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19117 0
19118 },
19119};
19120
19121static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19122 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19123 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019124 { } /* end */
19125};
19126
19127/*
19128 * generic initialization of ADC, input mixers and output mixers
19129 */
19130static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019131 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19132 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19133 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019134
Kailang Yangc69aefa2010-08-17 10:39:22 +020019135 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19136 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19138 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19139 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19140 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019141
19142 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19143 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19144 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19146 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019147
19148 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19149 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
19150
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019151 { }
19152};
19153
Kailang Yangc69aefa2010-08-17 10:39:22 +020019154/* toggle speaker-output according to the hp-jack state */
19155static void alc680_base_setup(struct hda_codec *codec)
19156{
19157 struct alc_spec *spec = codec->spec;
19158
19159 spec->autocfg.hp_pins[0] = 0x16;
19160 spec->autocfg.speaker_pins[0] = 0x14;
19161 spec->autocfg.speaker_pins[1] = 0x15;
19162 spec->autocfg.input_pins[AUTO_PIN_MIC] = 0x18;
19163 spec->autocfg.input_pins[AUTO_PIN_LINE] = 0x19;
19164}
19165
19166static void alc680_rec_autoswitch(struct hda_codec *codec)
19167{
19168 struct alc_spec *spec = codec->spec;
19169 struct auto_pin_cfg *cfg = &spec->autocfg;
19170 unsigned int present;
19171 hda_nid_t new_adc;
19172
19173 present = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]);
19174
19175 new_adc = present ? 0x8 : 0x7;
19176 __snd_hda_codec_cleanup_stream(codec, !present ? 0x8 : 0x7, 1);
19177 snd_hda_codec_setup_stream(codec, new_adc,
19178 spec->cur_adc_stream_tag, 0,
19179 spec->cur_adc_format);
19180
19181}
19182
19183static void alc680_unsol_event(struct hda_codec *codec,
19184 unsigned int res)
19185{
19186 if ((res >> 26) == ALC880_HP_EVENT)
19187 alc_automute_amp(codec);
19188 if ((res >> 26) == ALC880_MIC_EVENT)
19189 alc680_rec_autoswitch(codec);
19190}
19191
19192static void alc680_inithook(struct hda_codec *codec)
19193{
19194 alc_automute_amp(codec);
19195 alc680_rec_autoswitch(codec);
19196}
19197
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019198/* create input playback/capture controls for the given pin */
19199static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19200 const char *ctlname, int idx)
19201{
19202 hda_nid_t dac;
19203 int err;
19204
19205 switch (nid) {
19206 case 0x14:
19207 dac = 0x02;
19208 break;
19209 case 0x15:
19210 dac = 0x03;
19211 break;
19212 case 0x16:
19213 dac = 0x04;
19214 break;
19215 default:
19216 return 0;
19217 }
19218 if (spec->multiout.dac_nids[0] != dac &&
19219 spec->multiout.dac_nids[1] != dac) {
19220 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19221 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19222 HDA_OUTPUT));
19223 if (err < 0)
19224 return err;
19225
19226 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19227 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19228
19229 if (err < 0)
19230 return err;
19231 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19232 }
19233
19234 return 0;
19235}
19236
19237/* add playback controls from the parsed DAC table */
19238static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19239 const struct auto_pin_cfg *cfg)
19240{
19241 hda_nid_t nid;
19242 int err;
19243
19244 spec->multiout.dac_nids = spec->private_dac_nids;
19245
19246 nid = cfg->line_out_pins[0];
19247 if (nid) {
19248 const char *name;
19249 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19250 name = "Speaker";
19251 else
19252 name = "Front";
19253 err = alc680_new_analog_output(spec, nid, name, 0);
19254 if (err < 0)
19255 return err;
19256 }
19257
19258 nid = cfg->speaker_pins[0];
19259 if (nid) {
19260 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19261 if (err < 0)
19262 return err;
19263 }
19264 nid = cfg->hp_pins[0];
19265 if (nid) {
19266 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19267 if (err < 0)
19268 return err;
19269 }
19270
19271 return 0;
19272}
19273
19274static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19275 hda_nid_t nid, int pin_type)
19276{
19277 alc_set_pin_output(codec, nid, pin_type);
19278}
19279
19280static void alc680_auto_init_multi_out(struct hda_codec *codec)
19281{
19282 struct alc_spec *spec = codec->spec;
19283 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19284 if (nid) {
19285 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19286 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19287 }
19288}
19289
19290static void alc680_auto_init_hp_out(struct hda_codec *codec)
19291{
19292 struct alc_spec *spec = codec->spec;
19293 hda_nid_t pin;
19294
19295 pin = spec->autocfg.hp_pins[0];
19296 if (pin)
19297 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19298 pin = spec->autocfg.speaker_pins[0];
19299 if (pin)
19300 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19301}
19302
19303/* pcm configuration: identical with ALC880 */
19304#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19305#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19306#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19307#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019308#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019309
19310/*
19311 * BIOS auto configuration
19312 */
19313static int alc680_parse_auto_config(struct hda_codec *codec)
19314{
19315 struct alc_spec *spec = codec->spec;
19316 int err;
19317 static hda_nid_t alc680_ignore[] = { 0 };
19318
19319 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19320 alc680_ignore);
19321 if (err < 0)
19322 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019323
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019324 if (!spec->autocfg.line_outs) {
19325 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19326 spec->multiout.max_channels = 2;
19327 spec->no_analog = 1;
19328 goto dig_only;
19329 }
19330 return 0; /* can't find valid BIOS pin config */
19331 }
19332 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19333 if (err < 0)
19334 return err;
19335
19336 spec->multiout.max_channels = 2;
19337
19338 dig_only:
19339 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019340 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019341 if (spec->kctls.list)
19342 add_mixer(spec, spec->kctls.list);
19343
19344 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019345
19346 err = alc_auto_add_mic_boost(codec);
19347 if (err < 0)
19348 return err;
19349
19350 return 1;
19351}
19352
19353#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19354
19355/* init callback for auto-configuration model -- overriding the default init */
19356static void alc680_auto_init(struct hda_codec *codec)
19357{
19358 struct alc_spec *spec = codec->spec;
19359 alc680_auto_init_multi_out(codec);
19360 alc680_auto_init_hp_out(codec);
19361 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019362 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019363 if (spec->unsol_event)
19364 alc_inithook(codec);
19365}
19366
19367/*
19368 * configuration and preset
19369 */
19370static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019371 [ALC680_BASE] = "base",
19372 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019373};
19374
19375static struct snd_pci_quirk alc680_cfg_tbl[] = {
19376 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19377 {}
19378};
19379
19380static struct alc_config_preset alc680_presets[] = {
19381 [ALC680_BASE] = {
19382 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019383 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019384 .init_verbs = { alc680_init_verbs },
19385 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19386 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019387 .dig_out_nid = ALC680_DIGOUT_NID,
19388 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19389 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019390 .unsol_event = alc680_unsol_event,
19391 .setup = alc680_base_setup,
19392 .init_hook = alc680_inithook,
19393
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019394 },
19395};
19396
19397static int patch_alc680(struct hda_codec *codec)
19398{
19399 struct alc_spec *spec;
19400 int board_config;
19401 int err;
19402
19403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19404 if (spec == NULL)
19405 return -ENOMEM;
19406
19407 codec->spec = spec;
19408
19409 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19410 alc680_models,
19411 alc680_cfg_tbl);
19412
19413 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19414 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19415 codec->chip_name);
19416 board_config = ALC680_AUTO;
19417 }
19418
19419 if (board_config == ALC680_AUTO) {
19420 /* automatic parse from the BIOS config */
19421 err = alc680_parse_auto_config(codec);
19422 if (err < 0) {
19423 alc_free(codec);
19424 return err;
19425 } else if (!err) {
19426 printk(KERN_INFO
19427 "hda_codec: Cannot set up configuration "
19428 "from BIOS. Using base mode...\n");
19429 board_config = ALC680_BASE;
19430 }
19431 }
19432
19433 if (board_config != ALC680_AUTO)
19434 setup_preset(codec, &alc680_presets[board_config]);
19435
19436 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019437 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019438 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019439 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019440
19441 if (!spec->adc_nids) {
19442 spec->adc_nids = alc680_adc_nids;
19443 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19444 }
19445
19446 if (!spec->cap_mixer)
19447 set_capture_mixer(codec);
19448
19449 spec->vmaster_nid = 0x02;
19450
19451 codec->patch_ops = alc_patch_ops;
19452 if (board_config == ALC680_AUTO)
19453 spec->init_hook = alc680_auto_init;
19454
19455 return 0;
19456}
19457
19458/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019459 * patch entries
19460 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019461static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019462 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019463 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019464 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019465 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019466 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019467 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019468 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019469 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019470 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019471 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019472 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19473 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19474 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019475 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019476 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019477 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19478 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019479 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019480 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019481 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019482 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019483 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019484 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019485 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019486 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019487 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019488 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019489 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019490 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019491 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019492 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019493 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019494 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019495 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019496 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019497 {} /* terminator */
19498};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019499
19500MODULE_ALIAS("snd-hda-codec-id:10ec*");
19501
19502MODULE_LICENSE("GPL");
19503MODULE_DESCRIPTION("Realtek HD-audio codec");
19504
19505static struct hda_codec_preset_list realtek_list = {
19506 .preset = snd_hda_preset_realtek,
19507 .owner = THIS_MODULE,
19508};
19509
19510static int __init patch_realtek_init(void)
19511{
19512 return snd_hda_add_codec_preset(&realtek_list);
19513}
19514
19515static void __exit patch_realtek_exit(void)
19516{
19517 snd_hda_delete_codec_preset(&realtek_list);
19518}
19519
19520module_init(patch_realtek_init)
19521module_exit(patch_realtek_exit)