blob: 26069e397fc92df5141e03526359d7b52298f04e [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 Iwaibb35feb2010-09-08 15:30:49 +0200993static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +0200994{
995 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +0200996 unsigned int mute;
997 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200998 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200999
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001000 spec->jack_present = 0;
1001 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1002 nid = spec->autocfg.hp_pins[i];
1003 if (!nid)
1004 break;
1005 if (snd_hda_jack_detect(codec, nid)) {
1006 spec->jack_present = 1;
1007 break;
1008 }
1009 }
1010
1011 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1012 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001013 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1014 nid = spec->autocfg.speaker_pins[i];
1015 if (!nid)
1016 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001017 if (pinctl) {
1018 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001019 AC_VERB_SET_PIN_WIDGET_CONTROL,
1020 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001021 } else {
1022 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1023 HDA_AMP_MUTE, mute);
1024 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001025 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001026}
1027
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001028static void alc_automute_pin(struct hda_codec *codec)
1029{
1030 alc_automute_speaker(codec, 1);
1031}
1032
Takashi Iwai6c819492009-08-10 18:47:44 +02001033static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1034 hda_nid_t nid)
1035{
1036 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1037 int i, nums;
1038
1039 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1040 for (i = 0; i < nums; i++)
1041 if (conn[i] == nid)
1042 return i;
1043 return -1;
1044}
1045
Takashi Iwai840b64c2010-07-13 22:49:01 +02001046/* switch the current ADC according to the jack state */
1047static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1048{
1049 struct alc_spec *spec = codec->spec;
1050 unsigned int present;
1051 hda_nid_t new_adc;
1052
1053 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1054 if (present)
1055 spec->cur_adc_idx = 1;
1056 else
1057 spec->cur_adc_idx = 0;
1058 new_adc = spec->adc_nids[spec->cur_adc_idx];
1059 if (spec->cur_adc && spec->cur_adc != new_adc) {
1060 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001061 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001062 spec->cur_adc = new_adc;
1063 snd_hda_codec_setup_stream(codec, new_adc,
1064 spec->cur_adc_stream_tag, 0,
1065 spec->cur_adc_format);
1066 }
1067}
1068
Kailang Yang7fb0d782008-10-15 11:12:35 +02001069static void alc_mic_automute(struct hda_codec *codec)
1070{
1071 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001072 struct alc_mic_route *dead, *alive;
1073 unsigned int present, type;
1074 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001075
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001076 if (!spec->auto_mic)
1077 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001078 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1079 return;
1080 if (snd_BUG_ON(!spec->adc_nids))
1081 return;
1082
Takashi Iwai840b64c2010-07-13 22:49:01 +02001083 if (spec->dual_adc_switch) {
1084 alc_dual_mic_adc_auto_switch(codec);
1085 return;
1086 }
1087
Takashi Iwai6c819492009-08-10 18:47:44 +02001088 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1089
Wu Fengguang864f92b2009-11-18 12:38:02 +08001090 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001091 if (present) {
1092 alive = &spec->ext_mic;
1093 dead = &spec->int_mic;
1094 } else {
1095 alive = &spec->int_mic;
1096 dead = &spec->ext_mic;
1097 }
1098
Takashi Iwai6c819492009-08-10 18:47:44 +02001099 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1100 if (type == AC_WID_AUD_MIX) {
1101 /* Matrix-mixer style (e.g. ALC882) */
1102 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1103 alive->mux_idx,
1104 HDA_AMP_MUTE, 0);
1105 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1106 dead->mux_idx,
1107 HDA_AMP_MUTE, HDA_AMP_MUTE);
1108 } else {
1109 /* MUX style (e.g. ALC880) */
1110 snd_hda_codec_write_cache(codec, cap_nid, 0,
1111 AC_VERB_SET_CONNECT_SEL,
1112 alive->mux_idx);
1113 }
1114
1115 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001116}
1117
Kailang Yangc9b58002007-10-16 14:30:01 +02001118/* unsolicited event for HP jack sensing */
1119static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1120{
1121 if (codec->vendor_id == 0x10ec0880)
1122 res >>= 28;
1123 else
1124 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001125 switch (res) {
1126 case ALC880_HP_EVENT:
1127 alc_automute_pin(codec);
1128 break;
1129 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001130 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001131 break;
1132 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001133}
1134
1135static void alc_inithook(struct hda_codec *codec)
1136{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001137 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001138 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001139}
1140
Kailang Yangf9423e72008-05-27 12:32:25 +02001141/* additional initialization for ALC888 variants */
1142static void alc888_coef_init(struct hda_codec *codec)
1143{
1144 unsigned int tmp;
1145
1146 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1147 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1148 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001149 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001150 /* alc888S-VC */
1151 snd_hda_codec_read(codec, 0x20, 0,
1152 AC_VERB_SET_PROC_COEF, 0x830);
1153 else
1154 /* alc888-VB */
1155 snd_hda_codec_read(codec, 0x20, 0,
1156 AC_VERB_SET_PROC_COEF, 0x3030);
1157}
1158
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001159static void alc889_coef_init(struct hda_codec *codec)
1160{
1161 unsigned int tmp;
1162
1163 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1164 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1165 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1166 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1167}
1168
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001169/* turn on/off EAPD control (only if available) */
1170static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1171{
1172 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1173 return;
1174 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1175 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1176 on ? 2 : 0);
1177}
1178
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001179static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001180{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001182
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001183 switch (type) {
1184 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001185 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1186 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001187 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001188 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1189 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001190 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001191 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1192 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001194 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001195 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001196 set_eapd(codec, 0x0f, 1);
1197 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001198 break;
1199 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001200 case 0x10ec0267:
1201 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001202 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001203 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001204 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001205 case 0x10ec0660:
1206 case 0x10ec0662:
1207 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001208 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001209 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001210 set_eapd(codec, 0x14, 1);
1211 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001212 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001213 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001214 switch (codec->vendor_id) {
1215 case 0x10ec0260:
1216 snd_hda_codec_write(codec, 0x1a, 0,
1217 AC_VERB_SET_COEF_INDEX, 7);
1218 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1219 AC_VERB_GET_PROC_COEF, 0);
1220 snd_hda_codec_write(codec, 0x1a, 0,
1221 AC_VERB_SET_COEF_INDEX, 7);
1222 snd_hda_codec_write(codec, 0x1a, 0,
1223 AC_VERB_SET_PROC_COEF,
1224 tmp | 0x2010);
1225 break;
1226 case 0x10ec0262:
1227 case 0x10ec0880:
1228 case 0x10ec0882:
1229 case 0x10ec0883:
1230 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001231 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001232 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001233 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001234 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001235 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001236 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001237 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001238#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001239 case 0x10ec0267:
1240 case 0x10ec0268:
1241 snd_hda_codec_write(codec, 0x20, 0,
1242 AC_VERB_SET_COEF_INDEX, 7);
1243 tmp = snd_hda_codec_read(codec, 0x20, 0,
1244 AC_VERB_GET_PROC_COEF, 0);
1245 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001246 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001247 snd_hda_codec_write(codec, 0x20, 0,
1248 AC_VERB_SET_PROC_COEF,
1249 tmp | 0x3000);
1250 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001251#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001252 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001253 break;
1254 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001255}
Kailang Yangea1fb292008-08-26 12:58:38 +02001256
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001257static void alc_init_auto_hp(struct hda_codec *codec)
1258{
1259 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001260 struct auto_pin_cfg *cfg = &spec->autocfg;
1261 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001262
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001263 if (!cfg->hp_pins[0]) {
1264 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001265 return;
1266 }
1267
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001268 if (!cfg->speaker_pins[0]) {
1269 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1270 return;
1271 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1272 sizeof(cfg->speaker_pins));
1273 cfg->speaker_outs = cfg->line_outs;
1274 }
1275
1276 if (!cfg->hp_pins[0]) {
1277 memcpy(cfg->hp_pins, cfg->line_out_pins,
1278 sizeof(cfg->hp_pins));
1279 cfg->hp_outs = cfg->line_outs;
1280 }
1281
1282 for (i = 0; i < cfg->hp_outs; i++) {
1283 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1284 cfg->hp_pins[i]);
1285 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001286 AC_VERB_SET_UNSOLICITED_ENABLE,
1287 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001288 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001289 spec->unsol_event = alc_sku_unsol_event;
1290}
1291
Takashi Iwai6c819492009-08-10 18:47:44 +02001292static void alc_init_auto_mic(struct hda_codec *codec)
1293{
1294 struct alc_spec *spec = codec->spec;
1295 struct auto_pin_cfg *cfg = &spec->autocfg;
1296 hda_nid_t fixed, ext;
1297 int i;
1298
1299 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001300 for (i = 0; i < cfg->num_inputs; i++)
1301 if (cfg->inputs[i].type >= AUTO_PIN_LINE)
Takashi Iwai6c819492009-08-10 18:47:44 +02001302 return;
1303
1304 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001305 for (i = 0; i < cfg->num_inputs; i++) {
1306 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001307 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001308 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1309 switch (get_defcfg_connect(defcfg)) {
1310 case AC_JACK_PORT_FIXED:
1311 if (fixed)
1312 return; /* already occupied */
1313 fixed = nid;
1314 break;
1315 case AC_JACK_PORT_COMPLEX:
1316 if (ext)
1317 return; /* already occupied */
1318 ext = nid;
1319 break;
1320 default:
1321 return; /* invalid entry */
1322 }
1323 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001324 if (!ext || !fixed)
1325 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001326 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1327 return; /* no unsol support */
1328 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1329 ext, fixed);
1330 spec->ext_mic.pin = ext;
1331 spec->int_mic.pin = fixed;
1332 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1333 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1334 spec->auto_mic = 1;
1335 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1336 AC_VERB_SET_UNSOLICITED_ENABLE,
1337 AC_USRSP_EN | ALC880_MIC_EVENT);
1338 spec->unsol_event = alc_sku_unsol_event;
1339}
1340
Kailang Yangda00c242010-03-19 11:23:45 +01001341static int alc_auto_parse_customize_define(struct hda_codec *codec)
1342{
1343 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001344 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001345 struct alc_spec *spec = codec->spec;
1346
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001347 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1348
Kailang Yangda00c242010-03-19 11:23:45 +01001349 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001350 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001351 goto do_sku;
1352
1353 nid = 0x1d;
1354 if (codec->vendor_id == 0x10ec0260)
1355 nid = 0x17;
1356 ass = snd_hda_codec_get_pincfg(codec, nid);
1357
1358 if (!(ass & 1)) {
1359 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1360 codec->chip_name, ass);
1361 return -1;
1362 }
1363
1364 /* check sum */
1365 tmp = 0;
1366 for (i = 1; i < 16; i++) {
1367 if ((ass >> i) & 1)
1368 tmp++;
1369 }
1370 if (((ass >> 16) & 0xf) != tmp)
1371 return -1;
1372
1373 spec->cdefine.port_connectivity = ass >> 30;
1374 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1375 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1376 spec->cdefine.customization = ass >> 8;
1377do_sku:
1378 spec->cdefine.sku_cfg = ass;
1379 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1380 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1381 spec->cdefine.swap = (ass & 0x2) >> 1;
1382 spec->cdefine.override = ass & 0x1;
1383
1384 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1385 nid, spec->cdefine.sku_cfg);
1386 snd_printd("SKU: port_connectivity=0x%x\n",
1387 spec->cdefine.port_connectivity);
1388 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1389 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1390 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1391 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1392 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1393 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1394 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1395
1396 return 0;
1397}
1398
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001399/* check subsystem ID and set up device-specific initialization;
1400 * return 1 if initialized, 0 if invalid SSID
1401 */
1402/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1403 * 31 ~ 16 : Manufacture ID
1404 * 15 ~ 8 : SKU ID
1405 * 7 ~ 0 : Assembly ID
1406 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1407 */
1408static int alc_subsystem_id(struct hda_codec *codec,
1409 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001410 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001411{
1412 unsigned int ass, tmp, i;
1413 unsigned nid;
1414 struct alc_spec *spec = codec->spec;
1415
1416 ass = codec->subsystem_id & 0xffff;
1417 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1418 goto do_sku;
1419
1420 /* invalid SSID, check the special NID pin defcfg instead */
1421 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001422 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001423 * 29~21 : reserve
1424 * 20 : PCBEEP input
1425 * 19~16 : Check sum (15:1)
1426 * 15~1 : Custom
1427 * 0 : override
1428 */
1429 nid = 0x1d;
1430 if (codec->vendor_id == 0x10ec0260)
1431 nid = 0x17;
1432 ass = snd_hda_codec_get_pincfg(codec, nid);
1433 snd_printd("realtek: No valid SSID, "
1434 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001435 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001436 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001437 return 0;
1438 if ((ass >> 30) != 1) /* no physical connection */
1439 return 0;
1440
1441 /* check sum */
1442 tmp = 0;
1443 for (i = 1; i < 16; i++) {
1444 if ((ass >> i) & 1)
1445 tmp++;
1446 }
1447 if (((ass >> 16) & 0xf) != tmp)
1448 return 0;
1449do_sku:
1450 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1451 ass & 0xffff, codec->vendor_id);
1452 /*
1453 * 0 : override
1454 * 1 : Swap Jack
1455 * 2 : 0 --> Desktop, 1 --> Laptop
1456 * 3~5 : External Amplifier control
1457 * 7~6 : Reserved
1458 */
1459 tmp = (ass & 0x38) >> 3; /* external Amp control */
1460 switch (tmp) {
1461 case 1:
1462 spec->init_amp = ALC_INIT_GPIO1;
1463 break;
1464 case 3:
1465 spec->init_amp = ALC_INIT_GPIO2;
1466 break;
1467 case 7:
1468 spec->init_amp = ALC_INIT_GPIO3;
1469 break;
1470 case 5:
1471 spec->init_amp = ALC_INIT_DEFAULT;
1472 break;
1473 }
1474
1475 /* is laptop or Desktop and enable the function "Mute internal speaker
1476 * when the external headphone out jack is plugged"
1477 */
1478 if (!(ass & 0x8000))
1479 return 1;
1480 /*
1481 * 10~8 : Jack location
1482 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1483 * 14~13: Resvered
1484 * 15 : 1 --> enable the function "Mute internal speaker
1485 * when the external headphone out jack is plugged"
1486 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001487 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001488 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001489 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1490 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001491 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001492 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001493 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001494 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001495 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001496 else if (tmp == 3)
1497 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001498 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001499 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001500 for (i = 0; i < spec->autocfg.line_outs; i++)
1501 if (spec->autocfg.line_out_pins[i] == nid)
1502 return 1;
1503 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001504 }
1505
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001506 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001507 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001508 return 1;
1509}
Kailang Yangea1fb292008-08-26 12:58:38 +02001510
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001511static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001512 hda_nid_t porta, hda_nid_t porte,
1513 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001514{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001515 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001516 struct alc_spec *spec = codec->spec;
1517 snd_printd("realtek: "
1518 "Enable default setup for auto mode as fallback\n");
1519 spec->init_amp = ALC_INIT_DEFAULT;
1520 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001521 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001522 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001523}
1524
Takashi Iwai41e41f12005-06-08 14:48:49 +02001525/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001526 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001527 */
1528
1529struct alc_pincfg {
1530 hda_nid_t nid;
1531 u32 val;
1532};
1533
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001534struct alc_fixup {
1535 const struct alc_pincfg *pins;
1536 const struct hda_verb *verbs;
1537};
1538
1539static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001540 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001541 const struct alc_fixup *fix,
1542 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001543{
1544 const struct alc_pincfg *cfg;
1545
1546 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1547 if (!quirk)
1548 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001549 fix += quirk->value;
1550 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001551 if (pre_init && cfg) {
1552#ifdef CONFIG_SND_DEBUG_VERBOSE
1553 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1554 codec->chip_name, quirk->name);
1555#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001556 for (; cfg->nid; cfg++)
1557 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1558 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001559 if (!pre_init && fix->verbs) {
1560#ifdef CONFIG_SND_DEBUG_VERBOSE
1561 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1562 codec->chip_name, quirk->name);
1563#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001564 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001565 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001566}
1567
Kailang Yang274693f2009-12-03 10:07:50 +01001568static int alc_read_coef_idx(struct hda_codec *codec,
1569 unsigned int coef_idx)
1570{
1571 unsigned int val;
1572 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1573 coef_idx);
1574 val = snd_hda_codec_read(codec, 0x20, 0,
1575 AC_VERB_GET_PROC_COEF, 0);
1576 return val;
1577}
1578
Takashi Iwai757899a2010-07-30 10:48:14 +02001579/* set right pin controls for digital I/O */
1580static void alc_auto_init_digital(struct hda_codec *codec)
1581{
1582 struct alc_spec *spec = codec->spec;
1583 int i;
1584 hda_nid_t pin;
1585
1586 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1587 pin = spec->autocfg.dig_out_pins[i];
1588 if (pin) {
1589 snd_hda_codec_write(codec, pin, 0,
1590 AC_VERB_SET_PIN_WIDGET_CONTROL,
1591 PIN_OUT);
1592 }
1593 }
1594 pin = spec->autocfg.dig_in_pin;
1595 if (pin)
1596 snd_hda_codec_write(codec, pin, 0,
1597 AC_VERB_SET_PIN_WIDGET_CONTROL,
1598 PIN_IN);
1599}
1600
1601/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1602static void alc_auto_parse_digital(struct hda_codec *codec)
1603{
1604 struct alc_spec *spec = codec->spec;
1605 int i, err;
1606 hda_nid_t dig_nid;
1607
1608 /* support multiple SPDIFs; the secondary is set up as a slave */
1609 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1610 err = snd_hda_get_connections(codec,
1611 spec->autocfg.dig_out_pins[i],
1612 &dig_nid, 1);
1613 if (err < 0)
1614 continue;
1615 if (!i) {
1616 spec->multiout.dig_out_nid = dig_nid;
1617 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1618 } else {
1619 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1620 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1621 break;
1622 spec->slave_dig_outs[i - 1] = dig_nid;
1623 }
1624 }
1625
1626 if (spec->autocfg.dig_in_pin) {
1627 hda_nid_t dig_nid;
1628 err = snd_hda_get_connections(codec,
1629 spec->autocfg.dig_in_pin,
1630 &dig_nid, 1);
1631 if (err > 0)
1632 spec->dig_in_nid = dig_nid;
1633 }
1634}
1635
Takashi Iwaif95474e2007-07-10 00:47:43 +02001636/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001637 * ALC888
1638 */
1639
1640/*
1641 * 2ch mode
1642 */
1643static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1644/* Mic-in jack as mic in */
1645 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1646 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1647/* Line-in jack as Line in */
1648 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1649 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1650/* Line-Out as Front */
1651 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1652 { } /* end */
1653};
1654
1655/*
1656 * 4ch mode
1657 */
1658static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1659/* Mic-in jack as mic in */
1660 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1661 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
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 Front */
1666 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1667 { } /* end */
1668};
1669
1670/*
1671 * 6ch mode
1672 */
1673static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1674/* Mic-in jack as CLFE */
1675 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1676 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1677/* Line-in jack as Surround */
1678 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1679 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1680/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1681 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1682 { } /* end */
1683};
1684
1685/*
1686 * 8ch mode
1687 */
1688static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1689/* Mic-in jack as CLFE */
1690 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1691 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1692/* Line-in jack as Surround */
1693 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1694 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1695/* Line-Out as Side */
1696 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1697 { } /* end */
1698};
1699
1700static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1701 { 2, alc888_4ST_ch2_intel_init },
1702 { 4, alc888_4ST_ch4_intel_init },
1703 { 6, alc888_4ST_ch6_intel_init },
1704 { 8, alc888_4ST_ch8_intel_init },
1705};
1706
1707/*
1708 * ALC888 Fujitsu Siemens Amillo xa3530
1709 */
1710
1711static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1712/* Front Mic: set to PIN_IN (empty by default) */
1713 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1714/* Connect Internal HP to Front */
1715 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1716 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1717 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1718/* Connect Bass HP to Front */
1719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1720 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1721 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1722/* Connect Line-Out side jack (SPDIF) to Side */
1723 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1724 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1725 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1726/* Connect Mic jack to CLFE */
1727 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1729 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1730/* Connect Line-in jack to Surround */
1731 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1732 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1733 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1734/* Connect HP out jack to Front */
1735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1737 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1738/* Enable unsolicited event for HP jack and Line-out jack */
1739 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1740 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1741 {}
1742};
1743
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001744static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001745{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001746 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001747}
1748
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001749static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1750 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001751{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001752 if (codec->vendor_id == 0x10ec0880)
1753 res >>= 28;
1754 else
1755 res >>= 26;
1756 if (res == ALC880_HP_EVENT)
1757 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001758}
1759
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001760static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001761{
1762 struct alc_spec *spec = codec->spec;
1763
1764 spec->autocfg.hp_pins[0] = 0x15;
1765 spec->autocfg.speaker_pins[0] = 0x14;
1766 spec->autocfg.speaker_pins[1] = 0x16;
1767 spec->autocfg.speaker_pins[2] = 0x17;
1768 spec->autocfg.speaker_pins[3] = 0x19;
1769 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001770}
1771
1772static void alc889_intel_init_hook(struct hda_codec *codec)
1773{
1774 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001775 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001776}
1777
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001778static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001779{
1780 struct alc_spec *spec = codec->spec;
1781
1782 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1783 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1784 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1785 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001786}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001787
1788/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001789 * ALC888 Acer Aspire 4930G model
1790 */
1791
1792static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1793/* Front Mic: set to PIN_IN (empty by default) */
1794 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1795/* Unselect Front Mic by default in input mixer 3 */
1796 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001797/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001798 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1799/* Connect Internal HP to front */
1800 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1801 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1802 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1803/* Connect HP out to front */
1804 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1806 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1807 { }
1808};
1809
Hector Martin3b315d72009-06-02 10:54:19 +02001810/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001811 * ALC888 Acer Aspire 6530G model
1812 */
1813
1814static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001815/* Route to built-in subwoofer as well as speakers */
1816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1818 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1819 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001820/* Bias voltage on for external mic port */
1821 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001822/* Front Mic: set to PIN_IN (empty by default) */
1823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1824/* Unselect Front Mic by default in input mixer 3 */
1825 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001826/* Enable unsolicited event for HP jack */
1827 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1828/* Enable speaker output */
1829 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1830 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001831 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001832/* Enable headphone output */
1833 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1834 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001836 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001837 { }
1838};
1839
1840/*
Hector Martin018df412009-06-04 00:13:40 +02001841 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001842 */
1843
Hector Martin018df412009-06-04 00:13:40 +02001844static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001845/* Front Mic: set to PIN_IN (empty by default) */
1846 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1847/* Unselect Front Mic by default in input mixer 3 */
1848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1849/* Enable unsolicited event for HP jack */
1850 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1851/* Connect Internal Front to Front */
1852 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1854 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1855/* Connect Internal Rear to Rear */
1856 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1857 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1858 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1859/* Connect Internal CLFE to CLFE */
1860 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1861 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1863/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001864 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001865 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1866 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1867/* Enable all DACs */
1868/* DAC DISABLE/MUTE 1? */
1869/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1870 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1871 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1872/* DAC DISABLE/MUTE 2? */
1873/* some bit here disables the other DACs. Init=0x4900 */
1874 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1875 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001876/* DMIC fix
1877 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1878 * which makes the stereo useless. However, either the mic or the ALC889
1879 * makes the signal become a difference/sum signal instead of standard
1880 * stereo, which is annoying. So instead we flip this bit which makes the
1881 * codec replicate the sum signal to both channels, turning it into a
1882 * normal mono mic.
1883 */
1884/* DMIC_CONTROL? Init value = 0x0001 */
1885 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1886 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001887 { }
1888};
1889
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001890static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001891 /* Front mic only available on one ADC */
1892 {
1893 .num_items = 4,
1894 .items = {
1895 { "Mic", 0x0 },
1896 { "Line", 0x2 },
1897 { "CD", 0x4 },
1898 { "Front Mic", 0xb },
1899 },
1900 },
1901 {
1902 .num_items = 3,
1903 .items = {
1904 { "Mic", 0x0 },
1905 { "Line", 0x2 },
1906 { "CD", 0x4 },
1907 },
1908 }
1909};
1910
Tony Vroond2fd4b02009-06-21 00:40:10 +01001911static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1912 /* Interal mic only available on one ADC */
1913 {
Tony Vroon684a8842009-06-26 09:27:50 +01001914 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001915 .items = {
1916 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001917 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001918 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001919 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001920 { "Int Mic", 0xb },
1921 },
1922 },
1923 {
Tony Vroon684a8842009-06-26 09:27:50 +01001924 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001925 .items = {
1926 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001927 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001928 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001929 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001930 },
1931 }
1932};
1933
Hector Martin018df412009-06-04 00:13:40 +02001934static struct hda_input_mux alc889_capture_sources[3] = {
1935 /* Digital mic only available on first "ADC" */
1936 {
1937 .num_items = 5,
1938 .items = {
1939 { "Mic", 0x0 },
1940 { "Line", 0x2 },
1941 { "CD", 0x4 },
1942 { "Front Mic", 0xb },
1943 { "Input Mix", 0xa },
1944 },
1945 },
1946 {
1947 .num_items = 4,
1948 .items = {
1949 { "Mic", 0x0 },
1950 { "Line", 0x2 },
1951 { "CD", 0x4 },
1952 { "Input Mix", 0xa },
1953 },
1954 },
1955 {
1956 .num_items = 4,
1957 .items = {
1958 { "Mic", 0x0 },
1959 { "Line", 0x2 },
1960 { "CD", 0x4 },
1961 { "Input Mix", 0xa },
1962 },
1963 }
1964};
1965
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001966static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1968 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1969 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1970 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1971 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1972 HDA_OUTPUT),
1973 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1976 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1977 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1978 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1979 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1983 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001985 { } /* end */
1986};
1987
Hector Martin556eea92009-12-20 22:51:23 +01001988static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1989 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1990 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1991 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1992 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1993 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1994 HDA_OUTPUT),
1995 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1996 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1997 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2000 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2001 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2002 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2003 { } /* end */
2004};
2005
2006
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002007static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002008{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002009 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002010
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002011 spec->autocfg.hp_pins[0] = 0x15;
2012 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002013 spec->autocfg.speaker_pins[1] = 0x16;
2014 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002015}
2016
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002017static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002018{
2019 struct alc_spec *spec = codec->spec;
2020
2021 spec->autocfg.hp_pins[0] = 0x15;
2022 spec->autocfg.speaker_pins[0] = 0x14;
2023 spec->autocfg.speaker_pins[1] = 0x16;
2024 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002025}
2026
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002027static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002028{
2029 struct alc_spec *spec = codec->spec;
2030
2031 spec->autocfg.hp_pins[0] = 0x15;
2032 spec->autocfg.speaker_pins[0] = 0x14;
2033 spec->autocfg.speaker_pins[1] = 0x16;
2034 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002035}
2036
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002037/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002038 * ALC880 3-stack model
2039 *
2040 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002041 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2042 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002043 */
2044
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002045static hda_nid_t alc880_dac_nids[4] = {
2046 /* front, rear, clfe, rear_surr */
2047 0x02, 0x05, 0x04, 0x03
2048};
2049
2050static hda_nid_t alc880_adc_nids[3] = {
2051 /* ADC0-2 */
2052 0x07, 0x08, 0x09,
2053};
2054
2055/* The datasheet says the node 0x07 is connected from inputs,
2056 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002057 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002059static hda_nid_t alc880_adc_nids_alt[2] = {
2060 /* ADC1-2 */
2061 0x08, 0x09,
2062};
2063
2064#define ALC880_DIGOUT_NID 0x06
2065#define ALC880_DIGIN_NID 0x0a
2066
2067static struct hda_input_mux alc880_capture_source = {
2068 .num_items = 4,
2069 .items = {
2070 { "Mic", 0x0 },
2071 { "Front Mic", 0x3 },
2072 { "Line", 0x2 },
2073 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002075};
2076
2077/* channel source setting (2/6 channel selection for 3-stack) */
2078/* 2ch mode */
2079static struct hda_verb alc880_threestack_ch2_init[] = {
2080 /* set line-in to input, mute it */
2081 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2082 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2083 /* set mic-in to input vref 80%, mute it */
2084 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2085 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086 { } /* end */
2087};
2088
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002089/* 6ch mode */
2090static struct hda_verb alc880_threestack_ch6_init[] = {
2091 /* set line-in to output, unmute it */
2092 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2093 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2094 /* set mic-in to output, unmute it */
2095 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2096 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2097 { } /* end */
2098};
2099
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002100static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002101 { 2, alc880_threestack_ch2_init },
2102 { 6, alc880_threestack_ch6_init },
2103};
2104
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002105static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002106 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002107 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002108 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002109 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002110 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2111 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002112 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2113 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2116 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2117 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2121 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002123 {
2124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2125 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002126 .info = alc_ch_mode_info,
2127 .get = alc_ch_mode_get,
2128 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002129 },
2130 { } /* end */
2131};
2132
2133/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002134static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2135 struct snd_ctl_elem_info *uinfo)
2136{
2137 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2138 struct alc_spec *spec = codec->spec;
2139 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002140
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002141 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002142 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2143 HDA_INPUT);
2144 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002145 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002146 return err;
2147}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002149static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2150 unsigned int size, unsigned int __user *tlv)
2151{
2152 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2153 struct alc_spec *spec = codec->spec;
2154 int err;
2155
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002156 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002157 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2158 HDA_INPUT);
2159 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002160 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002161 return err;
2162}
2163
2164typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2165 struct snd_ctl_elem_value *ucontrol);
2166
2167static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2168 struct snd_ctl_elem_value *ucontrol,
2169 getput_call_t func)
2170{
2171 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2172 struct alc_spec *spec = codec->spec;
2173 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2174 int err;
2175
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002176 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002177 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2178 3, 0, HDA_INPUT);
2179 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002180 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002181 return err;
2182}
2183
2184static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2185 struct snd_ctl_elem_value *ucontrol)
2186{
2187 return alc_cap_getput_caller(kcontrol, ucontrol,
2188 snd_hda_mixer_amp_volume_get);
2189}
2190
2191static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2192 struct snd_ctl_elem_value *ucontrol)
2193{
2194 return alc_cap_getput_caller(kcontrol, ucontrol,
2195 snd_hda_mixer_amp_volume_put);
2196}
2197
2198/* capture mixer elements */
2199#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2200
2201static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2202 struct snd_ctl_elem_value *ucontrol)
2203{
2204 return alc_cap_getput_caller(kcontrol, ucontrol,
2205 snd_hda_mixer_amp_switch_get);
2206}
2207
2208static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2209 struct snd_ctl_elem_value *ucontrol)
2210{
2211 return alc_cap_getput_caller(kcontrol, ucontrol,
2212 snd_hda_mixer_amp_switch_put);
2213}
2214
Takashi Iwaia23b6882009-03-23 15:21:36 +01002215#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002216 { \
2217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2218 .name = "Capture Switch", \
2219 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2220 .count = num, \
2221 .info = alc_cap_sw_info, \
2222 .get = alc_cap_sw_get, \
2223 .put = alc_cap_sw_put, \
2224 }, \
2225 { \
2226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2227 .name = "Capture Volume", \
2228 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2229 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2230 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2231 .count = num, \
2232 .info = alc_cap_vol_info, \
2233 .get = alc_cap_vol_get, \
2234 .put = alc_cap_vol_put, \
2235 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002236 }
2237
2238#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002239 { \
2240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2241 /* .name = "Capture Source", */ \
2242 .name = "Input Source", \
2243 .count = num, \
2244 .info = alc_mux_enum_info, \
2245 .get = alc_mux_enum_get, \
2246 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002247 }
2248
2249#define DEFINE_CAPMIX(num) \
2250static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2251 _DEFINE_CAPMIX(num), \
2252 _DEFINE_CAPSRC(num), \
2253 { } /* end */ \
2254}
2255
2256#define DEFINE_CAPMIX_NOSRC(num) \
2257static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2258 _DEFINE_CAPMIX(num), \
2259 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002260}
2261
2262/* up to three ADCs */
2263DEFINE_CAPMIX(1);
2264DEFINE_CAPMIX(2);
2265DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002266DEFINE_CAPMIX_NOSRC(1);
2267DEFINE_CAPMIX_NOSRC(2);
2268DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002269
2270/*
2271 * ALC880 5-stack model
2272 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002273 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2274 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002275 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2276 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2277 */
2278
2279/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002280static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002281 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002282 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 { } /* end */
2284};
2285
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002286/* channel source setting (6/8 channel selection for 5-stack) */
2287/* 6ch mode */
2288static struct hda_verb alc880_fivestack_ch6_init[] = {
2289 /* set line-in to input, mute it */
2290 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2291 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002292 { } /* end */
2293};
2294
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002295/* 8ch mode */
2296static struct hda_verb alc880_fivestack_ch8_init[] = {
2297 /* set line-in to output, unmute it */
2298 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2299 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2300 { } /* end */
2301};
2302
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002303static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002304 { 6, alc880_fivestack_ch6_init },
2305 { 8, alc880_fivestack_ch8_init },
2306};
2307
2308
2309/*
2310 * ALC880 6-stack model
2311 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002312 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2313 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002314 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2315 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2316 */
2317
2318static hda_nid_t alc880_6st_dac_nids[4] = {
2319 /* front, rear, clfe, rear_surr */
2320 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002321};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322
2323static struct hda_input_mux alc880_6stack_capture_source = {
2324 .num_items = 4,
2325 .items = {
2326 { "Mic", 0x0 },
2327 { "Front Mic", 0x1 },
2328 { "Line", 0x2 },
2329 { "CD", 0x4 },
2330 },
2331};
2332
2333/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002334static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002335 { 8, NULL },
2336};
2337
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002338static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002340 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002341 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002342 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002343 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2344 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002345 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2346 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002347 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002348 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002349 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2350 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2356 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002357 {
2358 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2359 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002360 .info = alc_ch_mode_info,
2361 .get = alc_ch_mode_get,
2362 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002363 },
2364 { } /* end */
2365};
2366
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002367
2368/*
2369 * ALC880 W810 model
2370 *
2371 * W810 has rear IO for:
2372 * Front (DAC 02)
2373 * Surround (DAC 03)
2374 * Center/LFE (DAC 04)
2375 * Digital out (06)
2376 *
2377 * The system also has a pair of internal speakers, and a headphone jack.
2378 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002379 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002380 * There is a variable resistor to control the speaker or headphone
2381 * volume. This is a hardware-only device without a software API.
2382 *
2383 * Plugging headphones in will disable the internal speakers. This is
2384 * implemented in hardware, not via the driver using jack sense. In
2385 * a similar fashion, plugging into the rear socket marked "front" will
2386 * disable both the speakers and headphones.
2387 *
2388 * For input, there's a microphone jack, and an "audio in" jack.
2389 * These may not do anything useful with this driver yet, because I
2390 * haven't setup any initialization verbs for these yet...
2391 */
2392
2393static hda_nid_t alc880_w810_dac_nids[3] = {
2394 /* front, rear/surround, clfe */
2395 0x02, 0x03, 0x04
2396};
2397
2398/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002399static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002400 { 6, NULL }
2401};
2402
2403/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002404static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002406 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002407 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002408 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002409 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2410 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002411 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2412 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2414 { } /* end */
2415};
2416
2417
2418/*
2419 * Z710V model
2420 *
2421 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002422 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2423 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002424 */
2425
2426static hda_nid_t alc880_z71v_dac_nids[1] = {
2427 0x02
2428};
2429#define ALC880_Z71V_HP_DAC 0x03
2430
2431/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002432static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002433 { 2, NULL }
2434};
2435
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002436static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002437 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002438 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002439 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002440 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002441 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2442 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2443 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2444 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2445 { } /* end */
2446};
2447
2448
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002449/*
2450 * ALC880 F1734 model
2451 *
2452 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2453 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2454 */
2455
2456static hda_nid_t alc880_f1734_dac_nids[1] = {
2457 0x03
2458};
2459#define ALC880_F1734_HP_DAC 0x02
2460
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002461static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002462 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002463 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002464 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2465 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002466 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2467 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2469 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002470 { } /* end */
2471};
2472
Takashi Iwai937b4162008-02-11 14:52:36 +01002473static struct hda_input_mux alc880_f1734_capture_source = {
2474 .num_items = 2,
2475 .items = {
2476 { "Mic", 0x1 },
2477 { "CD", 0x4 },
2478 },
2479};
2480
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002481
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002482/*
2483 * ALC880 ASUS model
2484 *
2485 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2486 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2487 * Mic = 0x18, Line = 0x1a
2488 */
2489
2490#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2491#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2492
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002493static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002494 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002495 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002496 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002497 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002498 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2499 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002500 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2501 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002508 {
2509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2510 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002511 .info = alc_ch_mode_info,
2512 .get = alc_ch_mode_get,
2513 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002514 },
2515 { } /* end */
2516};
2517
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002518/*
2519 * ALC880 ASUS W1V model
2520 *
2521 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2522 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2523 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2524 */
2525
2526/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002527static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002528 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2529 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002530 { } /* end */
2531};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532
Kailang Yangdf694da2005-12-05 19:42:22 +01002533/* TCL S700 */
2534static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2535 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2536 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2538 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2539 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2540 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2542 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2543 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002544 { } /* end */
2545};
2546
Kailang Yangccc656c2006-10-17 12:32:26 +02002547/* Uniwill */
2548static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002549 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2550 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2551 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2552 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002553 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2554 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2555 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2556 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2557 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2558 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2559 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2560 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2561 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2562 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2563 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2564 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002565 {
2566 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2567 .name = "Channel Mode",
2568 .info = alc_ch_mode_info,
2569 .get = alc_ch_mode_get,
2570 .put = alc_ch_mode_put,
2571 },
2572 { } /* end */
2573};
2574
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002575static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2576 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2577 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2578 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2579 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2580 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2581 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2582 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2583 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2584 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2585 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2586 { } /* end */
2587};
2588
Kailang Yangccc656c2006-10-17 12:32:26 +02002589static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002590 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2591 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2592 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2593 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002594 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2595 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2596 { } /* end */
2597};
2598
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002600 * virtual master controls
2601 */
2602
2603/*
2604 * slave controls for virtual master
2605 */
2606static const char *alc_slave_vols[] = {
2607 "Front Playback Volume",
2608 "Surround Playback Volume",
2609 "Center Playback Volume",
2610 "LFE Playback Volume",
2611 "Side Playback Volume",
2612 "Headphone Playback Volume",
2613 "Speaker Playback Volume",
2614 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002615 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002616 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002617 NULL,
2618};
2619
2620static const char *alc_slave_sws[] = {
2621 "Front Playback Switch",
2622 "Surround Playback Switch",
2623 "Center Playback Switch",
2624 "LFE Playback Switch",
2625 "Side Playback Switch",
2626 "Headphone Playback Switch",
2627 "Speaker Playback Switch",
2628 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002629 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002630 "Line-Out Playback Switch",
2631 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002632 NULL,
2633};
2634
2635/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002636 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002637 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002638
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002639#define NID_MAPPING (-1)
2640
2641#define SUBDEV_SPEAKER_ (0 << 6)
2642#define SUBDEV_HP_ (1 << 6)
2643#define SUBDEV_LINE_ (2 << 6)
2644#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2645#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2646#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2647
Takashi Iwai603c4012008-07-30 15:01:44 +02002648static void alc_free_kctls(struct hda_codec *codec);
2649
Takashi Iwai67d634c2009-11-16 15:35:59 +01002650#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002651/* additional beep mixers; the actual parameters are overwritten at build */
2652static struct snd_kcontrol_new alc_beep_mixer[] = {
2653 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002654 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002655 { } /* end */
2656};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002657#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002658
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659static int alc_build_controls(struct hda_codec *codec)
2660{
2661 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002662 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002663 struct snd_kcontrol_new *knew;
2664 int i, j, err;
2665 unsigned int u;
2666 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667
2668 for (i = 0; i < spec->num_mixers; i++) {
2669 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2670 if (err < 0)
2671 return err;
2672 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002673 if (spec->cap_mixer) {
2674 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2675 if (err < 0)
2676 return err;
2677 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002679 err = snd_hda_create_spdif_out_ctls(codec,
2680 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 if (err < 0)
2682 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002683 if (!spec->no_analog) {
2684 err = snd_hda_create_spdif_share_sw(codec,
2685 &spec->multiout);
2686 if (err < 0)
2687 return err;
2688 spec->multiout.share_spdif = 1;
2689 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 }
2691 if (spec->dig_in_nid) {
2692 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2693 if (err < 0)
2694 return err;
2695 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002696
Takashi Iwai67d634c2009-11-16 15:35:59 +01002697#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002698 /* create beep controls if needed */
2699 if (spec->beep_amp) {
2700 struct snd_kcontrol_new *knew;
2701 for (knew = alc_beep_mixer; knew->name; knew++) {
2702 struct snd_kcontrol *kctl;
2703 kctl = snd_ctl_new1(knew, codec);
2704 if (!kctl)
2705 return -ENOMEM;
2706 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002707 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002708 if (err < 0)
2709 return err;
2710 }
2711 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002712#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002713
Takashi Iwai2134ea42008-01-10 16:53:55 +01002714 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002715 if (!spec->no_analog &&
2716 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002717 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002718 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002719 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002720 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002721 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002722 if (err < 0)
2723 return err;
2724 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002725 if (!spec->no_analog &&
2726 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002727 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2728 NULL, alc_slave_sws);
2729 if (err < 0)
2730 return err;
2731 }
2732
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002733 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002734 if (spec->capsrc_nids || spec->adc_nids) {
2735 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2736 if (!kctl)
2737 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2738 for (i = 0; kctl && i < kctl->count; i++) {
2739 hda_nid_t *nids = spec->capsrc_nids;
2740 if (!nids)
2741 nids = spec->adc_nids;
2742 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2743 if (err < 0)
2744 return err;
2745 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002746 }
2747 if (spec->cap_mixer) {
2748 const char *kname = kctl ? kctl->id.name : NULL;
2749 for (knew = spec->cap_mixer; knew->name; knew++) {
2750 if (kname && strcmp(knew->name, kname) == 0)
2751 continue;
2752 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2753 for (i = 0; kctl && i < kctl->count; i++) {
2754 err = snd_hda_add_nid(codec, kctl, i,
2755 spec->adc_nids[i]);
2756 if (err < 0)
2757 return err;
2758 }
2759 }
2760 }
2761
2762 /* other nid->control mapping */
2763 for (i = 0; i < spec->num_mixers; i++) {
2764 for (knew = spec->mixers[i]; knew->name; knew++) {
2765 if (knew->iface != NID_MAPPING)
2766 continue;
2767 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2768 if (kctl == NULL)
2769 continue;
2770 u = knew->subdevice;
2771 for (j = 0; j < 4; j++, u >>= 8) {
2772 nid = u & 0x3f;
2773 if (nid == 0)
2774 continue;
2775 switch (u & 0xc0) {
2776 case SUBDEV_SPEAKER_:
2777 nid = spec->autocfg.speaker_pins[nid];
2778 break;
2779 case SUBDEV_LINE_:
2780 nid = spec->autocfg.line_out_pins[nid];
2781 break;
2782 case SUBDEV_HP_:
2783 nid = spec->autocfg.hp_pins[nid];
2784 break;
2785 default:
2786 continue;
2787 }
2788 err = snd_hda_add_nid(codec, kctl, 0, nid);
2789 if (err < 0)
2790 return err;
2791 }
2792 u = knew->private_value;
2793 for (j = 0; j < 4; j++, u >>= 8) {
2794 nid = u & 0xff;
2795 if (nid == 0)
2796 continue;
2797 err = snd_hda_add_nid(codec, kctl, 0, nid);
2798 if (err < 0)
2799 return err;
2800 }
2801 }
2802 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002803
2804 alc_free_kctls(codec); /* no longer needed */
2805
Linus Torvalds1da177e2005-04-16 15:20:36 -07002806 return 0;
2807}
2808
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002809
Linus Torvalds1da177e2005-04-16 15:20:36 -07002810/*
2811 * initialize the codec volumes, etc
2812 */
2813
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002814/*
2815 * generic initialization of ADC, input mixers and output mixers
2816 */
2817static struct hda_verb alc880_volume_init_verbs[] = {
2818 /*
2819 * Unmute ADC0-2 and set the default input to mic-in
2820 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002821 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002822 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002823 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002824 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002825 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002826 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002827
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002828 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2829 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002830 * Note: PASD motherboards uses the Line In 2 as the input for front
2831 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002832 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002833 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002834 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2835 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002841
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002842 /*
2843 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002844 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002845 /* set vol=0 to output mixers */
2846 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2847 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2848 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2849 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2850 /* set up input amps for analog loopback */
2851 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002852 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002854 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002856 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002858 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2859 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002860
2861 { }
2862};
2863
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002864/*
2865 * 3-stack pin configuration:
2866 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2867 */
2868static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2869 /*
2870 * preset connection lists of input pins
2871 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2872 */
2873 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2874 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2875 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2876
2877 /*
2878 * Set pin mode and muting
2879 */
2880 /* set front pin widgets 0x14 for output */
2881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2883 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2885 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2886 /* Mic2 (as headphone out) for HP output */
2887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2889 /* Line In pin widget for input */
2890 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2891 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2892 /* Line2 (as front mic) pin widget for input and vref at 80% */
2893 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2894 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2895 /* CD pin widget for input */
2896 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2897
2898 { }
2899};
2900
2901/*
2902 * 5-stack pin configuration:
2903 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2904 * line-in/side = 0x1a, f-mic = 0x1b
2905 */
2906static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2907 /*
2908 * preset connection lists of input pins
2909 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2910 */
2911 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2912 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2913
2914 /*
2915 * Set pin mode and muting
2916 */
2917 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002918 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2920 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2921 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002922 /* unmute pins for output (no gain on this amp) */
2923 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2924 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2925 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2926 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2927
Linus Torvalds1da177e2005-04-16 15:20:36 -07002928 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002929 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002930 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2931 /* Mic2 (as headphone out) for HP output */
2932 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002933 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934 /* Line In pin widget for input */
2935 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2936 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2937 /* Line2 (as front mic) pin widget for input and vref at 80% */
2938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2939 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2940 /* CD pin widget for input */
2941 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002942
2943 { }
2944};
2945
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002946/*
2947 * W810 pin configuration:
2948 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2949 */
2950static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002951 /* hphone/speaker input selector: front DAC */
2952 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2953
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2955 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2957 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2958 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2959 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2960
2961 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002962 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964 { }
2965};
2966
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967/*
2968 * Z71V pin configuration:
2969 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2970 */
2971static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002976
Takashi Iwai16ded522005-06-10 19:58:24 +02002977 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002978 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002979 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002980 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002981
2982 { }
2983};
2984
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985/*
2986 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002987 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2988 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002989 */
2990static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2991 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2992
Takashi Iwai16ded522005-06-10 19:58:24 +02002993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002995 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002996 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002997 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002999 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003000 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3001
Takashi Iwai16ded522005-06-10 19:58:24 +02003002 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003003 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003004 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003006 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003008 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003009 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003010 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003011
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003012 { }
3013};
Takashi Iwai16ded522005-06-10 19:58:24 +02003014
Kailang Yangccc656c2006-10-17 12:32:26 +02003015/*
3016 * Uniwill pin configuration:
3017 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3018 * line = 0x1a
3019 */
3020static struct hda_verb alc880_uniwill_init_verbs[] = {
3021 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3022
3023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3026 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3027 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3028 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3029 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3030 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3031 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3032 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3033 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3034 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3035 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3036 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3037
3038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3039 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3040 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3041 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3042 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3043 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3044 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3045 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047
3048 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3049 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3050
3051 { }
3052};
3053
3054/*
3055* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003056* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003057 */
3058static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3059 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3060
3061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3064 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3065 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3066 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3073
3074 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3075 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3076 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3077 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3078 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3079 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3080
3081 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3082 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3083
3084 { }
3085};
3086
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003087static struct hda_verb alc880_beep_init_verbs[] = {
3088 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3089 { }
3090};
3091
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003092/* auto-toggle front mic */
3093static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3094{
3095 unsigned int present;
3096 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003097
Wu Fengguang864f92b2009-11-18 12:38:02 +08003098 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003099 bits = present ? HDA_AMP_MUTE : 0;
3100 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003101}
3102
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003103static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003104{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003105 struct alc_spec *spec = codec->spec;
3106
3107 spec->autocfg.hp_pins[0] = 0x14;
3108 spec->autocfg.speaker_pins[0] = 0x15;
3109 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003110}
3111
3112static void alc880_uniwill_init_hook(struct hda_codec *codec)
3113{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003114 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003115 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003116}
3117
3118static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3119 unsigned int res)
3120{
3121 /* Looks like the unsol event is incompatible with the standard
3122 * definition. 4bit tag is placed at 28 bit!
3123 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003124 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003125 case ALC880_MIC_EVENT:
3126 alc880_uniwill_mic_automute(codec);
3127 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003128 default:
3129 alc_automute_amp_unsol_event(codec, res);
3130 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003131 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003132}
3133
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003134static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003135{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003136 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003137
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003138 spec->autocfg.hp_pins[0] = 0x14;
3139 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003140}
3141
3142static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3143{
3144 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003145
Kailang Yangccc656c2006-10-17 12:32:26 +02003146 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003147 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3148 present &= HDA_AMP_VOLMASK;
3149 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3150 HDA_AMP_VOLMASK, present);
3151 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3152 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003153}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003154
Kailang Yangccc656c2006-10-17 12:32:26 +02003155static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3156 unsigned int res)
3157{
3158 /* Looks like the unsol event is incompatible with the standard
3159 * definition. 4bit tag is placed at 28 bit!
3160 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003161 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003162 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003163 else
3164 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003165}
3166
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003167/*
3168 * F1734 pin configuration:
3169 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3170 */
3171static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003172 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003173 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3174 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3175 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3176 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3177
3178 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3179 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3180 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3181 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3182
3183 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3184 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003186 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3187 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3188 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3190 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003192
Takashi Iwai937b4162008-02-11 14:52:36 +01003193 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3194 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3195
Takashi Iwai16ded522005-06-10 19:58:24 +02003196 { }
3197};
3198
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003199/*
3200 * ASUS pin configuration:
3201 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3202 */
3203static struct hda_verb alc880_pin_asus_init_verbs[] = {
3204 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3205 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3206 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3207 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3208
3209 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3210 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3213 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3214 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3215 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3217
3218 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3220 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3222 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3226 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003227
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003228 { }
3229};
3230
3231/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003232#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3233#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003234#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235
Kailang Yangdf694da2005-12-05 19:42:22 +01003236/* Clevo m520g init */
3237static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3238 /* headphone output */
3239 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3240 /* line-out */
3241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3242 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3243 /* Line-in */
3244 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3245 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3246 /* CD */
3247 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3248 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3249 /* Mic1 (rear panel) */
3250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3252 /* Mic2 (front panel) */
3253 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3254 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3255 /* headphone */
3256 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3257 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3258 /* change to EAPD mode */
3259 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3260 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3261
3262 { }
3263};
3264
3265static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003266 /* change to EAPD mode */
3267 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3268 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3269
Kailang Yangdf694da2005-12-05 19:42:22 +01003270 /* Headphone output */
3271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3272 /* Front output*/
3273 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3274 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3275
3276 /* Line In pin widget for input */
3277 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3278 /* CD pin widget for input */
3279 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3280 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3282
3283 /* change to EAPD mode */
3284 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3285 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3286
3287 { }
3288};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003289
3290/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003291 * LG m1 express dual
3292 *
3293 * Pin assignment:
3294 * Rear Line-In/Out (blue): 0x14
3295 * Build-in Mic-In: 0x15
3296 * Speaker-out: 0x17
3297 * HP-Out (green): 0x1b
3298 * Mic-In/Out (red): 0x19
3299 * SPDIF-Out: 0x1e
3300 */
3301
3302/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3303static hda_nid_t alc880_lg_dac_nids[3] = {
3304 0x05, 0x02, 0x03
3305};
3306
3307/* seems analog CD is not working */
3308static struct hda_input_mux alc880_lg_capture_source = {
3309 .num_items = 3,
3310 .items = {
3311 { "Mic", 0x1 },
3312 { "Line", 0x5 },
3313 { "Internal Mic", 0x6 },
3314 },
3315};
3316
3317/* 2,4,6 channel modes */
3318static struct hda_verb alc880_lg_ch2_init[] = {
3319 /* set line-in and mic-in to input */
3320 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3321 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3322 { }
3323};
3324
3325static struct hda_verb alc880_lg_ch4_init[] = {
3326 /* set line-in to out and mic-in to input */
3327 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3328 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3329 { }
3330};
3331
3332static struct hda_verb alc880_lg_ch6_init[] = {
3333 /* set line-in and mic-in to output */
3334 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3335 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3336 { }
3337};
3338
3339static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3340 { 2, alc880_lg_ch2_init },
3341 { 4, alc880_lg_ch4_init },
3342 { 6, alc880_lg_ch6_init },
3343};
3344
3345static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003346 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3347 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003348 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3349 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3350 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3351 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3352 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3353 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3358 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3359 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3360 {
3361 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3362 .name = "Channel Mode",
3363 .info = alc_ch_mode_info,
3364 .get = alc_ch_mode_get,
3365 .put = alc_ch_mode_put,
3366 },
3367 { } /* end */
3368};
3369
3370static struct hda_verb alc880_lg_init_verbs[] = {
3371 /* set capture source to mic-in */
3372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3375 /* mute all amp mixer inputs */
3376 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003377 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3378 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003379 /* line-in to input */
3380 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3381 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 /* built-in mic */
3383 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3385 /* speaker-out */
3386 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3387 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3388 /* mic-in to input */
3389 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3390 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3391 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3392 /* HP-out */
3393 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3394 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3395 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3396 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003397 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003398 { }
3399};
3400
3401/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003402static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003403{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003404 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003405
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003406 spec->autocfg.hp_pins[0] = 0x1b;
3407 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003408}
3409
3410/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003411 * LG LW20
3412 *
3413 * Pin assignment:
3414 * Speaker-out: 0x14
3415 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003416 * Built-in Mic-In: 0x19
3417 * Line-In: 0x1b
3418 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003419 * SPDIF-Out: 0x1e
3420 */
3421
Takashi Iwaid6815182006-03-23 16:06:23 +01003422static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003423 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003424 .items = {
3425 { "Mic", 0x0 },
3426 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003427 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003428 },
3429};
3430
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003431#define alc880_lg_lw_modes alc880_threestack_modes
3432
Takashi Iwaid6815182006-03-23 16:06:23 +01003433static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003434 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3435 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3436 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3437 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3438 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3439 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3440 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3441 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3442 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3443 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003444 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3445 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3446 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3447 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003448 {
3449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3450 .name = "Channel Mode",
3451 .info = alc_ch_mode_info,
3452 .get = alc_ch_mode_get,
3453 .put = alc_ch_mode_put,
3454 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003455 { } /* end */
3456};
3457
3458static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003459 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3460 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3461 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3462
Takashi Iwaid6815182006-03-23 16:06:23 +01003463 /* set capture source to mic-in */
3464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3466 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003467 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003468 /* speaker-out */
3469 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3470 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3471 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003472 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3473 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 /* mic-in to input */
3475 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3476 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3477 /* built-in mic */
3478 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3479 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003481 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003482 { }
3483};
3484
3485/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003486static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003487{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003488 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003489
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003490 spec->autocfg.hp_pins[0] = 0x1b;
3491 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003492}
3493
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003494static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3495 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3496 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3499 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3500 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3501 { } /* end */
3502};
3503
3504static struct hda_input_mux alc880_medion_rim_capture_source = {
3505 .num_items = 2,
3506 .items = {
3507 { "Mic", 0x0 },
3508 { "Internal Mic", 0x1 },
3509 },
3510};
3511
3512static struct hda_verb alc880_medion_rim_init_verbs[] = {
3513 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3514
3515 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3516 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3517
3518 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3519 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3521 /* Mic2 (as headphone out) for HP output */
3522 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3523 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3524 /* Internal Speaker */
3525 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3526 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3527
3528 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3529 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3530
3531 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3532 { }
3533};
3534
3535/* toggle speaker-output according to the hp-jack state */
3536static void alc880_medion_rim_automute(struct hda_codec *codec)
3537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003538 struct alc_spec *spec = codec->spec;
3539 alc_automute_amp(codec);
3540 /* toggle EAPD */
3541 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003542 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3543 else
3544 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3545}
3546
3547static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3548 unsigned int res)
3549{
3550 /* Looks like the unsol event is incompatible with the standard
3551 * definition. 4bit tag is placed at 28 bit!
3552 */
3553 if ((res >> 28) == ALC880_HP_EVENT)
3554 alc880_medion_rim_automute(codec);
3555}
3556
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003557static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003558{
3559 struct alc_spec *spec = codec->spec;
3560
3561 spec->autocfg.hp_pins[0] = 0x14;
3562 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003563}
3564
Takashi Iwaicb53c622007-08-10 17:21:45 +02003565#ifdef CONFIG_SND_HDA_POWER_SAVE
3566static struct hda_amp_list alc880_loopbacks[] = {
3567 { 0x0b, HDA_INPUT, 0 },
3568 { 0x0b, HDA_INPUT, 1 },
3569 { 0x0b, HDA_INPUT, 2 },
3570 { 0x0b, HDA_INPUT, 3 },
3571 { 0x0b, HDA_INPUT, 4 },
3572 { } /* end */
3573};
3574
3575static struct hda_amp_list alc880_lg_loopbacks[] = {
3576 { 0x0b, HDA_INPUT, 1 },
3577 { 0x0b, HDA_INPUT, 6 },
3578 { 0x0b, HDA_INPUT, 7 },
3579 { } /* end */
3580};
3581#endif
3582
Takashi Iwaid6815182006-03-23 16:06:23 +01003583/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003584 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003585 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003586
Linus Torvalds1da177e2005-04-16 15:20:36 -07003587static int alc_init(struct hda_codec *codec)
3588{
3589 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003590 unsigned int i;
3591
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003592 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003593 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003594
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 for (i = 0; i < spec->num_init_verbs; i++)
3596 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003597
3598 if (spec->init_hook)
3599 spec->init_hook(codec);
3600
Takashi Iwaiad358792010-03-30 18:00:59 +02003601#ifdef CONFIG_SND_HDA_POWER_SAVE
3602 if (codec->patch_ops.check_power_status)
3603 codec->patch_ops.check_power_status(codec, 0x01);
3604#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003605 return 0;
3606}
3607
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003608static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3609{
3610 struct alc_spec *spec = codec->spec;
3611
3612 if (spec->unsol_event)
3613 spec->unsol_event(codec, res);
3614}
3615
Takashi Iwaicb53c622007-08-10 17:21:45 +02003616#ifdef CONFIG_SND_HDA_POWER_SAVE
3617static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3618{
3619 struct alc_spec *spec = codec->spec;
3620 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3621}
3622#endif
3623
Linus Torvalds1da177e2005-04-16 15:20:36 -07003624/*
3625 * Analog playback callbacks
3626 */
3627static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3628 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003629 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003630{
3631 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003632 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3633 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003634}
3635
3636static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3637 struct hda_codec *codec,
3638 unsigned int stream_tag,
3639 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003640 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641{
3642 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003643 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3644 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003645}
3646
3647static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3648 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003649 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003650{
3651 struct alc_spec *spec = codec->spec;
3652 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3653}
3654
3655/*
3656 * Digital out
3657 */
3658static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3659 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003660 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003661{
3662 struct alc_spec *spec = codec->spec;
3663 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3664}
3665
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003666static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3667 struct hda_codec *codec,
3668 unsigned int stream_tag,
3669 unsigned int format,
3670 struct snd_pcm_substream *substream)
3671{
3672 struct alc_spec *spec = codec->spec;
3673 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3674 stream_tag, format, substream);
3675}
3676
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003677static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3678 struct hda_codec *codec,
3679 struct snd_pcm_substream *substream)
3680{
3681 struct alc_spec *spec = codec->spec;
3682 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3683}
3684
Linus Torvalds1da177e2005-04-16 15:20:36 -07003685static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3686 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003687 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003688{
3689 struct alc_spec *spec = codec->spec;
3690 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3691}
3692
3693/*
3694 * Analog capture
3695 */
Takashi Iwai63300792008-01-24 15:31:36 +01003696static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003697 struct hda_codec *codec,
3698 unsigned int stream_tag,
3699 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003700 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701{
3702 struct alc_spec *spec = codec->spec;
3703
Takashi Iwai63300792008-01-24 15:31:36 +01003704 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705 stream_tag, 0, format);
3706 return 0;
3707}
3708
Takashi Iwai63300792008-01-24 15:31:36 +01003709static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003710 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003711 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003712{
3713 struct alc_spec *spec = codec->spec;
3714
Takashi Iwai888afa12008-03-18 09:57:50 +01003715 snd_hda_codec_cleanup_stream(codec,
3716 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717 return 0;
3718}
3719
Takashi Iwai840b64c2010-07-13 22:49:01 +02003720/* analog capture with dynamic dual-adc changes */
3721static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3722 struct hda_codec *codec,
3723 unsigned int stream_tag,
3724 unsigned int format,
3725 struct snd_pcm_substream *substream)
3726{
3727 struct alc_spec *spec = codec->spec;
3728 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3729 spec->cur_adc_stream_tag = stream_tag;
3730 spec->cur_adc_format = format;
3731 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3732 return 0;
3733}
3734
3735static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3736 struct hda_codec *codec,
3737 struct snd_pcm_substream *substream)
3738{
3739 struct alc_spec *spec = codec->spec;
3740 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3741 spec->cur_adc = 0;
3742 return 0;
3743}
3744
3745static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3746 .substreams = 1,
3747 .channels_min = 2,
3748 .channels_max = 2,
3749 .nid = 0, /* fill later */
3750 .ops = {
3751 .prepare = dualmic_capture_pcm_prepare,
3752 .cleanup = dualmic_capture_pcm_cleanup
3753 },
3754};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003755
3756/*
3757 */
3758static struct hda_pcm_stream alc880_pcm_analog_playback = {
3759 .substreams = 1,
3760 .channels_min = 2,
3761 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003762 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003763 .ops = {
3764 .open = alc880_playback_pcm_open,
3765 .prepare = alc880_playback_pcm_prepare,
3766 .cleanup = alc880_playback_pcm_cleanup
3767 },
3768};
3769
3770static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003771 .substreams = 1,
3772 .channels_min = 2,
3773 .channels_max = 2,
3774 /* NID is set in alc_build_pcms */
3775};
3776
3777static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3778 .substreams = 1,
3779 .channels_min = 2,
3780 .channels_max = 2,
3781 /* NID is set in alc_build_pcms */
3782};
3783
3784static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3785 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003786 .channels_min = 2,
3787 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003788 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003789 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003790 .prepare = alc880_alt_capture_pcm_prepare,
3791 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003792 },
3793};
3794
3795static struct hda_pcm_stream alc880_pcm_digital_playback = {
3796 .substreams = 1,
3797 .channels_min = 2,
3798 .channels_max = 2,
3799 /* NID is set in alc_build_pcms */
3800 .ops = {
3801 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003802 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003803 .prepare = alc880_dig_playback_pcm_prepare,
3804 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003805 },
3806};
3807
3808static struct hda_pcm_stream alc880_pcm_digital_capture = {
3809 .substreams = 1,
3810 .channels_min = 2,
3811 .channels_max = 2,
3812 /* NID is set in alc_build_pcms */
3813};
3814
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003815/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003816static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003817 .substreams = 0,
3818 .channels_min = 0,
3819 .channels_max = 0,
3820};
3821
Linus Torvalds1da177e2005-04-16 15:20:36 -07003822static int alc_build_pcms(struct hda_codec *codec)
3823{
3824 struct alc_spec *spec = codec->spec;
3825 struct hda_pcm *info = spec->pcm_rec;
3826 int i;
3827
3828 codec->num_pcms = 1;
3829 codec->pcm_info = info;
3830
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003831 if (spec->no_analog)
3832 goto skip_analog;
3833
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003834 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3835 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003836 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003837
Takashi Iwai4a471b72005-12-07 13:56:29 +01003838 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003839 if (snd_BUG_ON(!spec->multiout.dac_nids))
3840 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003841 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3842 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3843 }
3844 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003845 if (snd_BUG_ON(!spec->adc_nids))
3846 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003847 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3848 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3849 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003850
Takashi Iwai4a471b72005-12-07 13:56:29 +01003851 if (spec->channel_mode) {
3852 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3853 for (i = 0; i < spec->num_channel_mode; i++) {
3854 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3855 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3856 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003857 }
3858 }
3859
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003860 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003861 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003862 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003863 snprintf(spec->stream_name_digital,
3864 sizeof(spec->stream_name_digital),
3865 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003866 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003867 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003868 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003869 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003870 if (spec->dig_out_type)
3871 info->pcm_type = spec->dig_out_type;
3872 else
3873 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003874 if (spec->multiout.dig_out_nid &&
3875 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003876 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3877 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3878 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003879 if (spec->dig_in_nid &&
3880 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003881 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3882 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3883 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003884 /* FIXME: do we need this for all Realtek codec models? */
3885 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886 }
3887
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003888 if (spec->no_analog)
3889 return 0;
3890
Takashi Iwaie08a0072006-09-07 17:52:14 +02003891 /* If the use of more than one ADC is requested for the current
3892 * model, configure a second analog capture-only PCM.
3893 */
3894 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003895 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3896 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003897 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003898 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003899 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003900 if (spec->alt_dac_nid) {
3901 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3902 *spec->stream_analog_alt_playback;
3903 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3904 spec->alt_dac_nid;
3905 } else {
3906 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3907 alc_pcm_null_stream;
3908 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3909 }
3910 if (spec->num_adc_nids > 1) {
3911 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3912 *spec->stream_analog_alt_capture;
3913 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3914 spec->adc_nids[1];
3915 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3916 spec->num_adc_nids - 1;
3917 } else {
3918 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3919 alc_pcm_null_stream;
3920 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003921 }
3922 }
3923
Linus Torvalds1da177e2005-04-16 15:20:36 -07003924 return 0;
3925}
3926
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003927static inline void alc_shutup(struct hda_codec *codec)
3928{
3929 snd_hda_shutup_pins(codec);
3930}
3931
Takashi Iwai603c4012008-07-30 15:01:44 +02003932static void alc_free_kctls(struct hda_codec *codec)
3933{
3934 struct alc_spec *spec = codec->spec;
3935
3936 if (spec->kctls.list) {
3937 struct snd_kcontrol_new *kctl = spec->kctls.list;
3938 int i;
3939 for (i = 0; i < spec->kctls.used; i++)
3940 kfree(kctl[i].name);
3941 }
3942 snd_array_free(&spec->kctls);
3943}
3944
Linus Torvalds1da177e2005-04-16 15:20:36 -07003945static void alc_free(struct hda_codec *codec)
3946{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003947 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003948
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003949 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003950 return;
3951
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003952 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003953 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003954 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003955 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003956}
3957
Hector Martinf5de24b2009-12-20 22:51:31 +01003958#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003959static void alc_power_eapd(struct hda_codec *codec)
3960{
3961 /* We currently only handle front, HP */
3962 switch (codec->vendor_id) {
3963 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003964 set_eapd(codec, 0x0f, 0);
3965 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003966 break;
3967 case 0x10ec0262:
3968 case 0x10ec0267:
3969 case 0x10ec0268:
3970 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003971 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003972 case 0x10ec0272:
3973 case 0x10ec0660:
3974 case 0x10ec0662:
3975 case 0x10ec0663:
3976 case 0x10ec0862:
3977 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003978 set_eapd(codec, 0x14, 0);
3979 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003980 break;
3981 }
3982}
3983
Hector Martinf5de24b2009-12-20 22:51:31 +01003984static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3985{
3986 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003987 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003988 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003989 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003990 return 0;
3991}
3992#endif
3993
Takashi Iwaie044c392008-10-27 16:56:24 +01003994#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003995static int alc_resume(struct hda_codec *codec)
3996{
Takashi Iwaie044c392008-10-27 16:56:24 +01003997 codec->patch_ops.init(codec);
3998 snd_hda_codec_resume_amp(codec);
3999 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02004000#ifdef CONFIG_SND_HDA_POWER_SAVE
4001 if (codec->patch_ops.check_power_status)
4002 codec->patch_ops.check_power_status(codec, 0x01);
4003#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01004004 return 0;
4005}
Takashi Iwaie044c392008-10-27 16:56:24 +01004006#endif
4007
Linus Torvalds1da177e2005-04-16 15:20:36 -07004008/*
4009 */
4010static struct hda_codec_ops alc_patch_ops = {
4011 .build_controls = alc_build_controls,
4012 .build_pcms = alc_build_pcms,
4013 .init = alc_init,
4014 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004015 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004016#ifdef SND_HDA_NEEDS_RESUME
4017 .resume = alc_resume,
4018#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004019#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004020 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004021 .check_power_status = alc_check_power_status,
4022#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004023 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004024};
4025
Kailang Yangc027ddc2010-03-19 11:33:06 +01004026/* replace the codec chip_name with the given string */
4027static int alc_codec_rename(struct hda_codec *codec, const char *name)
4028{
4029 kfree(codec->chip_name);
4030 codec->chip_name = kstrdup(name, GFP_KERNEL);
4031 if (!codec->chip_name) {
4032 alc_free(codec);
4033 return -ENOMEM;
4034 }
4035 return 0;
4036}
4037
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004038/*
4039 * Test configuration for debugging
4040 *
4041 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4042 * enum controls.
4043 */
4044#ifdef CONFIG_SND_DEBUG
4045static hda_nid_t alc880_test_dac_nids[4] = {
4046 0x02, 0x03, 0x04, 0x05
4047};
4048
4049static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004050 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004051 .items = {
4052 { "In-1", 0x0 },
4053 { "In-2", 0x1 },
4054 { "In-3", 0x2 },
4055 { "In-4", 0x3 },
4056 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004057 { "Front", 0x5 },
4058 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004059 },
4060};
4061
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004062static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004063 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004064 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004065 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004066 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004067};
4068
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004069static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4070 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004071{
4072 static char *texts[] = {
4073 "N/A", "Line Out", "HP Out",
4074 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4075 };
4076 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4077 uinfo->count = 1;
4078 uinfo->value.enumerated.items = 8;
4079 if (uinfo->value.enumerated.item >= 8)
4080 uinfo->value.enumerated.item = 7;
4081 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4082 return 0;
4083}
4084
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004085static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4086 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004087{
4088 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4089 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4090 unsigned int pin_ctl, item = 0;
4091
4092 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4093 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4094 if (pin_ctl & AC_PINCTL_OUT_EN) {
4095 if (pin_ctl & AC_PINCTL_HP_EN)
4096 item = 2;
4097 else
4098 item = 1;
4099 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4100 switch (pin_ctl & AC_PINCTL_VREFEN) {
4101 case AC_PINCTL_VREF_HIZ: item = 3; break;
4102 case AC_PINCTL_VREF_50: item = 4; break;
4103 case AC_PINCTL_VREF_GRD: item = 5; break;
4104 case AC_PINCTL_VREF_80: item = 6; break;
4105 case AC_PINCTL_VREF_100: item = 7; break;
4106 }
4107 }
4108 ucontrol->value.enumerated.item[0] = item;
4109 return 0;
4110}
4111
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004112static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4113 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004114{
4115 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4116 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4117 static unsigned int ctls[] = {
4118 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4119 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4120 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4121 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4122 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4123 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4124 };
4125 unsigned int old_ctl, new_ctl;
4126
4127 old_ctl = snd_hda_codec_read(codec, nid, 0,
4128 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4129 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4130 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004131 int val;
4132 snd_hda_codec_write_cache(codec, nid, 0,
4133 AC_VERB_SET_PIN_WIDGET_CONTROL,
4134 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004135 val = ucontrol->value.enumerated.item[0] >= 3 ?
4136 HDA_AMP_MUTE : 0;
4137 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4138 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004139 return 1;
4140 }
4141 return 0;
4142}
4143
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004144static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4145 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004146{
4147 static char *texts[] = {
4148 "Front", "Surround", "CLFE", "Side"
4149 };
4150 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4151 uinfo->count = 1;
4152 uinfo->value.enumerated.items = 4;
4153 if (uinfo->value.enumerated.item >= 4)
4154 uinfo->value.enumerated.item = 3;
4155 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4156 return 0;
4157}
4158
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004159static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4160 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004161{
4162 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4163 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4164 unsigned int sel;
4165
4166 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4167 ucontrol->value.enumerated.item[0] = sel & 3;
4168 return 0;
4169}
4170
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004171static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4172 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004173{
4174 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4175 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4176 unsigned int sel;
4177
4178 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4179 if (ucontrol->value.enumerated.item[0] != sel) {
4180 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004181 snd_hda_codec_write_cache(codec, nid, 0,
4182 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004183 return 1;
4184 }
4185 return 0;
4186}
4187
4188#define PIN_CTL_TEST(xname,nid) { \
4189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4190 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004191 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004192 .info = alc_test_pin_ctl_info, \
4193 .get = alc_test_pin_ctl_get, \
4194 .put = alc_test_pin_ctl_put, \
4195 .private_value = nid \
4196 }
4197
4198#define PIN_SRC_TEST(xname,nid) { \
4199 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4200 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004201 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004202 .info = alc_test_pin_src_info, \
4203 .get = alc_test_pin_src_get, \
4204 .put = alc_test_pin_src_put, \
4205 .private_value = nid \
4206 }
4207
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004208static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4210 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4211 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4212 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4214 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4215 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4216 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004217 PIN_CTL_TEST("Front Pin Mode", 0x14),
4218 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4219 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4220 PIN_CTL_TEST("Side Pin Mode", 0x17),
4221 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4222 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4223 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4224 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4225 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4226 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4227 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4228 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4229 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4230 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4231 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4232 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4233 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4234 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4235 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4236 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4237 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4238 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004239 {
4240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4241 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004242 .info = alc_ch_mode_info,
4243 .get = alc_ch_mode_get,
4244 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004245 },
4246 { } /* end */
4247};
4248
4249static struct hda_verb alc880_test_init_verbs[] = {
4250 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4253 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4254 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4255 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4258 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004259 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004260 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4261 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4263 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004264 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004265 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4266 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4267 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4268 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004269 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4271 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4272 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4273 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004274 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4276 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004277 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4279 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004280 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004281 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4282 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4283 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4284 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004285 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004287 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004288 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004289 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004290 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004291 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004292 /* Analog input/passthru */
4293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4294 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4295 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4296 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004298 { }
4299};
4300#endif
4301
Linus Torvalds1da177e2005-04-16 15:20:36 -07004302/*
4303 */
4304
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004305static const char *alc880_models[ALC880_MODEL_LAST] = {
4306 [ALC880_3ST] = "3stack",
4307 [ALC880_TCL_S700] = "tcl",
4308 [ALC880_3ST_DIG] = "3stack-digout",
4309 [ALC880_CLEVO] = "clevo",
4310 [ALC880_5ST] = "5stack",
4311 [ALC880_5ST_DIG] = "5stack-digout",
4312 [ALC880_W810] = "w810",
4313 [ALC880_Z71V] = "z71v",
4314 [ALC880_6ST] = "6stack",
4315 [ALC880_6ST_DIG] = "6stack-digout",
4316 [ALC880_ASUS] = "asus",
4317 [ALC880_ASUS_W1V] = "asus-w1v",
4318 [ALC880_ASUS_DIG] = "asus-dig",
4319 [ALC880_ASUS_DIG2] = "asus-dig2",
4320 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004321 [ALC880_UNIWILL_P53] = "uniwill-p53",
4322 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004323 [ALC880_F1734] = "F1734",
4324 [ALC880_LG] = "lg",
4325 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004326 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004328 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004329#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004330 [ALC880_AUTO] = "auto",
4331};
4332
4333static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004334 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004335 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4336 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4337 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4338 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4339 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4340 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4341 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4342 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004343 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4344 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004345 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4346 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4347 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4348 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4349 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4350 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4351 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4352 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4353 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4354 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004355 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004356 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4357 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4358 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004359 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004360 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004361 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4362 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004363 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4364 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004365 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4366 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4367 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4368 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004369 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4370 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004371 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004372 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004373 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004374 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004375 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4376 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004377 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004378 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004379 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004380 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004381 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004382 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004383 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004384 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004385 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004386 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4387 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004388 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004389 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4390 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4391 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4392 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004393 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4394 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004395 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004396 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004397 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4398 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004399 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4400 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4401 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004402 /* default Intel */
4403 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004404 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4405 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004406 {}
4407};
4408
Takashi Iwai16ded522005-06-10 19:58:24 +02004409/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004410 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004411 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004412static struct alc_config_preset alc880_presets[] = {
4413 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004414 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004415 .init_verbs = { alc880_volume_init_verbs,
4416 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004417 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004418 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004419 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4420 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004421 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004422 .input_mux = &alc880_capture_source,
4423 },
4424 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004425 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004426 .init_verbs = { alc880_volume_init_verbs,
4427 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004428 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004429 .dac_nids = alc880_dac_nids,
4430 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004431 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4432 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004433 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004434 .input_mux = &alc880_capture_source,
4435 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004436 [ALC880_TCL_S700] = {
4437 .mixers = { alc880_tcl_s700_mixer },
4438 .init_verbs = { alc880_volume_init_verbs,
4439 alc880_pin_tcl_S700_init_verbs,
4440 alc880_gpio2_init_verbs },
4441 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4442 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004443 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4444 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004445 .hp_nid = 0x03,
4446 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4447 .channel_mode = alc880_2_jack_modes,
4448 .input_mux = &alc880_capture_source,
4449 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004450 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004451 .mixers = { alc880_three_stack_mixer,
4452 alc880_five_stack_mixer},
4453 .init_verbs = { alc880_volume_init_verbs,
4454 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004455 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4456 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004457 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4458 .channel_mode = alc880_fivestack_modes,
4459 .input_mux = &alc880_capture_source,
4460 },
4461 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004462 .mixers = { alc880_three_stack_mixer,
4463 alc880_five_stack_mixer },
4464 .init_verbs = { alc880_volume_init_verbs,
4465 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004466 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4467 .dac_nids = alc880_dac_nids,
4468 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004469 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4470 .channel_mode = alc880_fivestack_modes,
4471 .input_mux = &alc880_capture_source,
4472 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004473 [ALC880_6ST] = {
4474 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004475 .init_verbs = { alc880_volume_init_verbs,
4476 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004477 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4478 .dac_nids = alc880_6st_dac_nids,
4479 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4480 .channel_mode = alc880_sixstack_modes,
4481 .input_mux = &alc880_6stack_capture_source,
4482 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004483 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004485 .init_verbs = { alc880_volume_init_verbs,
4486 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004487 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4488 .dac_nids = alc880_6st_dac_nids,
4489 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004490 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4491 .channel_mode = alc880_sixstack_modes,
4492 .input_mux = &alc880_6stack_capture_source,
4493 },
4494 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004495 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004496 .init_verbs = { alc880_volume_init_verbs,
4497 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004498 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004499 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4500 .dac_nids = alc880_w810_dac_nids,
4501 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004502 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4503 .channel_mode = alc880_w810_modes,
4504 .input_mux = &alc880_capture_source,
4505 },
4506 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004507 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004508 .init_verbs = { alc880_volume_init_verbs,
4509 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004510 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4511 .dac_nids = alc880_z71v_dac_nids,
4512 .dig_out_nid = ALC880_DIGOUT_NID,
4513 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004514 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4515 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004516 .input_mux = &alc880_capture_source,
4517 },
4518 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004519 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004520 .init_verbs = { alc880_volume_init_verbs,
4521 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004522 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4523 .dac_nids = alc880_f1734_dac_nids,
4524 .hp_nid = 0x02,
4525 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4526 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004527 .input_mux = &alc880_f1734_capture_source,
4528 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004529 .setup = alc880_uniwill_p53_setup,
4530 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004531 },
4532 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004534 .init_verbs = { alc880_volume_init_verbs,
4535 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004536 alc880_gpio1_init_verbs },
4537 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4538 .dac_nids = alc880_asus_dac_nids,
4539 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4540 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004541 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004542 .input_mux = &alc880_capture_source,
4543 },
4544 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004545 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004546 .init_verbs = { alc880_volume_init_verbs,
4547 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004548 alc880_gpio1_init_verbs },
4549 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4550 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004551 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004552 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4553 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004554 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004555 .input_mux = &alc880_capture_source,
4556 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004557 [ALC880_ASUS_DIG2] = {
4558 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004559 .init_verbs = { alc880_volume_init_verbs,
4560 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004561 alc880_gpio2_init_verbs }, /* use GPIO2 */
4562 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4563 .dac_nids = alc880_asus_dac_nids,
4564 .dig_out_nid = ALC880_DIGOUT_NID,
4565 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4566 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004567 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004568 .input_mux = &alc880_capture_source,
4569 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004570 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004571 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004572 .init_verbs = { alc880_volume_init_verbs,
4573 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004574 alc880_gpio1_init_verbs },
4575 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4576 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004577 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004578 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4579 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004580 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004581 .input_mux = &alc880_capture_source,
4582 },
4583 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004584 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004585 .init_verbs = { alc880_volume_init_verbs,
4586 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4588 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004589 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4591 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004592 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004593 .input_mux = &alc880_capture_source,
4594 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004595 [ALC880_UNIWILL] = {
4596 .mixers = { alc880_uniwill_mixer },
4597 .init_verbs = { alc880_volume_init_verbs,
4598 alc880_uniwill_init_verbs },
4599 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4600 .dac_nids = alc880_asus_dac_nids,
4601 .dig_out_nid = ALC880_DIGOUT_NID,
4602 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4603 .channel_mode = alc880_threestack_modes,
4604 .need_dac_fix = 1,
4605 .input_mux = &alc880_capture_source,
4606 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004607 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004608 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004609 },
4610 [ALC880_UNIWILL_P53] = {
4611 .mixers = { alc880_uniwill_p53_mixer },
4612 .init_verbs = { alc880_volume_init_verbs,
4613 alc880_uniwill_p53_init_verbs },
4614 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4615 .dac_nids = alc880_asus_dac_nids,
4616 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004617 .channel_mode = alc880_threestack_modes,
4618 .input_mux = &alc880_capture_source,
4619 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004620 .setup = alc880_uniwill_p53_setup,
4621 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004622 },
4623 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004624 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004625 .init_verbs = { alc880_volume_init_verbs,
4626 alc880_uniwill_p53_init_verbs,
4627 alc880_beep_init_verbs },
4628 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4629 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004630 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004631 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4632 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004633 .input_mux = &alc880_capture_source,
4634 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004635 .setup = alc880_uniwill_p53_setup,
4636 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004637 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004638 [ALC880_CLEVO] = {
4639 .mixers = { alc880_three_stack_mixer },
4640 .init_verbs = { alc880_volume_init_verbs,
4641 alc880_pin_clevo_init_verbs },
4642 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4643 .dac_nids = alc880_dac_nids,
4644 .hp_nid = 0x03,
4645 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4646 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004647 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004648 .input_mux = &alc880_capture_source,
4649 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004650 [ALC880_LG] = {
4651 .mixers = { alc880_lg_mixer },
4652 .init_verbs = { alc880_volume_init_verbs,
4653 alc880_lg_init_verbs },
4654 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4655 .dac_nids = alc880_lg_dac_nids,
4656 .dig_out_nid = ALC880_DIGOUT_NID,
4657 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4658 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004659 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004660 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004661 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004662 .setup = alc880_lg_setup,
4663 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004664#ifdef CONFIG_SND_HDA_POWER_SAVE
4665 .loopbacks = alc880_lg_loopbacks,
4666#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004667 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004668 [ALC880_LG_LW] = {
4669 .mixers = { alc880_lg_lw_mixer },
4670 .init_verbs = { alc880_volume_init_verbs,
4671 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004672 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004673 .dac_nids = alc880_dac_nids,
4674 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004675 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4676 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004677 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004678 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004679 .setup = alc880_lg_lw_setup,
4680 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004681 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004682 [ALC880_MEDION_RIM] = {
4683 .mixers = { alc880_medion_rim_mixer },
4684 .init_verbs = { alc880_volume_init_verbs,
4685 alc880_medion_rim_init_verbs,
4686 alc_gpio2_init_verbs },
4687 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4688 .dac_nids = alc880_dac_nids,
4689 .dig_out_nid = ALC880_DIGOUT_NID,
4690 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4691 .channel_mode = alc880_2_jack_modes,
4692 .input_mux = &alc880_medion_rim_capture_source,
4693 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004694 .setup = alc880_medion_rim_setup,
4695 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004696 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004697#ifdef CONFIG_SND_DEBUG
4698 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004699 .mixers = { alc880_test_mixer },
4700 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004701 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4702 .dac_nids = alc880_test_dac_nids,
4703 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004704 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4705 .channel_mode = alc880_test_modes,
4706 .input_mux = &alc880_test_capture_source,
4707 },
4708#endif
4709};
4710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004711/*
4712 * Automatic parse of I/O pins from the BIOS configuration
4713 */
4714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715enum {
4716 ALC_CTL_WIDGET_VOL,
4717 ALC_CTL_WIDGET_MUTE,
4718 ALC_CTL_BIND_MUTE,
4719};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004720static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004721 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4722 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004723 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004724};
4725
4726/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004727static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004728 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004729{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004730 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004731
Takashi Iwai603c4012008-07-30 15:01:44 +02004732 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4733 knew = snd_array_new(&spec->kctls);
4734 if (!knew)
4735 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004736 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004737 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004738 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004739 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004740 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004741 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004742 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004743 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004744 return 0;
4745}
4746
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004747static int add_control_with_pfx(struct alc_spec *spec, int type,
4748 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004749 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004750{
4751 char name[32];
4752 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004753 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004754}
4755
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004756#define add_pb_vol_ctrl(spec, type, pfx, val) \
4757 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4758#define add_pb_sw_ctrl(spec, type, pfx, val) \
4759 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4760#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4761 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4762#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4763 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004764
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004765#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4766#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4767#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4768#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004769#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4770#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4771#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4772#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4773#define ALC880_PIN_CD_NID 0x1c
4774
4775/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004776static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4777 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004778{
4779 hda_nid_t nid;
4780 int assigned[4];
4781 int i, j;
4782
4783 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004784 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004785
4786 /* check the pins hardwired to audio widget */
4787 for (i = 0; i < cfg->line_outs; i++) {
4788 nid = cfg->line_out_pins[i];
4789 if (alc880_is_fixed_pin(nid)) {
4790 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004791 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004792 assigned[idx] = 1;
4793 }
4794 }
4795 /* left pins can be connect to any audio widget */
4796 for (i = 0; i < cfg->line_outs; i++) {
4797 nid = cfg->line_out_pins[i];
4798 if (alc880_is_fixed_pin(nid))
4799 continue;
4800 /* search for an empty channel */
4801 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004802 if (!assigned[j]) {
4803 spec->multiout.dac_nids[i] =
4804 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805 assigned[j] = 1;
4806 break;
4807 }
4808 }
4809 }
4810 spec->multiout.num_dacs = cfg->line_outs;
4811 return 0;
4812}
4813
4814/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004815static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4816 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 static const char *chname[4] = {
4819 "Front", "Surround", NULL /*CLFE*/, "Side"
4820 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004821 hda_nid_t nid;
4822 int i, err;
4823
4824 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004825 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004826 continue;
4827 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4828 if (i == 2) {
4829 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004830 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4831 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004832 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4833 HDA_OUTPUT));
4834 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004836 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4837 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004838 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4839 HDA_OUTPUT));
4840 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004841 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004842 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4843 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004844 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4845 HDA_INPUT));
4846 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004847 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004848 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4849 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004850 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4851 HDA_INPUT));
4852 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004853 return err;
4854 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004855 const char *pfx;
4856 if (cfg->line_outs == 1 &&
4857 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4858 pfx = "Speaker";
4859 else
4860 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004861 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004862 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4863 HDA_OUTPUT));
4864 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004865 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004866 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004867 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4868 HDA_INPUT));
4869 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004870 return err;
4871 }
4872 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 return 0;
4874}
4875
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004876/* add playback controls for speaker and HP outputs */
4877static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4878 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879{
4880 hda_nid_t nid;
4881 int err;
4882
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004883 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884 return 0;
4885
4886 if (alc880_is_fixed_pin(pin)) {
4887 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004888 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004889 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004890 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004891 else
4892 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004893 /* control HP volume/switch on the output mixer amp */
4894 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004895 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004896 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4897 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004898 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004899 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004900 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4901 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004902 return err;
4903 } else if (alc880_is_multi_pin(pin)) {
4904 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004905 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004906 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004907 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4908 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004909 return err;
4910 }
4911 return 0;
4912}
4913
4914/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004915static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004916 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01004917 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004918{
Kailang Yangdf694da2005-12-05 19:42:22 +01004919 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004920
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004921 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004922 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4923 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004924 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004925 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004926 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4927 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004928 return err;
4929 return 0;
4930}
4931
Takashi Iwai05f5f472009-08-25 13:10:18 +02004932static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004933{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004934 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4935 return (pincap & AC_PINCAP_IN) != 0;
4936}
4937
4938/* create playback/capture controls for input pins */
4939static int alc_auto_create_input_ctls(struct hda_codec *codec,
4940 const struct auto_pin_cfg *cfg,
4941 hda_nid_t mixer,
4942 hda_nid_t cap1, hda_nid_t cap2)
4943{
4944 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004945 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004946 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004948 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004949 hda_nid_t pin;
4950
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004951 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004952 if (!alc_is_input_pin(codec, pin))
4953 continue;
4954
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004955 type = cfg->inputs[i].type;
4956 if (i > 0 && type == cfg->inputs[i - 1].type)
4957 type_idx++;
4958 else
4959 type_idx = 0;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004960 if (mixer) {
4961 idx = get_connection_index(codec, mixer, pin);
4962 if (idx >= 0) {
4963 err = new_analog_input(spec, pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004964 auto_pin_cfg_labels[type],
4965 type_idx, idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02004966 if (err < 0)
4967 return err;
4968 }
4969 }
4970
4971 if (!cap1)
4972 continue;
4973 idx = get_connection_index(codec, cap1, pin);
4974 if (idx < 0 && cap2)
4975 idx = get_connection_index(codec, cap2, pin);
4976 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004977 imux->items[imux->num_items].label =
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004978 snd_hda_get_input_pin_label(cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02004979 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004980 imux->num_items++;
4981 }
4982 }
4983 return 0;
4984}
4985
Takashi Iwai05f5f472009-08-25 13:10:18 +02004986static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4987 const struct auto_pin_cfg *cfg)
4988{
4989 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4990}
4991
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004992static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4993 unsigned int pin_type)
4994{
4995 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4996 pin_type);
4997 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004998 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4999 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005000}
5001
Kailang Yangdf694da2005-12-05 19:42:22 +01005002static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5003 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 int dac_idx)
5005{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005006 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005007 /* need the manual connection? */
5008 if (alc880_is_multi_pin(nid)) {
5009 struct alc_spec *spec = codec->spec;
5010 int idx = alc880_multi_pin_idx(nid);
5011 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5012 AC_VERB_SET_CONNECT_SEL,
5013 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5014 }
5015}
5016
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005017static int get_pin_type(int line_out_type)
5018{
5019 if (line_out_type == AUTO_PIN_HP_OUT)
5020 return PIN_HP;
5021 else
5022 return PIN_OUT;
5023}
5024
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005025static void alc880_auto_init_multi_out(struct hda_codec *codec)
5026{
5027 struct alc_spec *spec = codec->spec;
5028 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005029
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030 for (i = 0; i < spec->autocfg.line_outs; i++) {
5031 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005032 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5033 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005034 }
5035}
5036
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005037static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005038{
5039 struct alc_spec *spec = codec->spec;
5040 hda_nid_t pin;
5041
Takashi Iwai82bc9552006-03-21 11:24:42 +01005042 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005043 if (pin) /* connect to front */
5044 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005045 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046 if (pin) /* connect to front */
5047 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5048}
5049
5050static void alc880_auto_init_analog_input(struct hda_codec *codec)
5051{
5052 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005053 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 int i;
5055
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005056 for (i = 0; i < cfg->num_inputs; i++) {
5057 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005058 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005059 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005060 if (nid != ALC880_PIN_CD_NID &&
5061 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005062 snd_hda_codec_write(codec, nid, 0,
5063 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005064 AMP_OUT_MUTE);
5065 }
5066 }
5067}
5068
Takashi Iwai7f311a42010-04-09 17:32:23 +02005069static void alc880_auto_init_input_src(struct hda_codec *codec)
5070{
5071 struct alc_spec *spec = codec->spec;
5072 int c;
5073
5074 for (c = 0; c < spec->num_adc_nids; c++) {
5075 unsigned int mux_idx;
5076 const struct hda_input_mux *imux;
5077 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5078 imux = &spec->input_mux[mux_idx];
5079 if (!imux->num_items && mux_idx > 0)
5080 imux = &spec->input_mux[0];
5081 if (imux)
5082 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5083 AC_VERB_SET_CONNECT_SEL,
5084 imux->items[0].index);
5085 }
5086}
5087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005088/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005089/* return 1 if successful, 0 if the proper config is not found,
5090 * or a negative error code
5091 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092static int alc880_parse_auto_config(struct hda_codec *codec)
5093{
5094 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005095 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005096 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005097
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005098 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5099 alc880_ignore);
5100 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005101 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005102 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005103 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005104
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005105 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5106 if (err < 0)
5107 return err;
5108 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5109 if (err < 0)
5110 return err;
5111 err = alc880_auto_create_extra_out(spec,
5112 spec->autocfg.speaker_pins[0],
5113 "Speaker");
5114 if (err < 0)
5115 return err;
5116 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5117 "Headphone");
5118 if (err < 0)
5119 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005120 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005122 return err;
5123
5124 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5125
Takashi Iwai757899a2010-07-30 10:48:14 +02005126 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005127
Takashi Iwai603c4012008-07-30 15:01:44 +02005128 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005129 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130
Takashi Iwaid88897e2008-10-31 15:01:37 +01005131 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005132
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005133 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005134 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005135
Kailang Yang6227cdc2010-02-25 08:36:52 +01005136 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005137
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005138 return 1;
5139}
5140
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005141/* additional initialization for auto-configuration model */
5142static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005143{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005144 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005145 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005146 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005147 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005148 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005149 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005150 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005151 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005152}
5153
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005154/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5155 * one of two digital mic pins, e.g. on ALC272
5156 */
5157static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005158{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005159 struct alc_spec *spec = codec->spec;
5160 int i;
5161
5162 for (i = 0; i < spec->num_adc_nids; i++) {
5163 hda_nid_t cap = spec->capsrc_nids ?
5164 spec->capsrc_nids[i] : spec->adc_nids[i];
5165 int iidx, eidx;
5166
5167 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5168 if (iidx < 0)
5169 continue;
5170 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5171 if (eidx < 0)
5172 continue;
5173 spec->int_mic.mux_idx = iidx;
5174 spec->ext_mic.mux_idx = eidx;
5175 if (spec->capsrc_nids)
5176 spec->capsrc_nids += i;
5177 spec->adc_nids += i;
5178 spec->num_adc_nids = 1;
5179 return;
5180 }
5181 snd_printd(KERN_INFO "hda_codec: %s: "
5182 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5183 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5184 spec->auto_mic = 0; /* disable auto-mic to be sure */
5185}
5186
Takashi Iwai748cce42010-08-04 07:37:39 +02005187/* select or unmute the given capsrc route */
5188static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5189 int idx)
5190{
5191 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5192 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5193 HDA_AMP_MUTE, 0);
5194 } else {
5195 snd_hda_codec_write_cache(codec, cap, 0,
5196 AC_VERB_SET_CONNECT_SEL, idx);
5197 }
5198}
5199
Takashi Iwai840b64c2010-07-13 22:49:01 +02005200/* set the default connection to that pin */
5201static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5202{
5203 struct alc_spec *spec = codec->spec;
5204 int i;
5205
5206 for (i = 0; i < spec->num_adc_nids; i++) {
5207 hda_nid_t cap = spec->capsrc_nids ?
5208 spec->capsrc_nids[i] : spec->adc_nids[i];
5209 int idx;
5210
5211 idx = get_connection_index(codec, cap, pin);
5212 if (idx < 0)
5213 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005214 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005215 return i; /* return the found index */
5216 }
5217 return -1; /* not found */
5218}
5219
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005220/* choose the ADC/MUX containing the input pin and initialize the setup */
5221static void fixup_single_adc(struct hda_codec *codec)
5222{
5223 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005224 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005225 int i;
5226
5227 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005228 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005229 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005230 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005231 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005232 /* use only this ADC */
5233 if (spec->capsrc_nids)
5234 spec->capsrc_nids += i;
5235 spec->adc_nids += i;
5236 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005237 }
5238}
5239
Takashi Iwai840b64c2010-07-13 22:49:01 +02005240/* initialize dual adcs */
5241static void fixup_dual_adc_switch(struct hda_codec *codec)
5242{
5243 struct alc_spec *spec = codec->spec;
5244 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5245 init_capsrc_for_pin(codec, spec->int_mic.pin);
5246}
5247
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005248static void set_capture_mixer(struct hda_codec *codec)
5249{
5250 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005251 static struct snd_kcontrol_new *caps[2][3] = {
5252 { alc_capture_mixer_nosrc1,
5253 alc_capture_mixer_nosrc2,
5254 alc_capture_mixer_nosrc3 },
5255 { alc_capture_mixer1,
5256 alc_capture_mixer2,
5257 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005258 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005259 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005260 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005261 int num_adcs = spec->num_adc_nids;
5262 if (spec->dual_adc_switch)
5263 fixup_dual_adc_switch(codec);
5264 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005265 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005266 else if (spec->input_mux) {
5267 if (spec->input_mux->num_items > 1)
5268 mux = 1;
5269 else if (spec->input_mux->num_items == 1)
5270 fixup_single_adc(codec);
5271 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005272 if (spec->dual_adc_switch)
5273 num_adcs = 1;
5274 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005275 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005276}
5277
Takashi Iwai66946352010-03-29 17:21:45 +02005278/* fill adc_nids (and capsrc_nids) containing all active input pins */
5279static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5280 int num_nids)
5281{
5282 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005283 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005284 int n;
5285 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5286
5287 for (n = 0; n < num_nids; n++) {
5288 hda_nid_t adc, cap;
5289 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5290 int nconns, i, j;
5291
5292 adc = nids[n];
5293 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5294 continue;
5295 cap = adc;
5296 nconns = snd_hda_get_connections(codec, cap, conn,
5297 ARRAY_SIZE(conn));
5298 if (nconns == 1) {
5299 cap = conn[0];
5300 nconns = snd_hda_get_connections(codec, cap, conn,
5301 ARRAY_SIZE(conn));
5302 }
5303 if (nconns <= 0)
5304 continue;
5305 if (!fallback_adc) {
5306 fallback_adc = adc;
5307 fallback_cap = cap;
5308 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005309 for (i = 0; i < cfg->num_inputs; i++) {
5310 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005311 for (j = 0; j < nconns; j++) {
5312 if (conn[j] == nid)
5313 break;
5314 }
5315 if (j >= nconns)
5316 break;
5317 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005318 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005319 int num_adcs = spec->num_adc_nids;
5320 spec->private_adc_nids[num_adcs] = adc;
5321 spec->private_capsrc_nids[num_adcs] = cap;
5322 spec->num_adc_nids++;
5323 spec->adc_nids = spec->private_adc_nids;
5324 if (adc != cap)
5325 spec->capsrc_nids = spec->private_capsrc_nids;
5326 }
5327 }
5328 if (!spec->num_adc_nids) {
5329 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005330 " using fallback 0x%x\n",
5331 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005332 spec->private_adc_nids[0] = fallback_adc;
5333 spec->adc_nids = spec->private_adc_nids;
5334 if (fallback_adc != fallback_cap) {
5335 spec->private_capsrc_nids[0] = fallback_cap;
5336 spec->capsrc_nids = spec->private_adc_nids;
5337 }
5338 }
5339}
5340
Takashi Iwai67d634c2009-11-16 15:35:59 +01005341#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005342#define set_beep_amp(spec, nid, idx, dir) \
5343 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005344
5345static struct snd_pci_quirk beep_white_list[] = {
5346 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005347 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005348 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005349 {}
5350};
5351
5352static inline int has_cdefine_beep(struct hda_codec *codec)
5353{
5354 struct alc_spec *spec = codec->spec;
5355 const struct snd_pci_quirk *q;
5356 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5357 if (q)
5358 return q->value;
5359 return spec->cdefine.enable_pcbeep;
5360}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005361#else
5362#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005363#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005364#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005365
5366/*
5367 * OK, here we have finally the patch for ALC880
5368 */
5369
Linus Torvalds1da177e2005-04-16 15:20:36 -07005370static int patch_alc880(struct hda_codec *codec)
5371{
5372 struct alc_spec *spec;
5373 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005374 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005375
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005377 if (spec == NULL)
5378 return -ENOMEM;
5379
5380 codec->spec = spec;
5381
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005382 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5383 alc880_models,
5384 alc880_cfg_tbl);
5385 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005386 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5387 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005388 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005389 }
5390
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005391 if (board_config == ALC880_AUTO) {
5392 /* automatic parse from the BIOS config */
5393 err = alc880_parse_auto_config(codec);
5394 if (err < 0) {
5395 alc_free(codec);
5396 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005397 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005398 printk(KERN_INFO
5399 "hda_codec: Cannot set up configuration "
5400 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005401 board_config = ALC880_3ST;
5402 }
5403 }
5404
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005405 err = snd_hda_attach_beep_device(codec, 0x1);
5406 if (err < 0) {
5407 alc_free(codec);
5408 return err;
5409 }
5410
Kailang Yangdf694da2005-12-05 19:42:22 +01005411 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005412 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005413
Linus Torvalds1da177e2005-04-16 15:20:36 -07005414 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5415 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005416 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005417
Linus Torvalds1da177e2005-04-16 15:20:36 -07005418 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5419 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5420
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005421 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005422 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005423 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005424 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005425 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005426 if (wcap != AC_WID_AUD_IN) {
5427 spec->adc_nids = alc880_adc_nids_alt;
5428 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005429 } else {
5430 spec->adc_nids = alc880_adc_nids;
5431 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432 }
5433 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005434 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005435 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005436
Takashi Iwai2134ea42008-01-10 16:53:55 +01005437 spec->vmaster_nid = 0x0c;
5438
Linus Torvalds1da177e2005-04-16 15:20:36 -07005439 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005440 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005441 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005442#ifdef CONFIG_SND_HDA_POWER_SAVE
5443 if (!spec->loopback.amplist)
5444 spec->loopback.amplist = alc880_loopbacks;
5445#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005446
5447 return 0;
5448}
5449
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005450
Linus Torvalds1da177e2005-04-16 15:20:36 -07005451/*
5452 * ALC260 support
5453 */
5454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005455static hda_nid_t alc260_dac_nids[1] = {
5456 /* front */
5457 0x02,
5458};
5459
5460static hda_nid_t alc260_adc_nids[1] = {
5461 /* ADC0 */
5462 0x04,
5463};
5464
Kailang Yangdf694da2005-12-05 19:42:22 +01005465static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005466 /* ADC1 */
5467 0x05,
5468};
5469
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005470/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5471 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5472 */
5473static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005474 /* ADC0, ADC1 */
5475 0x04, 0x05
5476};
5477
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005478#define ALC260_DIGOUT_NID 0x03
5479#define ALC260_DIGIN_NID 0x06
5480
5481static struct hda_input_mux alc260_capture_source = {
5482 .num_items = 4,
5483 .items = {
5484 { "Mic", 0x0 },
5485 { "Front Mic", 0x1 },
5486 { "Line", 0x2 },
5487 { "CD", 0x4 },
5488 },
5489};
5490
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005491/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005492 * headphone jack and the internal CD lines since these are the only pins at
5493 * which audio can appear. For flexibility, also allow the option of
5494 * recording the mixer output on the second ADC (ADC0 doesn't have a
5495 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005496 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005497static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5498 {
5499 .num_items = 3,
5500 .items = {
5501 { "Mic/Line", 0x0 },
5502 { "CD", 0x4 },
5503 { "Headphone", 0x2 },
5504 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005505 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005506 {
5507 .num_items = 4,
5508 .items = {
5509 { "Mic/Line", 0x0 },
5510 { "CD", 0x4 },
5511 { "Headphone", 0x2 },
5512 { "Mixer", 0x5 },
5513 },
5514 },
5515
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005516};
5517
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005518/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5519 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005520 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005521static struct hda_input_mux alc260_acer_capture_sources[2] = {
5522 {
5523 .num_items = 4,
5524 .items = {
5525 { "Mic", 0x0 },
5526 { "Line", 0x2 },
5527 { "CD", 0x4 },
5528 { "Headphone", 0x5 },
5529 },
5530 },
5531 {
5532 .num_items = 5,
5533 .items = {
5534 { "Mic", 0x0 },
5535 { "Line", 0x2 },
5536 { "CD", 0x4 },
5537 { "Headphone", 0x6 },
5538 { "Mixer", 0x5 },
5539 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005540 },
5541};
Michael Schwingencc959482009-02-22 18:58:45 +01005542
5543/* Maxdata Favorit 100XS */
5544static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5545 {
5546 .num_items = 2,
5547 .items = {
5548 { "Line/Mic", 0x0 },
5549 { "CD", 0x4 },
5550 },
5551 },
5552 {
5553 .num_items = 3,
5554 .items = {
5555 { "Line/Mic", 0x0 },
5556 { "CD", 0x4 },
5557 { "Mixer", 0x5 },
5558 },
5559 },
5560};
5561
Linus Torvalds1da177e2005-04-16 15:20:36 -07005562/*
5563 * This is just place-holder, so there's something for alc_build_pcms to look
5564 * at when it calculates the maximum number of channels. ALC260 has no mixer
5565 * element which allows changing the channel mode, so the verb list is
5566 * never used.
5567 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005568static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005569 { 2, NULL },
5570};
5571
Kailang Yangdf694da2005-12-05 19:42:22 +01005572
5573/* Mixer combinations
5574 *
5575 * basic: base_output + input + pc_beep + capture
5576 * HP: base_output + input + capture_alt
5577 * HP_3013: hp_3013 + input + capture
5578 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005579 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005580 */
5581
5582static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005583 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005584 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005585 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5586 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5587 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5588 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5589 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005590};
Kailang Yangdf694da2005-12-05 19:42:22 +01005591
5592static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005593 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5594 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5595 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5596 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5598 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005601 { } /* end */
5602};
5603
Takashi Iwaibec15c32008-01-28 18:16:30 +01005604/* update HP, line and mono out pins according to the master switch */
5605static void alc260_hp_master_update(struct hda_codec *codec,
5606 hda_nid_t hp, hda_nid_t line,
5607 hda_nid_t mono)
5608{
5609 struct alc_spec *spec = codec->spec;
5610 unsigned int val = spec->master_sw ? PIN_HP : 0;
5611 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005612 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005613 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005614 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005615 val);
5616 /* mono (speaker) depending on the HP jack sense */
5617 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005618 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005619 val);
5620}
5621
5622static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5623 struct snd_ctl_elem_value *ucontrol)
5624{
5625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5626 struct alc_spec *spec = codec->spec;
5627 *ucontrol->value.integer.value = spec->master_sw;
5628 return 0;
5629}
5630
5631static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5632 struct snd_ctl_elem_value *ucontrol)
5633{
5634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5635 struct alc_spec *spec = codec->spec;
5636 int val = !!*ucontrol->value.integer.value;
5637 hda_nid_t hp, line, mono;
5638
5639 if (val == spec->master_sw)
5640 return 0;
5641 spec->master_sw = val;
5642 hp = (kcontrol->private_value >> 16) & 0xff;
5643 line = (kcontrol->private_value >> 8) & 0xff;
5644 mono = kcontrol->private_value & 0xff;
5645 alc260_hp_master_update(codec, hp, line, mono);
5646 return 1;
5647}
5648
5649static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5650 {
5651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5652 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005653 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005654 .info = snd_ctl_boolean_mono_info,
5655 .get = alc260_hp_master_sw_get,
5656 .put = alc260_hp_master_sw_put,
5657 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5658 },
5659 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5660 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5661 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5662 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5663 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5664 HDA_OUTPUT),
5665 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5666 { } /* end */
5667};
5668
5669static struct hda_verb alc260_hp_unsol_verbs[] = {
5670 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5671 {},
5672};
5673
5674static void alc260_hp_automute(struct hda_codec *codec)
5675{
5676 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005677
Wu Fengguang864f92b2009-11-18 12:38:02 +08005678 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005679 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5680}
5681
5682static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5683{
5684 if ((res >> 26) == ALC880_HP_EVENT)
5685 alc260_hp_automute(codec);
5686}
5687
Kailang Yangdf694da2005-12-05 19:42:22 +01005688static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005689 {
5690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5691 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005692 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005693 .info = snd_ctl_boolean_mono_info,
5694 .get = alc260_hp_master_sw_get,
5695 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005696 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005697 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005698 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5699 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5700 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5701 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005704 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5705 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005706 { } /* end */
5707};
5708
Kailang Yang3f878302008-08-26 13:02:23 +02005709static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5710 .ops = &snd_hda_bind_vol,
5711 .values = {
5712 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5713 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5714 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5715 0
5716 },
5717};
5718
5719static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5720 .ops = &snd_hda_bind_sw,
5721 .values = {
5722 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5723 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5724 0
5725 },
5726};
5727
5728static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5729 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5730 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5731 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5733 { } /* end */
5734};
5735
Takashi Iwaibec15c32008-01-28 18:16:30 +01005736static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5737 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5738 {},
5739};
5740
5741static void alc260_hp_3013_automute(struct hda_codec *codec)
5742{
5743 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005744
Wu Fengguang864f92b2009-11-18 12:38:02 +08005745 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005746 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005747}
5748
5749static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5750 unsigned int res)
5751{
5752 if ((res >> 26) == ALC880_HP_EVENT)
5753 alc260_hp_3013_automute(codec);
5754}
5755
Kailang Yang3f878302008-08-26 13:02:23 +02005756static void alc260_hp_3012_automute(struct hda_codec *codec)
5757{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005758 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005759
Kailang Yang3f878302008-08-26 13:02:23 +02005760 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5761 bits);
5762 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5763 bits);
5764 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5765 bits);
5766}
5767
5768static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5769 unsigned int res)
5770{
5771 if ((res >> 26) == ALC880_HP_EVENT)
5772 alc260_hp_3012_automute(codec);
5773}
5774
5775/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005776 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5777 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005778static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005779 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005780 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005781 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005782 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5783 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5784 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5785 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005786 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005787 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5788 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005789 { } /* end */
5790};
5791
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005792/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5793 * versions of the ALC260 don't act on requests to enable mic bias from NID
5794 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5795 * datasheet doesn't mention this restriction. At this stage it's not clear
5796 * whether this behaviour is intentional or is a hardware bug in chip
5797 * revisions available in early 2006. Therefore for now allow the
5798 * "Headphone Jack Mode" control to span all choices, but if it turns out
5799 * that the lack of mic bias for this NID is intentional we could change the
5800 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5801 *
5802 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5803 * don't appear to make the mic bias available from the "line" jack, even
5804 * though the NID used for this jack (0x14) can supply it. The theory is
5805 * that perhaps Acer have included blocking capacitors between the ALC260
5806 * and the output jack. If this turns out to be the case for all such
5807 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5808 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005809 *
5810 * The C20x Tablet series have a mono internal speaker which is controlled
5811 * via the chip's Mono sum widget and pin complex, so include the necessary
5812 * controls for such models. On models without a "mono speaker" the control
5813 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005814 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005815static struct snd_kcontrol_new alc260_acer_mixer[] = {
5816 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5817 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005818 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005819 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005820 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005821 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005822 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005823 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5824 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5826 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5827 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5828 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5829 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5830 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005831 { } /* end */
5832};
5833
Michael Schwingencc959482009-02-22 18:58:45 +01005834/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5835 */
5836static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5837 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5838 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5839 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5840 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5841 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5842 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5843 { } /* end */
5844};
5845
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005846/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5847 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5848 */
5849static struct snd_kcontrol_new alc260_will_mixer[] = {
5850 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5851 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5853 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5854 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5855 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5856 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5857 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5858 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5859 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005860 { } /* end */
5861};
5862
5863/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5864 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5865 */
5866static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5867 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5868 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5870 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5871 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5872 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5873 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5874 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5875 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5876 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5877 { } /* end */
5878};
5879
Kailang Yangdf694da2005-12-05 19:42:22 +01005880/*
5881 * initialization verbs
5882 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005883static struct hda_verb alc260_init_verbs[] = {
5884 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005886 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005887 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005888 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005889 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005890 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005891 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005892 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005894 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005895 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005896 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005897 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005898 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005899 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005900 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005901 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5902 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005903 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005904 /* set connection select to line in (default select for this ADC) */
5905 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005906 /* mute capture amp left and right */
5907 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5908 /* set connection select to line in (default select for this ADC) */
5909 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005910 /* set vol=0 Line-Out mixer amp left and right */
5911 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5912 /* unmute pin widget amp left and right (no gain on this amp) */
5913 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5914 /* set vol=0 HP mixer amp left and right */
5915 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5916 /* unmute pin widget amp left and right (no gain on this amp) */
5917 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5918 /* set vol=0 Mono mixer amp left and right */
5919 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5920 /* unmute pin widget amp left and right (no gain on this amp) */
5921 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5922 /* unmute LINE-2 out pin */
5923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005924 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5925 * Line In 2 = 0x03
5926 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005927 /* mute analog inputs */
5928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005933 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005934 /* mute Front out path */
5935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5936 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5937 /* mute Headphone out path */
5938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5940 /* mute Mono out path */
5941 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5942 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005943 { }
5944};
5945
Takashi Iwai474167d2006-05-17 17:17:43 +02005946#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005947static struct hda_verb alc260_hp_init_verbs[] = {
5948 /* Headphone and output */
5949 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5950 /* mono output */
5951 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5952 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5954 /* Mic2 (front panel) pin widget for input and vref at 80% */
5955 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5956 /* Line In pin widget for input */
5957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5958 /* Line-2 pin widget for output */
5959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5960 /* CD pin widget for input */
5961 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5962 /* unmute amp left and right */
5963 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5964 /* set connection select to line in (default select for this ADC) */
5965 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5966 /* unmute Line-Out mixer amp left and right (volume = 0) */
5967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5968 /* mute pin widget amp left and right (no gain on this amp) */
5969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5970 /* unmute HP mixer amp left and right (volume = 0) */
5971 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5972 /* mute pin widget amp left and right (no gain on this amp) */
5973 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005974 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5975 * Line In 2 = 0x03
5976 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005977 /* mute analog inputs */
5978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005983 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5984 /* Unmute Front out path */
5985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5987 /* Unmute Headphone out path */
5988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5990 /* Unmute Mono out path */
5991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5993 { }
5994};
Takashi Iwai474167d2006-05-17 17:17:43 +02005995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005996
5997static struct hda_verb alc260_hp_3013_init_verbs[] = {
5998 /* Line out and output */
5999 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6000 /* mono output */
6001 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6002 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6003 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6004 /* Mic2 (front panel) pin widget for input and vref at 80% */
6005 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6006 /* Line In pin widget for input */
6007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6008 /* Headphone pin widget for output */
6009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6010 /* CD pin widget for input */
6011 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6012 /* unmute amp left and right */
6013 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6014 /* set connection select to line in (default select for this ADC) */
6015 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6016 /* unmute Line-Out mixer amp left and right (volume = 0) */
6017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6018 /* mute pin widget amp left and right (no gain on this amp) */
6019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6020 /* unmute HP mixer amp left and right (volume = 0) */
6021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6022 /* mute pin widget amp left and right (no gain on this amp) */
6023 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006024 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6025 * Line In 2 = 0x03
6026 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006027 /* mute analog inputs */
6028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006033 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6034 /* Unmute Front out path */
6035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6037 /* Unmute Headphone out path */
6038 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6040 /* Unmute Mono out path */
6041 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6042 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6043 { }
6044};
6045
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006046/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006047 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6048 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006049 */
6050static struct hda_verb alc260_fujitsu_init_verbs[] = {
6051 /* Disable all GPIOs */
6052 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6053 /* Internal speaker is connected to headphone pin */
6054 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6055 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006057 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6058 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6059 /* Ensure all other unused pins are disabled and muted. */
6060 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006062 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006063 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006064 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006065 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006068
Jonathan Woithef7ace402006-02-28 11:46:14 +01006069 /* Disable digital (SPDIF) pins */
6070 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6071 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006072
Kailang Yangea1fb292008-08-26 12:58:38 +02006073 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006074 * when acting as an output.
6075 */
6076 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6077
6078 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6080 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6081 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6084 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6085 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6086 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6087 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006088
Jonathan Woithef7ace402006-02-28 11:46:14 +01006089 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6090 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6091 /* Unmute Line1 pin widget output buffer since it starts as an output.
6092 * If the pin mode is changed by the user the pin mode control will
6093 * take care of enabling the pin's input/output buffers as needed.
6094 * Therefore there's no need to enable the input buffer at this
6095 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006096 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006097 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006098 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006099 * mixer ctrl)
6100 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006101 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006102
Jonathan Woithef7ace402006-02-28 11:46:14 +01006103 /* Mute capture amp left and right */
6104 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006105 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006106 * in (on mic1 pin)
6107 */
6108 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006109
Jonathan Woithef7ace402006-02-28 11:46:14 +01006110 /* Do the same for the second ADC: mute capture input amp and
6111 * set ADC connection to line in (on mic1 pin)
6112 */
6113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6114 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006115
Jonathan Woithef7ace402006-02-28 11:46:14 +01006116 /* Mute all inputs to mixer widget (even unconnected ones) */
6117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6123 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006125
6126 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006127};
6128
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006129/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6130 * similar laptops (adapted from Fujitsu init verbs).
6131 */
6132static struct hda_verb alc260_acer_init_verbs[] = {
6133 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6134 * the headphone jack. Turn this on and rely on the standard mute
6135 * methods whenever the user wants to turn these outputs off.
6136 */
6137 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6138 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6139 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6140 /* Internal speaker/Headphone jack is connected to Line-out pin */
6141 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6142 /* Internal microphone/Mic jack is connected to Mic1 pin */
6143 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6144 /* Line In jack is connected to Line1 pin */
6145 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006146 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6147 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006148 /* Ensure all other unused pins are disabled and muted. */
6149 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6150 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006151 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6152 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6155 /* Disable digital (SPDIF) pins */
6156 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6157 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6158
Kailang Yangea1fb292008-08-26 12:58:38 +02006159 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006160 * bus when acting as outputs.
6161 */
6162 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6163 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6164
6165 /* Start with output sum widgets muted and their output gains at min */
6166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6168 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6171 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6174 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006176 /* Unmute Line-out pin widget amp left and right
6177 * (no equiv mixer ctrl)
6178 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006179 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006180 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6181 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006182 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6183 * inputs. If the pin mode is changed by the user the pin mode control
6184 * will take care of enabling the pin's input/output buffers as needed.
6185 * Therefore there's no need to enable the input buffer at this
6186 * stage.
6187 */
6188 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6190
6191 /* Mute capture amp left and right */
6192 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6193 /* Set ADC connection select to match default mixer setting - mic
6194 * (on mic1 pin)
6195 */
6196 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6197
6198 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006199 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006200 */
6201 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006202 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006203
6204 /* Mute all inputs to mixer widget (even unconnected ones) */
6205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6213
6214 { }
6215};
6216
Michael Schwingencc959482009-02-22 18:58:45 +01006217/* Initialisation sequence for Maxdata Favorit 100XS
6218 * (adapted from Acer init verbs).
6219 */
6220static struct hda_verb alc260_favorit100_init_verbs[] = {
6221 /* GPIO 0 enables the output jack.
6222 * Turn this on and rely on the standard mute
6223 * methods whenever the user wants to turn these outputs off.
6224 */
6225 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6226 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6227 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6228 /* Line/Mic input jack is connected to Mic1 pin */
6229 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6230 /* Ensure all other unused pins are disabled and muted. */
6231 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6232 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6233 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6234 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6235 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6236 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6241 /* Disable digital (SPDIF) pins */
6242 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6243 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6244
6245 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6246 * bus when acting as outputs.
6247 */
6248 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6249 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6250
6251 /* Start with output sum widgets muted and their output gains at min */
6252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6258 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6260 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6261
6262 /* Unmute Line-out pin widget amp left and right
6263 * (no equiv mixer ctrl)
6264 */
6265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6266 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6267 * inputs. If the pin mode is changed by the user the pin mode control
6268 * will take care of enabling the pin's input/output buffers as needed.
6269 * Therefore there's no need to enable the input buffer at this
6270 * stage.
6271 */
6272 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6273
6274 /* Mute capture amp left and right */
6275 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6276 /* Set ADC connection select to match default mixer setting - mic
6277 * (on mic1 pin)
6278 */
6279 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6280
6281 /* Do similar with the second ADC: mute capture input amp and
6282 * set ADC connection to mic to match ALSA's default state.
6283 */
6284 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6285 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6286
6287 /* Mute all inputs to mixer widget (even unconnected ones) */
6288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6296
6297 { }
6298};
6299
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006300static struct hda_verb alc260_will_verbs[] = {
6301 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6302 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6303 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6304 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6305 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6306 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6307 {}
6308};
6309
6310static struct hda_verb alc260_replacer_672v_verbs[] = {
6311 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6312 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6313 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6314
6315 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6316 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6317 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6318
6319 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6320 {}
6321};
6322
6323/* toggle speaker-output according to the hp-jack state */
6324static void alc260_replacer_672v_automute(struct hda_codec *codec)
6325{
6326 unsigned int present;
6327
6328 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006329 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006330 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006331 snd_hda_codec_write_cache(codec, 0x01, 0,
6332 AC_VERB_SET_GPIO_DATA, 1);
6333 snd_hda_codec_write_cache(codec, 0x0f, 0,
6334 AC_VERB_SET_PIN_WIDGET_CONTROL,
6335 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006336 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006337 snd_hda_codec_write_cache(codec, 0x01, 0,
6338 AC_VERB_SET_GPIO_DATA, 0);
6339 snd_hda_codec_write_cache(codec, 0x0f, 0,
6340 AC_VERB_SET_PIN_WIDGET_CONTROL,
6341 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006342 }
6343}
6344
6345static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6346 unsigned int res)
6347{
6348 if ((res >> 26) == ALC880_HP_EVENT)
6349 alc260_replacer_672v_automute(codec);
6350}
6351
Kailang Yang3f878302008-08-26 13:02:23 +02006352static struct hda_verb alc260_hp_dc7600_verbs[] = {
6353 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6355 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6356 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6357 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6360 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6361 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6363 {}
6364};
6365
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006366/* Test configuration for debugging, modelled after the ALC880 test
6367 * configuration.
6368 */
6369#ifdef CONFIG_SND_DEBUG
6370static hda_nid_t alc260_test_dac_nids[1] = {
6371 0x02,
6372};
6373static hda_nid_t alc260_test_adc_nids[2] = {
6374 0x04, 0x05,
6375};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006376/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006377 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006378 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006379 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006380static struct hda_input_mux alc260_test_capture_sources[2] = {
6381 {
6382 .num_items = 7,
6383 .items = {
6384 { "MIC1 pin", 0x0 },
6385 { "MIC2 pin", 0x1 },
6386 { "LINE1 pin", 0x2 },
6387 { "LINE2 pin", 0x3 },
6388 { "CD pin", 0x4 },
6389 { "LINE-OUT pin", 0x5 },
6390 { "HP-OUT pin", 0x6 },
6391 },
6392 },
6393 {
6394 .num_items = 8,
6395 .items = {
6396 { "MIC1 pin", 0x0 },
6397 { "MIC2 pin", 0x1 },
6398 { "LINE1 pin", 0x2 },
6399 { "LINE2 pin", 0x3 },
6400 { "CD pin", 0x4 },
6401 { "Mixer", 0x5 },
6402 { "LINE-OUT pin", 0x6 },
6403 { "HP-OUT pin", 0x7 },
6404 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006405 },
6406};
6407static struct snd_kcontrol_new alc260_test_mixer[] = {
6408 /* Output driver widgets */
6409 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6410 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6411 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6412 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6413 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6414 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6415
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006416 /* Modes for retasking pin widgets
6417 * Note: the ALC260 doesn't seem to act on requests to enable mic
6418 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6419 * mention this restriction. At this stage it's not clear whether
6420 * this behaviour is intentional or is a hardware bug in chip
6421 * revisions available at least up until early 2006. Therefore for
6422 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6423 * choices, but if it turns out that the lack of mic bias for these
6424 * NIDs is intentional we could change their modes from
6425 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6426 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006427 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6428 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6429 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6430 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6431 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6432 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6433
6434 /* Loopback mixer controls */
6435 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6436 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6437 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6438 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6439 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6440 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6441 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6442 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6443 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6444 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006445 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6446 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6447 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6448 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006449
6450 /* Controls for GPIO pins, assuming they are configured as outputs */
6451 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6452 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6453 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6454 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6455
Jonathan Woithe92621f12006-02-28 11:47:47 +01006456 /* Switches to allow the digital IO pins to be enabled. The datasheet
6457 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006458 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006459 */
6460 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6461 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6462
Jonathan Woithef8225f62008-01-08 12:16:54 +01006463 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6464 * this output to turn on an external amplifier.
6465 */
6466 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6467 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6468
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006469 { } /* end */
6470};
6471static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006472 /* Enable all GPIOs as outputs with an initial value of 0 */
6473 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6474 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6475 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6476
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006477 /* Enable retasking pins as output, initially without power amp */
6478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6479 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6482 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6483 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6484
Jonathan Woithe92621f12006-02-28 11:47:47 +01006485 /* Disable digital (SPDIF) pins initially, but users can enable
6486 * them via a mixer switch. In the case of SPDIF-out, this initverb
6487 * payload also sets the generation to 0, output to be in "consumer"
6488 * PCM format, copyright asserted, no pre-emphasis and no validity
6489 * control.
6490 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006491 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6492 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6493
Kailang Yangea1fb292008-08-26 12:58:38 +02006494 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006495 * OUT1 sum bus when acting as an output.
6496 */
6497 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6498 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6499 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6500 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6501
6502 /* Start with output sum widgets muted and their output gains at min */
6503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6512
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006513 /* Unmute retasking pin widget output buffers since the default
6514 * state appears to be output. As the pin mode is changed by the
6515 * user the pin mode control will take care of enabling the pin's
6516 * input/output buffers as needed.
6517 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006518 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6521 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6522 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6523 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6524 /* Also unmute the mono-out pin widget */
6525 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6526
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006527 /* Mute capture amp left and right */
6528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006529 /* Set ADC connection select to match default mixer setting (mic1
6530 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006531 */
6532 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6533
6534 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006535 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006536 */
6537 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6538 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6539
6540 /* Mute all inputs to mixer widget (even unconnected ones) */
6541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6549
6550 { }
6551};
6552#endif
6553
Takashi Iwai63300792008-01-24 15:31:36 +01006554#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6555#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006556
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006557#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6558#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6559
Kailang Yangdf694da2005-12-05 19:42:22 +01006560/*
6561 * for BIOS auto-configuration
6562 */
6563
6564static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006565 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006566{
6567 hda_nid_t nid_vol;
6568 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006569 int err;
6570
6571 if (nid >= 0x0f && nid < 0x11) {
6572 nid_vol = nid - 0x7;
6573 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6574 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6575 } else if (nid == 0x11) {
6576 nid_vol = nid - 0x7;
6577 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6578 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6579 } else if (nid >= 0x12 && nid <= 0x15) {
6580 nid_vol = 0x08;
6581 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6582 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6583 } else
6584 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006585
Takashi Iwai863b4512008-10-21 17:01:47 +02006586 if (!(*vol_bits & (1 << nid_vol))) {
6587 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006588 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006589 if (err < 0)
6590 return err;
6591 *vol_bits |= (1 << nid_vol);
6592 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006593 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006594 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006595 return err;
6596 return 1;
6597}
6598
6599/* add playback controls from the parsed DAC table */
6600static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6601 const struct auto_pin_cfg *cfg)
6602{
6603 hda_nid_t nid;
6604 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006605 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006606
6607 spec->multiout.num_dacs = 1;
6608 spec->multiout.dac_nids = spec->private_dac_nids;
6609 spec->multiout.dac_nids[0] = 0x02;
6610
6611 nid = cfg->line_out_pins[0];
6612 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006613 const char *pfx;
6614 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6615 pfx = "Master";
6616 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6617 pfx = "Speaker";
6618 else
6619 pfx = "Front";
6620 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006621 if (err < 0)
6622 return err;
6623 }
6624
Takashi Iwai82bc9552006-03-21 11:24:42 +01006625 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006627 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006628 if (err < 0)
6629 return err;
6630 }
6631
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006632 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006633 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006634 err = alc260_add_playback_controls(spec, nid, "Headphone",
6635 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006636 if (err < 0)
6637 return err;
6638 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006639 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006640}
6641
6642/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006643static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006644 const struct auto_pin_cfg *cfg)
6645{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006646 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006647}
6648
6649static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6650 hda_nid_t nid, int pin_type,
6651 int sel_idx)
6652{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006653 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006654 /* need the manual connection? */
6655 if (nid >= 0x12) {
6656 int idx = nid - 0x12;
6657 snd_hda_codec_write(codec, idx + 0x0b, 0,
6658 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006659 }
6660}
6661
6662static void alc260_auto_init_multi_out(struct hda_codec *codec)
6663{
6664 struct alc_spec *spec = codec->spec;
6665 hda_nid_t nid;
6666
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006667 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006668 if (nid) {
6669 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6670 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6671 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006672
Takashi Iwai82bc9552006-03-21 11:24:42 +01006673 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006674 if (nid)
6675 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6676
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006677 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006678 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006679 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006680}
Kailang Yangdf694da2005-12-05 19:42:22 +01006681
6682#define ALC260_PIN_CD_NID 0x16
6683static void alc260_auto_init_analog_input(struct hda_codec *codec)
6684{
6685 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006686 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006687 int i;
6688
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006689 for (i = 0; i < cfg->num_inputs; i++) {
6690 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006691 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006692 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006693 if (nid != ALC260_PIN_CD_NID &&
6694 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006695 snd_hda_codec_write(codec, nid, 0,
6696 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006697 AMP_OUT_MUTE);
6698 }
6699 }
6700}
6701
Takashi Iwai7f311a42010-04-09 17:32:23 +02006702#define alc260_auto_init_input_src alc880_auto_init_input_src
6703
Kailang Yangdf694da2005-12-05 19:42:22 +01006704/*
6705 * generic initialization of ADC, input mixers and output mixers
6706 */
6707static struct hda_verb alc260_volume_init_verbs[] = {
6708 /*
6709 * Unmute ADC0-1 and set the default input to mic-in
6710 */
6711 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6712 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6713 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6714 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006715
Kailang Yangdf694da2005-12-05 19:42:22 +01006716 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6717 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006718 * Note: PASD motherboards uses the Line In 2 as the input for
6719 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006720 */
6721 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006722 /* mute analog inputs */
6723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006728
6729 /*
6730 * Set up output mixers (0x08 - 0x0a)
6731 */
6732 /* set vol=0 to output mixers */
6733 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6734 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6735 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6736 /* set up input amps for analog loopback */
6737 /* Amp Indices: DAC = 0, mixer = 1 */
6738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6739 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6743 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006744
Kailang Yangdf694da2005-12-05 19:42:22 +01006745 { }
6746};
6747
6748static int alc260_parse_auto_config(struct hda_codec *codec)
6749{
6750 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006751 int err;
6752 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6753
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006754 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6755 alc260_ignore);
6756 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006757 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006758 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6759 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006760 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006761 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006762 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006763 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006764 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006765 return err;
6766
6767 spec->multiout.max_channels = 2;
6768
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006769 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006770 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006771 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006772 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006773
Takashi Iwaid88897e2008-10-31 15:01:37 +01006774 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006775
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006776 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006777 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006778
Kailang Yang6227cdc2010-02-25 08:36:52 +01006779 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006780
Kailang Yangdf694da2005-12-05 19:42:22 +01006781 return 1;
6782}
6783
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006784/* additional initialization for auto-configuration model */
6785static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006786{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006787 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006788 alc260_auto_init_multi_out(codec);
6789 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006790 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006791 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006792 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006793 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006794}
6795
Takashi Iwaicb53c622007-08-10 17:21:45 +02006796#ifdef CONFIG_SND_HDA_POWER_SAVE
6797static struct hda_amp_list alc260_loopbacks[] = {
6798 { 0x07, HDA_INPUT, 0 },
6799 { 0x07, HDA_INPUT, 1 },
6800 { 0x07, HDA_INPUT, 2 },
6801 { 0x07, HDA_INPUT, 3 },
6802 { 0x07, HDA_INPUT, 4 },
6803 { } /* end */
6804};
6805#endif
6806
Kailang Yangdf694da2005-12-05 19:42:22 +01006807/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006808 * Pin config fixes
6809 */
6810enum {
6811 PINFIX_HP_DC5750,
6812};
6813
Takashi Iwaifc091762010-08-04 23:53:36 +02006814static const struct alc_fixup alc260_fixups[] = {
6815 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006816 .pins = (const struct alc_pincfg[]) {
6817 { 0x11, 0x90130110 }, /* speaker */
6818 { }
6819 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006820 },
6821};
6822
6823static struct snd_pci_quirk alc260_fixup_tbl[] = {
6824 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6825 {}
6826};
6827
6828/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006829 * ALC260 configurations
6830 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006831static const char *alc260_models[ALC260_MODEL_LAST] = {
6832 [ALC260_BASIC] = "basic",
6833 [ALC260_HP] = "hp",
6834 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006835 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006836 [ALC260_FUJITSU_S702X] = "fujitsu",
6837 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006838 [ALC260_WILL] = "will",
6839 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006840 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006841#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006842 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006843#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006844 [ALC260_AUTO] = "auto",
6845};
6846
6847static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006848 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006849 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006850 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006851 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006852 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006853 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006854 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006855 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006856 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006857 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6858 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6859 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6860 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6861 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6862 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6863 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6864 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6865 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006866 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006867 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006868 {}
6869};
6870
Kailang Yangdf694da2005-12-05 19:42:22 +01006871static struct alc_config_preset alc260_presets[] = {
6872 [ALC260_BASIC] = {
6873 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006874 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006875 .init_verbs = { alc260_init_verbs },
6876 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6877 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006878 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006879 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006880 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6881 .channel_mode = alc260_modes,
6882 .input_mux = &alc260_capture_source,
6883 },
6884 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006885 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006886 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006887 .init_verbs = { alc260_init_verbs,
6888 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006889 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6890 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006891 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6892 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006893 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6894 .channel_mode = alc260_modes,
6895 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006896 .unsol_event = alc260_hp_unsol_event,
6897 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006898 },
Kailang Yang3f878302008-08-26 13:02:23 +02006899 [ALC260_HP_DC7600] = {
6900 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006901 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006902 .init_verbs = { alc260_init_verbs,
6903 alc260_hp_dc7600_verbs },
6904 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6905 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006906 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6907 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006908 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6909 .channel_mode = alc260_modes,
6910 .input_mux = &alc260_capture_source,
6911 .unsol_event = alc260_hp_3012_unsol_event,
6912 .init_hook = alc260_hp_3012_automute,
6913 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 [ALC260_HP_3013] = {
6915 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006916 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006917 .init_verbs = { alc260_hp_3013_init_verbs,
6918 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6920 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006921 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6922 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006923 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6924 .channel_mode = alc260_modes,
6925 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006926 .unsol_event = alc260_hp_3013_unsol_event,
6927 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006928 },
6929 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006930 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006931 .init_verbs = { alc260_fujitsu_init_verbs },
6932 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6933 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006934 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6935 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006936 .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_fujitsu_capture_sources),
6939 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006940 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006941 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006942 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006943 .init_verbs = { alc260_acer_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,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006950 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6951 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006952 },
Michael Schwingencc959482009-02-22 18:58:45 +01006953 [ALC260_FAVORIT100] = {
6954 .mixers = { alc260_favorit100_mixer },
6955 .init_verbs = { alc260_favorit100_init_verbs },
6956 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6957 .dac_nids = alc260_dac_nids,
6958 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6959 .adc_nids = alc260_dual_adc_nids,
6960 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6961 .channel_mode = alc260_modes,
6962 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6963 .input_mux = alc260_favorit100_capture_sources,
6964 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006965 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006966 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006967 .init_verbs = { alc260_init_verbs, alc260_will_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 },
6977 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006978 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006979 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6980 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6981 .dac_nids = alc260_dac_nids,
6982 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6983 .adc_nids = alc260_adc_nids,
6984 .dig_out_nid = ALC260_DIGOUT_NID,
6985 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6986 .channel_mode = alc260_modes,
6987 .input_mux = &alc260_capture_source,
6988 .unsol_event = alc260_replacer_672v_unsol_event,
6989 .init_hook = alc260_replacer_672v_automute,
6990 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006991#ifdef CONFIG_SND_DEBUG
6992 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006993 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006994 .init_verbs = { alc260_test_init_verbs },
6995 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6996 .dac_nids = alc260_test_dac_nids,
6997 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6998 .adc_nids = alc260_test_adc_nids,
6999 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7000 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007001 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7002 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007003 },
7004#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007005};
7006
Linus Torvalds1da177e2005-04-16 15:20:36 -07007007static int patch_alc260(struct hda_codec *codec)
7008{
7009 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007010 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007011
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007012 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007013 if (spec == NULL)
7014 return -ENOMEM;
7015
7016 codec->spec = spec;
7017
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007018 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7019 alc260_models,
7020 alc260_cfg_tbl);
7021 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007022 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007023 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007024 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007025 }
7026
Takashi Iwaifc091762010-08-04 23:53:36 +02007027 if (board_config == ALC260_AUTO)
7028 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7029
Kailang Yangdf694da2005-12-05 19:42:22 +01007030 if (board_config == ALC260_AUTO) {
7031 /* automatic parse from the BIOS config */
7032 err = alc260_parse_auto_config(codec);
7033 if (err < 0) {
7034 alc_free(codec);
7035 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007036 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007037 printk(KERN_INFO
7038 "hda_codec: Cannot set up configuration "
7039 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007040 board_config = ALC260_BASIC;
7041 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007042 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007043
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007044 err = snd_hda_attach_beep_device(codec, 0x1);
7045 if (err < 0) {
7046 alc_free(codec);
7047 return err;
7048 }
7049
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007051 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007052
Linus Torvalds1da177e2005-04-16 15:20:36 -07007053 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7054 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307055 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007056
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007057 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7058 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7059
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007060 if (!spec->adc_nids && spec->input_mux) {
7061 /* check whether NID 0x04 is valid */
7062 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007063 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007064 /* get type */
7065 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7066 spec->adc_nids = alc260_adc_nids_alt;
7067 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7068 } else {
7069 spec->adc_nids = alc260_adc_nids;
7070 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7071 }
7072 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007073 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007074 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007075
Takashi Iwaifc091762010-08-04 23:53:36 +02007076 if (board_config == ALC260_AUTO)
7077 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7078
Takashi Iwai2134ea42008-01-10 16:53:55 +01007079 spec->vmaster_nid = 0x08;
7080
Linus Torvalds1da177e2005-04-16 15:20:36 -07007081 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007082 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007083 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007084#ifdef CONFIG_SND_HDA_POWER_SAVE
7085 if (!spec->loopback.amplist)
7086 spec->loopback.amplist = alc260_loopbacks;
7087#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007088
7089 return 0;
7090}
7091
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007092
Linus Torvalds1da177e2005-04-16 15:20:36 -07007093/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007094 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007095 *
7096 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7097 * configuration. Each pin widget can choose any input DACs and a mixer.
7098 * Each ADC is connected from a mixer of all inputs. This makes possible
7099 * 6-channel independent captures.
7100 *
7101 * In addition, an independent DAC for the multi-playback (not used in this
7102 * driver yet).
7103 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007104#define ALC882_DIGOUT_NID 0x06
7105#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007106#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7107#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7108#define ALC1200_DIGOUT_NID 0x10
7109
Linus Torvalds1da177e2005-04-16 15:20:36 -07007110
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007111static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007112 { 8, NULL }
7113};
7114
Takashi Iwai4953550a2009-06-30 15:28:30 +02007115/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007116static hda_nid_t alc882_dac_nids[4] = {
7117 /* front, rear, clfe, rear_surr */
7118 0x02, 0x03, 0x04, 0x05
7119};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007120#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007121
Takashi Iwai4953550a2009-06-30 15:28:30 +02007122/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007123#define alc882_adc_nids alc880_adc_nids
7124#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007125#define alc883_adc_nids alc882_adc_nids_alt
7126static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7127static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7128#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007129
Takashi Iwaie1406342008-02-11 18:32:32 +01007130static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7131static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007132#define alc883_capsrc_nids alc882_capsrc_nids_alt
7133static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7134#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007135
Linus Torvalds1da177e2005-04-16 15:20:36 -07007136/* input MUX */
7137/* FIXME: should be a matrix-type input source selection */
7138
7139static struct hda_input_mux alc882_capture_source = {
7140 .num_items = 4,
7141 .items = {
7142 { "Mic", 0x0 },
7143 { "Front Mic", 0x1 },
7144 { "Line", 0x2 },
7145 { "CD", 0x4 },
7146 },
7147};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007148
Takashi Iwai4953550a2009-06-30 15:28:30 +02007149#define alc883_capture_source alc882_capture_source
7150
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007151static struct hda_input_mux alc889_capture_source = {
7152 .num_items = 3,
7153 .items = {
7154 { "Front Mic", 0x0 },
7155 { "Mic", 0x3 },
7156 { "Line", 0x2 },
7157 },
7158};
7159
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007160static struct hda_input_mux mb5_capture_source = {
7161 .num_items = 3,
7162 .items = {
7163 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307164 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007165 { "CD", 0x4 },
7166 },
7167};
7168
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007169static struct hda_input_mux macmini3_capture_source = {
7170 .num_items = 2,
7171 .items = {
7172 { "Line", 0x2 },
7173 { "CD", 0x4 },
7174 },
7175};
7176
Takashi Iwai4953550a2009-06-30 15:28:30 +02007177static struct hda_input_mux alc883_3stack_6ch_intel = {
7178 .num_items = 4,
7179 .items = {
7180 { "Mic", 0x1 },
7181 { "Front Mic", 0x0 },
7182 { "Line", 0x2 },
7183 { "CD", 0x4 },
7184 },
7185};
7186
7187static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7188 .num_items = 2,
7189 .items = {
7190 { "Mic", 0x1 },
7191 { "Line", 0x2 },
7192 },
7193};
7194
7195static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7196 .num_items = 4,
7197 .items = {
7198 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007199 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007200 { "Line", 0x2 },
7201 { "CD", 0x4 },
7202 },
7203};
7204
7205static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7206 .num_items = 2,
7207 .items = {
7208 { "Mic", 0x0 },
7209 { "Int Mic", 0x1 },
7210 },
7211};
7212
7213static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7214 .num_items = 3,
7215 .items = {
7216 { "Mic", 0x0 },
7217 { "Front Mic", 0x1 },
7218 { "Line", 0x4 },
7219 },
7220};
7221
7222static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7223 .num_items = 2,
7224 .items = {
7225 { "Mic", 0x0 },
7226 { "Line", 0x2 },
7227 },
7228};
7229
7230static struct hda_input_mux alc889A_mb31_capture_source = {
7231 .num_items = 2,
7232 .items = {
7233 { "Mic", 0x0 },
7234 /* Front Mic (0x01) unused */
7235 { "Line", 0x2 },
7236 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007237 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007238 },
7239};
7240
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007241static struct hda_input_mux alc889A_imac91_capture_source = {
7242 .num_items = 2,
7243 .items = {
7244 { "Mic", 0x01 },
7245 { "Line", 0x2 }, /* Not sure! */
7246 },
7247};
7248
Takashi Iwai4953550a2009-06-30 15:28:30 +02007249/*
7250 * 2ch mode
7251 */
7252static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7253 { 2, NULL }
7254};
7255
Kailang Yangdf694da2005-12-05 19:42:22 +01007256/*
Kailang Yang272a5272007-05-14 11:00:38 +02007257 * 2ch mode
7258 */
7259static struct hda_verb alc882_3ST_ch2_init[] = {
7260 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7261 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7262 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7263 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7264 { } /* end */
7265};
7266
7267/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007268 * 4ch mode
7269 */
7270static struct hda_verb alc882_3ST_ch4_init[] = {
7271 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7272 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7273 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7274 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7275 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7276 { } /* end */
7277};
7278
7279/*
Kailang Yang272a5272007-05-14 11:00:38 +02007280 * 6ch mode
7281 */
7282static struct hda_verb alc882_3ST_ch6_init[] = {
7283 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7284 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7285 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7286 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7287 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7288 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7289 { } /* end */
7290};
7291
Takashi Iwai4953550a2009-06-30 15:28:30 +02007292static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007293 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007294 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007295 { 6, alc882_3ST_ch6_init },
7296};
7297
Takashi Iwai4953550a2009-06-30 15:28:30 +02007298#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7299
Kailang Yang272a5272007-05-14 11:00:38 +02007300/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307301 * 2ch mode
7302 */
7303static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7304 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
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_IN },
7308 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7309 { } /* end */
7310};
7311
7312/*
7313 * 4ch mode
7314 */
7315static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7316 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7317 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7318 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7319 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7320 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7321 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7322 { } /* end */
7323};
7324
7325/*
7326 * 6ch mode
7327 */
7328static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7329 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7330 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7331 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7332 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7333 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7334 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7335 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7336 { } /* end */
7337};
7338
7339static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7340 { 2, alc883_3ST_ch2_clevo_init },
7341 { 4, alc883_3ST_ch4_clevo_init },
7342 { 6, alc883_3ST_ch6_clevo_init },
7343};
7344
7345
7346/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007347 * 6ch mode
7348 */
7349static struct hda_verb alc882_sixstack_ch6_init[] = {
7350 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7351 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7352 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7353 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7354 { } /* end */
7355};
7356
7357/*
7358 * 8ch mode
7359 */
7360static struct hda_verb alc882_sixstack_ch8_init[] = {
7361 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7362 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7363 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7364 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7365 { } /* end */
7366};
7367
7368static struct hda_channel_mode alc882_sixstack_modes[2] = {
7369 { 6, alc882_sixstack_ch6_init },
7370 { 8, alc882_sixstack_ch8_init },
7371};
7372
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007373
7374/* Macbook Air 2,1 */
7375
7376static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7377 { 2, NULL },
7378};
7379
Takashi Iwai87350ad2007-08-16 18:19:38 +02007380/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007381 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007382 */
7383
7384/*
7385 * 2ch mode
7386 */
7387static struct hda_verb alc885_mbp_ch2_init[] = {
7388 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7389 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7391 { } /* end */
7392};
7393
7394/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007395 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007396 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007397static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007398 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7399 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7400 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7401 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7402 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7403 { } /* end */
7404};
7405
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007406static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007407 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007408 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007409};
7410
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007411/*
7412 * 2ch
7413 * Speakers/Woofer/HP = Front
7414 * LineIn = Input
7415 */
7416static struct hda_verb alc885_mb5_ch2_init[] = {
7417 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7418 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7419 { } /* end */
7420};
7421
7422/*
7423 * 6ch mode
7424 * Speakers/HP = Front
7425 * Woofer = LFE
7426 * LineIn = Surround
7427 */
7428static struct hda_verb alc885_mb5_ch6_init[] = {
7429 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7430 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7431 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7432 { } /* end */
7433};
7434
7435static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7436 { 2, alc885_mb5_ch2_init },
7437 { 6, alc885_mb5_ch6_init },
7438};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007439
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007440#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007441
7442/*
7443 * 2ch mode
7444 */
7445static struct hda_verb alc883_4ST_ch2_init[] = {
7446 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7447 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7448 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7449 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7450 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7451 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7452 { } /* end */
7453};
7454
7455/*
7456 * 4ch mode
7457 */
7458static struct hda_verb alc883_4ST_ch4_init[] = {
7459 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7460 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7461 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7462 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7463 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7464 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7465 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7466 { } /* end */
7467};
7468
7469/*
7470 * 6ch mode
7471 */
7472static struct hda_verb alc883_4ST_ch6_init[] = {
7473 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7474 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7477 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7478 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7479 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7480 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7481 { } /* end */
7482};
7483
7484/*
7485 * 8ch mode
7486 */
7487static struct hda_verb alc883_4ST_ch8_init[] = {
7488 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7489 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7490 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7491 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7492 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7493 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7494 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7495 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7496 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7497 { } /* end */
7498};
7499
7500static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7501 { 2, alc883_4ST_ch2_init },
7502 { 4, alc883_4ST_ch4_init },
7503 { 6, alc883_4ST_ch6_init },
7504 { 8, alc883_4ST_ch8_init },
7505};
7506
7507
7508/*
7509 * 2ch mode
7510 */
7511static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7512 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7513 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7514 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7515 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7516 { } /* end */
7517};
7518
7519/*
7520 * 4ch mode
7521 */
7522static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7523 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7524 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7525 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7526 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7527 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7528 { } /* end */
7529};
7530
7531/*
7532 * 6ch mode
7533 */
7534static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7535 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7536 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7537 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7538 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7539 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7540 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7541 { } /* end */
7542};
7543
7544static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7545 { 2, alc883_3ST_ch2_intel_init },
7546 { 4, alc883_3ST_ch4_intel_init },
7547 { 6, alc883_3ST_ch6_intel_init },
7548};
7549
7550/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007551 * 2ch mode
7552 */
7553static struct hda_verb alc889_ch2_intel_init[] = {
7554 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7555 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7556 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7557 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7558 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7559 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7560 { } /* end */
7561};
7562
7563/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007564 * 6ch mode
7565 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007566static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007567 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7568 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7569 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7570 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7571 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007572 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7573 { } /* end */
7574};
7575
7576/*
7577 * 8ch mode
7578 */
7579static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007580 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7581 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7582 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7583 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7584 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007585 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7586 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007587 { } /* end */
7588};
7589
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007590static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7591 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007592 { 6, alc889_ch6_intel_init },
7593 { 8, alc889_ch8_intel_init },
7594};
7595
7596/*
7597 * 6ch mode
7598 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007599static struct hda_verb alc883_sixstack_ch6_init[] = {
7600 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7601 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { } /* end */
7605};
7606
7607/*
7608 * 8ch mode
7609 */
7610static struct hda_verb alc883_sixstack_ch8_init[] = {
7611 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7612 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7613 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7614 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7615 { } /* end */
7616};
7617
7618static struct hda_channel_mode alc883_sixstack_modes[2] = {
7619 { 6, alc883_sixstack_ch6_init },
7620 { 8, alc883_sixstack_ch8_init },
7621};
7622
7623
Linus Torvalds1da177e2005-04-16 15:20:36 -07007624/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7625 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7626 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007627static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007628 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007629 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007630 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007631 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007632 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7633 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007634 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7635 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007636 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007637 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7639 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7640 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7641 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7642 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7643 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007644 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007645 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7646 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007647 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007648 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007649 { } /* end */
7650};
7651
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007652/* Macbook Air 2,1 same control for HP and internal Speaker */
7653
7654static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7655 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7656 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7657 { }
7658};
7659
7660
Takashi Iwai87350ad2007-08-16 18:19:38 +02007661static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007662 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7663 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7664 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7665 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7666 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007667 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7668 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7670 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007671 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007672 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7673 { } /* end */
7674};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007675
7676static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007677 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7678 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7679 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7680 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7681 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7682 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307683 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7684 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7686 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7688 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7689 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7690 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7691 { } /* end */
7692};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007693
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007694static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7695 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7696 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7697 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7698 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7699 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7700 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7702 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7703 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7704 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7705 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7706 { } /* end */
7707};
7708
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007709static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007710 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7711 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007712 { } /* end */
7713};
7714
7715
Kailang Yangbdd148a2007-05-08 15:19:08 +02007716static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7717 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7718 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7719 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7720 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7721 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7722 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7723 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007726 { } /* end */
7727};
7728
Kailang Yang272a5272007-05-14 11:00:38 +02007729static struct snd_kcontrol_new alc882_targa_mixer[] = {
7730 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7731 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7733 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7734 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7735 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7736 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7737 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7738 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007739 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007740 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7741 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007742 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007743 { } /* end */
7744};
7745
7746/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7747 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7748 */
7749static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7751 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7753 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7754 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7755 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7756 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7757 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7758 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7759 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007762 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007763 { } /* end */
7764};
7765
Takashi Iwai914759b2007-09-06 14:52:04 +02007766static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7767 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7768 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7769 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7770 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7771 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7772 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7773 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7774 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007777 { } /* end */
7778};
7779
Kailang Yangdf694da2005-12-05 19:42:22 +01007780static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7781 {
7782 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7783 .name = "Channel Mode",
7784 .info = alc_ch_mode_info,
7785 .get = alc_ch_mode_get,
7786 .put = alc_ch_mode_put,
7787 },
7788 { } /* end */
7789};
7790
Takashi Iwai4953550a2009-06-30 15:28:30 +02007791static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007792 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007793 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007795 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007796 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7797 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007798 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007799 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7800 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007801 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007802 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007804
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007805 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007806 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007807 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007808 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007809 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007810 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007813 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007814 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007815 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007816 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007817 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007818 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007820 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007821 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007822 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007823 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7824 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007825 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007826 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7827 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7830 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7831 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7832 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7833 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007834 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007835 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007836
7837 /* FIXME: use matrix-type input source selection */
7838 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007839 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007840 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007841 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007842 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007843 /* ADC2: mute amp left and right */
7844 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007845 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007846 /* ADC3: mute amp left and right */
7847 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007848 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007849
7850 { }
7851};
7852
Takashi Iwai4953550a2009-06-30 15:28:30 +02007853static struct hda_verb alc882_adc1_init_verbs[] = {
7854 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7855 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7859 /* ADC1: mute amp left and right */
7860 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7861 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7862 { }
7863};
7864
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007865static struct hda_verb alc882_eapd_verbs[] = {
7866 /* change to EAPD mode */
7867 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007868 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007869 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007870};
7871
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007872static struct hda_verb alc889_eapd_verbs[] = {
7873 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7874 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7875 { }
7876};
7877
Wu Fengguang6732bd02009-07-30 09:19:14 +02007878static struct hda_verb alc_hp15_unsol_verbs[] = {
7879 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7880 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7881 {}
7882};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007883
7884static struct hda_verb alc885_init_verbs[] = {
7885 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007886 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007888 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007889 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007891 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007892 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007894 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007895 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7896 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007897
7898 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007899 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007900 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7901 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7902 /* Front Pin: output 0 (0x0c) */
7903 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7904 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7905 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7906 /* Rear Pin: output 1 (0x0d) */
7907 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7908 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7909 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7910 /* CLFE Pin: output 2 (0x0e) */
7911 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7912 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7913 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7914 /* Side Pin: output 3 (0x0f) */
7915 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7916 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7917 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7918 /* Mic (rear) pin: input vref at 80% */
7919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7920 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7921 /* Front Mic pin: input vref at 80% */
7922 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7923 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7924 /* Line In pin: input */
7925 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7926 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7927
7928 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7929 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007930 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007931 /* Input mixer2 */
7932 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007933 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007935 /* ADC2: mute amp left and right */
7936 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7937 /* ADC3: mute amp left and right */
7938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7939
7940 { }
7941};
7942
7943static struct hda_verb alc885_init_input_verbs[] = {
7944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7947 { }
7948};
7949
7950
7951/* Unmute Selector 24h and set the default input to front mic */
7952static struct hda_verb alc889_init_input_verbs[] = {
7953 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7954 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7955 { }
7956};
7957
7958
Takashi Iwai4953550a2009-06-30 15:28:30 +02007959#define alc883_init_verbs alc882_base_init_verbs
7960
Tobin Davis9102cd12006-12-15 10:02:12 +01007961/* Mac Pro test */
7962static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7963 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7964 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7965 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007968 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007969 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7970 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007971 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007972 { } /* end */
7973};
7974
7975static struct hda_verb alc882_macpro_init_verbs[] = {
7976 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7977 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7980 /* Front Pin: output 0 (0x0c) */
7981 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7982 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7983 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7984 /* Front Mic pin: input vref at 80% */
7985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7987 /* Speaker: output */
7988 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7989 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7990 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7991 /* Headphone output (output 0 - 0x0c) */
7992 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7993 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7994 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7995
7996 /* FIXME: use matrix-type input source selection */
7997 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7998 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7999 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8001 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8003 /* Input mixer2 */
8004 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8008 /* Input mixer3 */
8009 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8013 /* ADC1: mute amp left and right */
8014 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8015 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8016 /* ADC2: mute amp left and right */
8017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8018 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8019 /* ADC3: mute amp left and right */
8020 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8021 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8022
8023 { }
8024};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008025
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008026/* Macbook 5,1 */
8027static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008028 /* DACs */
8029 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8030 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8031 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8032 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008033 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008034 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008037 /* Surround mixer */
8038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8039 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8041 /* LFE mixer */
8042 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8045 /* HP mixer */
8046 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8047 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8048 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8049 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008052 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8053 /* LFE Pin (0x0e) */
8054 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8055 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8056 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8057 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008058 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8059 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008060 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308061 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008062 /* Front Mic pin: input vref at 80% */
8063 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8064 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8065 /* Line In pin */
8066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8068
Alex Murrayb8f171e2010-06-14 12:08:43 +09308069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008072 { }
8073};
8074
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008075/* Macmini 3,1 */
8076static struct hda_verb alc885_macmini3_init_verbs[] = {
8077 /* DACs */
8078 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8079 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8080 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8081 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8082 /* Front mixer */
8083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8086 /* Surround mixer */
8087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8090 /* LFE mixer */
8091 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8094 /* HP mixer */
8095 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8096 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8097 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8098 /* Front Pin (0x0c) */
8099 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8101 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8102 /* LFE Pin (0x0e) */
8103 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8105 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8106 /* HP Pin (0x0f) */
8107 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8109 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8110 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8111 /* Line In pin */
8112 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8113 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8114
8115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8119 { }
8120};
8121
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008122
8123static struct hda_verb alc885_mba21_init_verbs[] = {
8124 /*Internal and HP Speaker Mixer*/
8125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8128 /*Internal Speaker Pin (0x0c)*/
8129 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8130 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8131 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8132 /* HP Pin: output 0 (0x0e) */
8133 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8134 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8135 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8136 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8137 /* Line in (is hp when jack connected)*/
8138 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8139 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8140
8141 { }
8142 };
8143
8144
Takashi Iwai87350ad2007-08-16 18:19:38 +02008145/* Macbook Pro rev3 */
8146static struct hda_verb alc885_mbp3_init_verbs[] = {
8147 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8148 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8151 /* Rear mixer */
8152 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008155 /* HP mixer */
8156 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8157 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008159 /* Front Pin: output 0 (0x0c) */
8160 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8161 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8162 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008163 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008165 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8166 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008167 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8168 /* Mic (rear) pin: input vref at 80% */
8169 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8170 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8171 /* Front Mic pin: input vref at 80% */
8172 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8173 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8174 /* Line In pin: use output 1 when in LineOut mode */
8175 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8176 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8177 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8178
8179 /* FIXME: use matrix-type input source selection */
8180 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8181 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8182 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8186 /* Input mixer2 */
8187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8191 /* Input mixer3 */
8192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8196 /* ADC1: mute amp left and right */
8197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8198 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8199 /* ADC2: mute amp left and right */
8200 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8201 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8202 /* ADC3: mute amp left and right */
8203 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8204 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8205
8206 { }
8207};
8208
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008209/* iMac 9,1 */
8210static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008211 /* Internal Speaker Pin (0x0c) */
8212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8213 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8214 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8215 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8216 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8217 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8218 /* HP Pin: Rear */
8219 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8221 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8222 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8223 /* Line in Rear */
8224 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8225 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8226 /* Front Mic pin: input vref at 80% */
8227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8228 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008229 /* Rear mixer */
8230 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008233 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8235 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8236 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8237 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008238 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008242 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008243 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008247 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008248 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008252 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008253 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8254 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008255 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008256 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8257 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008258 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008259 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8260 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008261 { }
8262};
8263
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008264/* iMac 24 mixer. */
8265static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8266 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8267 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8268 { } /* end */
8269};
8270
8271/* iMac 24 init verbs. */
8272static struct hda_verb alc885_imac24_init_verbs[] = {
8273 /* Internal speakers: output 0 (0x0c) */
8274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8276 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8277 /* Internal speakers: output 0 (0x0c) */
8278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8280 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8281 /* Headphone: output 0 (0x0c) */
8282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8283 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8284 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8285 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8286 /* Front Mic: input vref at 80% */
8287 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8288 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8289 { }
8290};
8291
8292/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008293static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008294{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008295 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008296
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008297 spec->autocfg.hp_pins[0] = 0x14;
8298 spec->autocfg.speaker_pins[0] = 0x18;
8299 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008300}
8301
Takashi Iwai9d54f082010-02-22 08:34:40 +01008302#define alc885_mb5_setup alc885_imac24_setup
8303#define alc885_macmini3_setup alc885_imac24_setup
8304
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008305/* Macbook Air 2,1 */
8306static void alc885_mba21_setup(struct hda_codec *codec)
8307{
8308 struct alc_spec *spec = codec->spec;
8309
8310 spec->autocfg.hp_pins[0] = 0x14;
8311 spec->autocfg.speaker_pins[0] = 0x18;
8312}
8313
8314
8315
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008316static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008317{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008318 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008319
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008320 spec->autocfg.hp_pins[0] = 0x15;
8321 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008322}
8323
Takashi Iwai9d54f082010-02-22 08:34:40 +01008324static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308325{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008326 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308327
Takashi Iwai9d54f082010-02-22 08:34:40 +01008328 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008329 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008330 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008331}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008332
Kailang Yang272a5272007-05-14 11:00:38 +02008333static struct hda_verb alc882_targa_verbs[] = {
8334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8336
8337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8338 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008339
Kailang Yang272a5272007-05-14 11:00:38 +02008340 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8341 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8342 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8343
8344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008345 { } /* end */
8346};
8347
8348/* toggle speaker-output according to the hp-jack state */
8349static void alc882_targa_automute(struct hda_codec *codec)
8350{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008351 struct alc_spec *spec = codec->spec;
8352 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008353 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008354 spec->jack_present ? 1 : 3);
8355}
8356
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008357static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008358{
8359 struct alc_spec *spec = codec->spec;
8360
8361 spec->autocfg.hp_pins[0] = 0x14;
8362 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008363}
8364
8365static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8366{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008367 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008368 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008369}
8370
8371static struct hda_verb alc882_asus_a7j_verbs[] = {
8372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8374
8375 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8376 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8377 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008378
Kailang Yang272a5272007-05-14 11:00:38 +02008379 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8381 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8382
8383 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8384 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8385 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8386 { } /* end */
8387};
8388
Takashi Iwai914759b2007-09-06 14:52:04 +02008389static struct hda_verb alc882_asus_a7m_verbs[] = {
8390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8392
8393 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8394 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8395 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008396
Takashi Iwai914759b2007-09-06 14:52:04 +02008397 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8398 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8399 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8400
8401 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8402 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8403 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8404 { } /* end */
8405};
8406
Tobin Davis9102cd12006-12-15 10:02:12 +01008407static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8408{
8409 unsigned int gpiostate, gpiomask, gpiodir;
8410
8411 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8412 AC_VERB_GET_GPIO_DATA, 0);
8413
8414 if (!muted)
8415 gpiostate |= (1 << pin);
8416 else
8417 gpiostate &= ~(1 << pin);
8418
8419 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8420 AC_VERB_GET_GPIO_MASK, 0);
8421 gpiomask |= (1 << pin);
8422
8423 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8424 AC_VERB_GET_GPIO_DIRECTION, 0);
8425 gpiodir |= (1 << pin);
8426
8427
8428 snd_hda_codec_write(codec, codec->afg, 0,
8429 AC_VERB_SET_GPIO_MASK, gpiomask);
8430 snd_hda_codec_write(codec, codec->afg, 0,
8431 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8432
8433 msleep(1);
8434
8435 snd_hda_codec_write(codec, codec->afg, 0,
8436 AC_VERB_SET_GPIO_DATA, gpiostate);
8437}
8438
Takashi Iwai7debbe52007-08-16 15:01:03 +02008439/* set up GPIO at initialization */
8440static void alc885_macpro_init_hook(struct hda_codec *codec)
8441{
8442 alc882_gpio_mute(codec, 0, 0);
8443 alc882_gpio_mute(codec, 1, 0);
8444}
8445
8446/* set up GPIO and update auto-muting at initialization */
8447static void alc885_imac24_init_hook(struct hda_codec *codec)
8448{
8449 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008450 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008451}
8452
Kailang Yangdf694da2005-12-05 19:42:22 +01008453/*
8454 * generic initialization of ADC, input mixers and output mixers
8455 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008456static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008457 /*
8458 * Unmute ADC0-2 and set the default input to mic-in
8459 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008460 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8461 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8462 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8463 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8464
Kailang Yangdf694da2005-12-05 19:42:22 +01008465 /*
8466 * Set up output mixers (0x0c - 0x0f)
8467 */
8468 /* set vol=0 to output mixers */
8469 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8470 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8471 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8472 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8473 /* set up input amps for analog loopback */
8474 /* Amp Indices: DAC = 0, mixer = 1 */
8475 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8477 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8481 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8483 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8484 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8485
8486 /* FIXME: use matrix-type input source selection */
8487 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008488 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008489 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008490 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008492 { }
8493};
8494
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008495/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8496static struct hda_verb alc889A_mb31_ch2_init[] = {
8497 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8498 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8499 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8500 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8501 { } /* end */
8502};
8503
8504/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8505static struct hda_verb alc889A_mb31_ch4_init[] = {
8506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8508 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8509 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8510 { } /* end */
8511};
8512
8513/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8514static struct hda_verb alc889A_mb31_ch5_init[] = {
8515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8516 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8517 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8519 { } /* end */
8520};
8521
8522/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8523static struct hda_verb alc889A_mb31_ch6_init[] = {
8524 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8525 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8526 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8527 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8528 { } /* end */
8529};
8530
8531static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8532 { 2, alc889A_mb31_ch2_init },
8533 { 4, alc889A_mb31_ch4_init },
8534 { 5, alc889A_mb31_ch5_init },
8535 { 6, alc889A_mb31_ch6_init },
8536};
8537
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008538static struct hda_verb alc883_medion_eapd_verbs[] = {
8539 /* eanable EAPD on medion laptop */
8540 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8541 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8542 { }
8543};
8544
Takashi Iwai4953550a2009-06-30 15:28:30 +02008545#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008546
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008547static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8548 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8549 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8550 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8551 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8552 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8553 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8556 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8557 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8558 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8559 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8560 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008561 { } /* end */
8562};
8563
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008564static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008565 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8566 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8567 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8568 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8569 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8570 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8571 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8572 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8573 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8574 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008575 { } /* end */
8576};
8577
Jiang zhefb97dc62008-03-06 11:07:11 +01008578static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8579 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8580 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8581 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8582 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8584 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8585 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8586 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8587 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8588 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008589 { } /* end */
8590};
8591
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008592static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8593 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8594 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8595 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8596 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8597 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8598 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8599 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8600 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008601 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008602 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8603 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008604 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008605 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008606 { } /* end */
8607};
8608
8609static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8610 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8611 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8612 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8613 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8614 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8615 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8616 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8617 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8618 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8619 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8620 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8621 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8622 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8623 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008624 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008625 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8626 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008627 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008628 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008629 { } /* end */
8630};
8631
Jiang zhe17bba1b2008-06-04 12:11:07 +02008632static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8633 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8634 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8635 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8636 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8637 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8638 HDA_OUTPUT),
8639 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8640 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8641 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8642 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8643 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8644 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8645 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8646 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8648 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8649 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8650 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8651 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8652 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008653 { } /* end */
8654};
8655
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008656static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8657 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8658 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8659 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8660 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8661 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8662 HDA_OUTPUT),
8663 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8664 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8665 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8666 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8667 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8668 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8669 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8670 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8671 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8672 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8674 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8675 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8676 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8677 { } /* end */
8678};
8679
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008680static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008681 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008682 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008683 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008684 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008685 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8686 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008687 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8688 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008689 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8690 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8691 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8692 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8693 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8694 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008695 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8697 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008698 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008699 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008700 { } /* end */
8701};
8702
Sasha Alexandrc2592492009-06-16 14:52:54 -04008703static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008704 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008705 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008706 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008707 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008708 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8709 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8710 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8711 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8712 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8713 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8714 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8715 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8716 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8717 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008719 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008721 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008722};
Kailang Yangccc656c2006-10-17 12:32:26 +02008723
Sasha Alexandrc2592492009-06-16 14:52:54 -04008724static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008725 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008726 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008727 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008728 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008729 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8730 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008732 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008733 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008734 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8735 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8736 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008737 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008738};
Kailang Yangccc656c2006-10-17 12:32:26 +02008739
Takashi Iwaib99dba32009-09-17 18:23:00 +02008740static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8741 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8742 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8743 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8744 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8745 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8746 { } /* end */
8747};
8748
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008749static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8750 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8751 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008752 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8753 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008754 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8756 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8757 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008758 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008759};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008760
Kailang Yang272a5272007-05-14 11:00:38 +02008761static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8762 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8763 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8764 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008769 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8770 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008771 { } /* end */
8772};
8773
8774static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8775 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8777 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8778 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8779 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8780 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8781 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008784 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008785};
Kailang Yang272a5272007-05-14 11:00:38 +02008786
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008787static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8788 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8789 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8790 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8791 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8792 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8793 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8794 { } /* end */
8795};
8796
8797static struct hda_verb alc883_medion_wim2160_verbs[] = {
8798 /* Unmute front mixer */
8799 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8801
8802 /* Set speaker pin to front mixer */
8803 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8804
8805 /* Init headphone pin */
8806 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8808 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8809 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8810
8811 { } /* end */
8812};
8813
8814/* toggle speaker-output according to the hp-jack state */
8815static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8816{
8817 struct alc_spec *spec = codec->spec;
8818
8819 spec->autocfg.hp_pins[0] = 0x1a;
8820 spec->autocfg.speaker_pins[0] = 0x15;
8821}
8822
Tobin Davis2880a862007-08-07 11:50:26 +02008823static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008824 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8825 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008826 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008827 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8828 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008829 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8830 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8831 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008832 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008833};
Tobin Davis2880a862007-08-07 11:50:26 +02008834
Tony Vroond2fd4b02009-06-21 00:40:10 +01008835static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8836 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008837 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008838 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8839 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008840 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8841 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8845 { } /* end */
8846};
8847
Kailang Yange2757d52008-08-26 13:17:46 +02008848static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8849 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8850 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8851 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8852 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8853 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8854 0x0d, 1, 0x0, HDA_OUTPUT),
8855 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8856 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8857 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8859 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008860 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8861 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8862 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8863 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008870 { } /* end */
8871};
8872
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008873static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8874 /* Output mixers */
8875 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8876 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8877 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8878 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8879 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8880 HDA_OUTPUT),
8881 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8882 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8883 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8884 /* Output switches */
8885 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8886 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8887 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8888 /* Boost mixers */
8889 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8890 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8891 /* Input mixers */
8892 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8893 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8894 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8895 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8896 { } /* end */
8897};
8898
Guido Günther3e1647c2009-06-05 00:47:26 +02008899static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8900 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8901 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8902 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8903 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8904 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8905 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8906 { } /* end */
8907};
8908
Kailang Yange2757d52008-08-26 13:17:46 +02008909static struct hda_bind_ctls alc883_bind_cap_vol = {
8910 .ops = &snd_hda_bind_vol,
8911 .values = {
8912 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8913 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8914 0
8915 },
8916};
8917
8918static struct hda_bind_ctls alc883_bind_cap_switch = {
8919 .ops = &snd_hda_bind_sw,
8920 .values = {
8921 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8922 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8923 0
8924 },
8925};
8926
8927static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008936 { } /* end */
8937};
8938
8939static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008940 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8941 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8942 {
8943 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8944 /* .name = "Capture Source", */
8945 .name = "Input Source",
8946 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008947 .info = alc_mux_enum_info,
8948 .get = alc_mux_enum_get,
8949 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008950 },
8951 { } /* end */
8952};
8953
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008954static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8955 {
8956 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8957 .name = "Channel Mode",
8958 .info = alc_ch_mode_info,
8959 .get = alc_ch_mode_get,
8960 .put = alc_ch_mode_put,
8961 },
8962 { } /* end */
8963};
8964
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008965/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008966static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008967{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008968 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008969
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008970 spec->autocfg.hp_pins[0] = 0x15;
8971 spec->autocfg.speaker_pins[0] = 0x14;
8972 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008973}
8974
8975/* auto-toggle front mic */
8976/*
8977static void alc883_mitac_mic_automute(struct hda_codec *codec)
8978{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008979 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008980
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008981 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8982}
8983*/
8984
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008985static struct hda_verb alc883_mitac_verbs[] = {
8986 /* HP */
8987 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8988 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8989 /* Subwoofer */
8990 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8991 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8992
8993 /* enable unsolicited event */
8994 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8995 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8996
8997 { } /* end */
8998};
8999
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309000static struct hda_verb alc883_clevo_m540r_verbs[] = {
9001 /* HP */
9002 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9004 /* Int speaker */
9005 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9006
9007 /* enable unsolicited event */
9008 /*
9009 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9011 */
9012
9013 { } /* end */
9014};
9015
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009016static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009017 /* HP */
9018 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9019 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9020 /* Int speaker */
9021 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9023
9024 /* enable unsolicited event */
9025 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009026 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009027
9028 { } /* end */
9029};
9030
Jiang zhefb97dc62008-03-06 11:07:11 +01009031static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9032 /* HP */
9033 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9034 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9035 /* Subwoofer */
9036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9037 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9038
9039 /* enable unsolicited event */
9040 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9041
9042 { } /* end */
9043};
9044
Sasha Alexandrc2592492009-06-16 14:52:54 -04009045static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009046 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9048
9049 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9050 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009051
David Heidelberger64a8be72009-06-08 16:15:18 +02009052/* Connect Line-Out side jack (SPDIF) to Side */
9053 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9054 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9055 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9056/* Connect Mic jack to CLFE */
9057 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9058 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9059 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9060/* Connect Line-in jack to Surround */
9061 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9062 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9063 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9064/* Connect HP out jack to Front */
9065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9066 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009068
9069 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009070
9071 { } /* end */
9072};
9073
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009074static struct hda_verb alc883_lenovo_101e_verbs[] = {
9075 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9076 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9077 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9078 { } /* end */
9079};
9080
Kailang Yang272a5272007-05-14 11:00:38 +02009081static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9084 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9086 { } /* end */
9087};
9088
9089static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9092 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9093 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9094 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9095 { } /* end */
9096};
9097
Kailang Yang189609a2007-08-20 11:31:23 +02009098static struct hda_verb alc883_haier_w66_verbs[] = {
9099 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9101
9102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9103
9104 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9105 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9106 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9107 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9108 { } /* end */
9109};
9110
Kailang Yange2757d52008-08-26 13:17:46 +02009111static struct hda_verb alc888_lenovo_sky_verbs[] = {
9112 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9114 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9115 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9116 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9118 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9119 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9120 { } /* end */
9121};
9122
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009123static struct hda_verb alc888_6st_dell_verbs[] = {
9124 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9125 { }
9126};
9127
Guido Günther3e1647c2009-06-05 00:47:26 +02009128static struct hda_verb alc883_vaiott_verbs[] = {
9129 /* HP */
9130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9132
9133 /* enable unsolicited event */
9134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9135
9136 { } /* end */
9137};
9138
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009139static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009140{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009141 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009142
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009143 spec->autocfg.hp_pins[0] = 0x1b;
9144 spec->autocfg.speaker_pins[0] = 0x14;
9145 spec->autocfg.speaker_pins[1] = 0x16;
9146 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009147}
9148
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009149static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009150 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009151 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9152 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009153 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009154 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009155};
9156
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009157/*
9158 * 2ch mode
9159 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009160static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009161 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9162 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9163 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9164 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009165 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009166};
9167
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009168/*
9169 * 4ch mode
9170 */
9171static struct hda_verb alc888_3st_hp_4ch_init[] = {
9172 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9173 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9174 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9175 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9176 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9177 { } /* end */
9178};
9179
9180/*
9181 * 6ch mode
9182 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009183static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009184 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9185 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009186 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009187 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9188 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009189 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9190 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009191};
9192
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009193static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009194 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009195 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009196 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009197};
9198
Kailang Yang272a5272007-05-14 11:00:38 +02009199/* toggle front-jack and RCA according to the hp-jack state */
9200static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9201{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009202 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009203
Takashi Iwai47fd8302007-08-10 17:11:07 +02009204 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9205 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9206 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9207 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009208}
9209
9210/* toggle RCA according to the front-jack state */
9211static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9212{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009213 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009214
Takashi Iwai47fd8302007-08-10 17:11:07 +02009215 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9216 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009217}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009218
Kailang Yang272a5272007-05-14 11:00:38 +02009219static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9220 unsigned int res)
9221{
9222 if ((res >> 26) == ALC880_HP_EVENT)
9223 alc888_lenovo_ms7195_front_automute(codec);
9224 if ((res >> 26) == ALC880_FRONT_EVENT)
9225 alc888_lenovo_ms7195_rca_automute(codec);
9226}
9227
9228static struct hda_verb alc883_medion_md2_verbs[] = {
9229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9231
9232 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9233
9234 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9235 { } /* end */
9236};
9237
9238/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009239static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009240{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009241 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009242
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009243 spec->autocfg.hp_pins[0] = 0x14;
9244 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009245}
9246
Kailang Yangccc656c2006-10-17 12:32:26 +02009247/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009248#define alc883_targa_init_hook alc882_targa_init_hook
9249#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009250
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009251static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9252{
9253 unsigned int present;
9254
Takashi Iwaid56757a2009-11-18 08:00:14 +01009255 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009256 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9257 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9258}
9259
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009260static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009261{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009262 struct alc_spec *spec = codec->spec;
9263
9264 spec->autocfg.hp_pins[0] = 0x15;
9265 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009266}
9267
9268static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9269{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009270 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009271 alc883_clevo_m720_mic_automute(codec);
9272}
9273
9274static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009275 unsigned int res)
9276{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009277 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009278 case ALC880_MIC_EVENT:
9279 alc883_clevo_m720_mic_automute(codec);
9280 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009281 default:
9282 alc_automute_amp_unsol_event(codec, res);
9283 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009284 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009285}
9286
Jiang zhefb97dc62008-03-06 11:07:11 +01009287/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009288static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009289{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009290 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009291
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009292 spec->autocfg.hp_pins[0] = 0x14;
9293 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009294}
9295
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009296static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009297{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009298 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009299
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009300 spec->autocfg.hp_pins[0] = 0x1b;
9301 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009302}
9303
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009304static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9305{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009306 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009307
Takashi Iwai47fd8302007-08-10 17:11:07 +02009308 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9309 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009310}
9311
9312static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9313{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009314 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009315
Takashi Iwai47fd8302007-08-10 17:11:07 +02009316 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9317 HDA_AMP_MUTE, bits);
9318 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9319 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009320}
9321
9322static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9323 unsigned int res)
9324{
9325 if ((res >> 26) == ALC880_HP_EVENT)
9326 alc883_lenovo_101e_all_automute(codec);
9327 if ((res >> 26) == ALC880_FRONT_EVENT)
9328 alc883_lenovo_101e_ispeaker_automute(codec);
9329}
9330
Takashi Iwai676a9b52007-08-16 15:23:35 +02009331/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009332static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009333{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009334 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009335
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009336 spec->autocfg.hp_pins[0] = 0x14;
9337 spec->autocfg.speaker_pins[0] = 0x15;
9338 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009339}
9340
Kailang Yangd1a991a2007-08-15 16:21:59 +02009341static struct hda_verb alc883_acer_eapd_verbs[] = {
9342 /* HP Pin: output 0 (0x0c) */
9343 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9345 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9346 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9348 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009349 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009350 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9351 /* eanable EAPD on medion laptop */
9352 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9353 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009354 /* enable unsolicited event */
9355 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009356 { }
9357};
9358
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009359static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9360 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9361 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9363 { } /* end */
9364};
9365
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009366static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009367{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009368 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009369
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009370 spec->autocfg.hp_pins[0] = 0x1b;
9371 spec->autocfg.speaker_pins[0] = 0x14;
9372 spec->autocfg.speaker_pins[1] = 0x15;
9373 spec->autocfg.speaker_pins[2] = 0x16;
9374 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009375}
9376
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009377static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009378{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009379 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009380
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009381 spec->autocfg.hp_pins[0] = 0x1b;
9382 spec->autocfg.speaker_pins[0] = 0x14;
9383 spec->autocfg.speaker_pins[1] = 0x15;
9384 spec->autocfg.speaker_pins[2] = 0x16;
9385 spec->autocfg.speaker_pins[3] = 0x17;
9386 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009387}
9388
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009389static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009390{
9391 struct alc_spec *spec = codec->spec;
9392
9393 spec->autocfg.hp_pins[0] = 0x15;
9394 spec->autocfg.speaker_pins[0] = 0x14;
9395 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009396}
9397
Kailang Yange2757d52008-08-26 13:17:46 +02009398static struct hda_verb alc888_asus_m90v_verbs[] = {
9399 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9400 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9402 /* enable unsolicited event */
9403 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9404 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9405 { } /* end */
9406};
9407
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009408static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009409{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009410 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009411
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009412 spec->autocfg.hp_pins[0] = 0x1b;
9413 spec->autocfg.speaker_pins[0] = 0x14;
9414 spec->autocfg.speaker_pins[1] = 0x15;
9415 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009416 spec->ext_mic.pin = 0x18;
9417 spec->int_mic.pin = 0x19;
9418 spec->ext_mic.mux_idx = 0;
9419 spec->int_mic.mux_idx = 1;
9420 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009421}
9422
9423static struct hda_verb alc888_asus_eee1601_verbs[] = {
9424 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9428 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9429 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9430 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9431 /* enable unsolicited event */
9432 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9433 { } /* end */
9434};
9435
Kailang Yange2757d52008-08-26 13:17:46 +02009436static void alc883_eee1601_inithook(struct hda_codec *codec)
9437{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009438 struct alc_spec *spec = codec->spec;
9439
9440 spec->autocfg.hp_pins[0] = 0x14;
9441 spec->autocfg.speaker_pins[0] = 0x1b;
9442 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009443}
9444
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009445static struct hda_verb alc889A_mb31_verbs[] = {
9446 /* Init rear pin (used as headphone output) */
9447 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9448 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9449 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9450 /* Init line pin (used as output in 4ch and 6ch mode) */
9451 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9452 /* Init line 2 pin (used as headphone out by default) */
9453 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9454 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9455 { } /* end */
9456};
9457
9458/* Mute speakers according to the headphone jack state */
9459static void alc889A_mb31_automute(struct hda_codec *codec)
9460{
9461 unsigned int present;
9462
9463 /* Mute only in 2ch or 4ch mode */
9464 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9465 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009466 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009467 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9468 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9469 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9470 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9471 }
9472}
9473
9474static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9475{
9476 if ((res >> 26) == ALC880_HP_EVENT)
9477 alc889A_mb31_automute(codec);
9478}
9479
Takashi Iwai4953550a2009-06-30 15:28:30 +02009480
Takashi Iwaicb53c622007-08-10 17:21:45 +02009481#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009482#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009483#endif
9484
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009485/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009486#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9487#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9488#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9489#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9490
9491static hda_nid_t alc883_slave_dig_outs[] = {
9492 ALC1200_DIGOUT_NID, 0,
9493};
9494
9495static hda_nid_t alc1200_slave_dig_outs[] = {
9496 ALC883_DIGOUT_NID, 0,
9497};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009498
9499/*
9500 * configuration and preset
9501 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009502static const char *alc882_models[ALC882_MODEL_LAST] = {
9503 [ALC882_3ST_DIG] = "3stack-dig",
9504 [ALC882_6ST_DIG] = "6stack-dig",
9505 [ALC882_ARIMA] = "arima",
9506 [ALC882_W2JC] = "w2jc",
9507 [ALC882_TARGA] = "targa",
9508 [ALC882_ASUS_A7J] = "asus-a7j",
9509 [ALC882_ASUS_A7M] = "asus-a7m",
9510 [ALC885_MACPRO] = "macpro",
9511 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009512 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009513 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009514 [ALC885_MBP3] = "mbp3",
9515 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009516 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009517 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009518 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9519 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009520 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009521 [ALC883_TARGA_DIG] = "targa-dig",
9522 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009523 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009524 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009525 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009526 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009527 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009528 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009529 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009530 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009531 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009532 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009533 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009534 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009535 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9536 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009537 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009538 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009539 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009540 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009541 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309542 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009543 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009544 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009545 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009546 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009547 [ALC889A_INTEL] = "intel-alc889a",
9548 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009549 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009550 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009551 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009552 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009553};
9554
Takashi Iwai4953550a2009-06-30 15:28:30 +02009555static struct snd_pci_quirk alc882_cfg_tbl[] = {
9556 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9557
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009558 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009559 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009560 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009561 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9562 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009563 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009564 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9565 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009566 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009567 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009568 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9569 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009570 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9571 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009572 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9573 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009574 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009575 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009576 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009577 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009578 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9579 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009580 /* default Acer -- disabled as it causes more problems.
9581 * model=auto should work fine now
9582 */
9583 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009584
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009585 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009586
Tobin Davisfebe3372007-06-12 11:27:46 +02009587 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009588 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9589 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009590 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009591 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009592 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009593
9594 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9595 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9596 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009597 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009598 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9599 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9600 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009601 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009602 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009603 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009604 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009605
9606 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009607 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009608 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009609 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009610 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9611 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009612 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009613 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009614 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9615
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009616 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9617 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9618 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009619 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009620 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009621 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009622 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009623 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009624 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9625 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9626 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9627 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9628 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9629 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009630 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009631 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9632 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9633 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009634 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009635 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009636 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9637 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009638 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009639 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009640 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009641 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009642 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009643 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009644 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009645 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009646 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009647
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009648 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009649 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009650 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9651 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309652 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009653 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009654 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009655 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009656 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009657 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009658 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009659 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009660 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009661 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009662 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009663 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9664 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009665 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009666 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009667 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009668 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009669 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009670
Jiang zhe17bba1b2008-06-04 12:11:07 +02009671 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9672 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009673 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009674 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9675 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9676 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009677 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009678
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009679 {}
9680};
9681
Takashi Iwai4953550a2009-06-30 15:28:30 +02009682/* codec SSID table for Intel Mac */
9683static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9684 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9685 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9686 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9687 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9688 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9689 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9690 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009691 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009692 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009693 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009694 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009695 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9696 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9697 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009698 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009699 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009700 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009701 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9702 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009703 */
9704 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009705 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009706 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009707 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009708};
9709
Takashi Iwai4953550a2009-06-30 15:28:30 +02009710static struct alc_config_preset alc882_presets[] = {
9711 [ALC882_3ST_DIG] = {
9712 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009713 .init_verbs = { alc882_base_init_verbs,
9714 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009715 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9716 .dac_nids = alc882_dac_nids,
9717 .dig_out_nid = ALC882_DIGOUT_NID,
9718 .dig_in_nid = ALC882_DIGIN_NID,
9719 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9720 .channel_mode = alc882_ch_modes,
9721 .need_dac_fix = 1,
9722 .input_mux = &alc882_capture_source,
9723 },
9724 [ALC882_6ST_DIG] = {
9725 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009726 .init_verbs = { alc882_base_init_verbs,
9727 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009728 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9729 .dac_nids = alc882_dac_nids,
9730 .dig_out_nid = ALC882_DIGOUT_NID,
9731 .dig_in_nid = ALC882_DIGIN_NID,
9732 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9733 .channel_mode = alc882_sixstack_modes,
9734 .input_mux = &alc882_capture_source,
9735 },
9736 [ALC882_ARIMA] = {
9737 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009738 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9739 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009740 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9741 .dac_nids = alc882_dac_nids,
9742 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9743 .channel_mode = alc882_sixstack_modes,
9744 .input_mux = &alc882_capture_source,
9745 },
9746 [ALC882_W2JC] = {
9747 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009748 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9749 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009750 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9751 .dac_nids = alc882_dac_nids,
9752 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9753 .channel_mode = alc880_threestack_modes,
9754 .need_dac_fix = 1,
9755 .input_mux = &alc882_capture_source,
9756 .dig_out_nid = ALC882_DIGOUT_NID,
9757 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009758 [ALC885_MBA21] = {
9759 .mixers = { alc885_mba21_mixer },
9760 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9761 .num_dacs = 2,
9762 .dac_nids = alc882_dac_nids,
9763 .channel_mode = alc885_mba21_ch_modes,
9764 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9765 .input_mux = &alc882_capture_source,
9766 .unsol_event = alc_automute_amp_unsol_event,
9767 .setup = alc885_mba21_setup,
9768 .init_hook = alc_automute_amp,
9769 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770 [ALC885_MBP3] = {
9771 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9772 .init_verbs = { alc885_mbp3_init_verbs,
9773 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009774 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009775 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009776 .hp_nid = 0x04,
9777 .channel_mode = alc885_mbp_4ch_modes,
9778 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009779 .input_mux = &alc882_capture_source,
9780 .dig_out_nid = ALC882_DIGOUT_NID,
9781 .dig_in_nid = ALC882_DIGIN_NID,
9782 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009783 .setup = alc885_mbp3_setup,
9784 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009785 },
9786 [ALC885_MB5] = {
9787 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9788 .init_verbs = { alc885_mb5_init_verbs,
9789 alc880_gpio1_init_verbs },
9790 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9791 .dac_nids = alc882_dac_nids,
9792 .channel_mode = alc885_mb5_6ch_modes,
9793 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9794 .input_mux = &mb5_capture_source,
9795 .dig_out_nid = ALC882_DIGOUT_NID,
9796 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009797 .unsol_event = alc_automute_amp_unsol_event,
9798 .setup = alc885_mb5_setup,
9799 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009800 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009801 [ALC885_MACMINI3] = {
9802 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9803 .init_verbs = { alc885_macmini3_init_verbs,
9804 alc880_gpio1_init_verbs },
9805 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9806 .dac_nids = alc882_dac_nids,
9807 .channel_mode = alc885_macmini3_6ch_modes,
9808 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9809 .input_mux = &macmini3_capture_source,
9810 .dig_out_nid = ALC882_DIGOUT_NID,
9811 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009812 .unsol_event = alc_automute_amp_unsol_event,
9813 .setup = alc885_macmini3_setup,
9814 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009815 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009816 [ALC885_MACPRO] = {
9817 .mixers = { alc882_macpro_mixer },
9818 .init_verbs = { alc882_macpro_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 .init_hook = alc885_macpro_init_hook,
9827 },
9828 [ALC885_IMAC24] = {
9829 .mixers = { alc885_imac24_mixer },
9830 .init_verbs = { alc885_imac24_init_verbs },
9831 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9832 .dac_nids = alc882_dac_nids,
9833 .dig_out_nid = ALC882_DIGOUT_NID,
9834 .dig_in_nid = ALC882_DIGIN_NID,
9835 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9836 .channel_mode = alc882_ch_modes,
9837 .input_mux = &alc882_capture_source,
9838 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009839 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009840 .init_hook = alc885_imac24_init_hook,
9841 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009842 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009843 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009844 .init_verbs = { alc885_imac91_init_verbs,
9845 alc880_gpio1_init_verbs },
9846 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9847 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009848 .channel_mode = alc885_mba21_ch_modes,
9849 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9850 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009851 .dig_out_nid = ALC882_DIGOUT_NID,
9852 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009853 .unsol_event = alc_automute_amp_unsol_event,
9854 .setup = alc885_imac91_setup,
9855 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009856 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009857 [ALC882_TARGA] = {
9858 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009859 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009860 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009861 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9862 .dac_nids = alc882_dac_nids,
9863 .dig_out_nid = ALC882_DIGOUT_NID,
9864 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9865 .adc_nids = alc882_adc_nids,
9866 .capsrc_nids = alc882_capsrc_nids,
9867 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9868 .channel_mode = alc882_3ST_6ch_modes,
9869 .need_dac_fix = 1,
9870 .input_mux = &alc882_capture_source,
9871 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009872 .setup = alc882_targa_setup,
9873 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009874 },
9875 [ALC882_ASUS_A7J] = {
9876 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009877 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9878 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9880 .dac_nids = alc882_dac_nids,
9881 .dig_out_nid = ALC882_DIGOUT_NID,
9882 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9883 .adc_nids = alc882_adc_nids,
9884 .capsrc_nids = alc882_capsrc_nids,
9885 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9886 .channel_mode = alc882_3ST_6ch_modes,
9887 .need_dac_fix = 1,
9888 .input_mux = &alc882_capture_source,
9889 },
9890 [ALC882_ASUS_A7M] = {
9891 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009892 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9893 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009894 alc882_asus_a7m_verbs },
9895 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9896 .dac_nids = alc882_dac_nids,
9897 .dig_out_nid = ALC882_DIGOUT_NID,
9898 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9899 .channel_mode = alc880_threestack_modes,
9900 .need_dac_fix = 1,
9901 .input_mux = &alc882_capture_source,
9902 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009903 [ALC883_3ST_2ch_DIG] = {
9904 .mixers = { alc883_3ST_2ch_mixer },
9905 .init_verbs = { alc883_init_verbs },
9906 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9907 .dac_nids = alc883_dac_nids,
9908 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009909 .dig_in_nid = ALC883_DIGIN_NID,
9910 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9911 .channel_mode = alc883_3ST_2ch_modes,
9912 .input_mux = &alc883_capture_source,
9913 },
9914 [ALC883_3ST_6ch_DIG] = {
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,
9919 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009920 .dig_in_nid = ALC883_DIGIN_NID,
9921 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9922 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009923 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009924 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009925 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009926 [ALC883_3ST_6ch] = {
9927 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9928 .init_verbs = { alc883_init_verbs },
9929 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9930 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009931 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9932 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009933 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009934 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009935 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009936 [ALC883_3ST_6ch_INTEL] = {
9937 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9938 .init_verbs = { alc883_init_verbs },
9939 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9940 .dac_nids = alc883_dac_nids,
9941 .dig_out_nid = ALC883_DIGOUT_NID,
9942 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009943 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009944 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9945 .channel_mode = alc883_3ST_6ch_intel_modes,
9946 .need_dac_fix = 1,
9947 .input_mux = &alc883_3stack_6ch_intel,
9948 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009949 [ALC889A_INTEL] = {
9950 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009951 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9952 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009953 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9954 .dac_nids = alc883_dac_nids,
9955 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9956 .adc_nids = alc889_adc_nids,
9957 .dig_out_nid = ALC883_DIGOUT_NID,
9958 .dig_in_nid = ALC883_DIGIN_NID,
9959 .slave_dig_outs = alc883_slave_dig_outs,
9960 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9961 .channel_mode = alc889_8ch_intel_modes,
9962 .capsrc_nids = alc889_capsrc_nids,
9963 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009964 .setup = alc889_automute_setup,
9965 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009966 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009967 .need_dac_fix = 1,
9968 },
9969 [ALC889_INTEL] = {
9970 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9971 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009972 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009973 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9974 .dac_nids = alc883_dac_nids,
9975 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9976 .adc_nids = alc889_adc_nids,
9977 .dig_out_nid = ALC883_DIGOUT_NID,
9978 .dig_in_nid = ALC883_DIGIN_NID,
9979 .slave_dig_outs = alc883_slave_dig_outs,
9980 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9981 .channel_mode = alc889_8ch_intel_modes,
9982 .capsrc_nids = alc889_capsrc_nids,
9983 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009984 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009985 .init_hook = alc889_intel_init_hook,
9986 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009987 .need_dac_fix = 1,
9988 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009989 [ALC883_6ST_DIG] = {
9990 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9991 .init_verbs = { alc883_init_verbs },
9992 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9993 .dac_nids = alc883_dac_nids,
9994 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009995 .dig_in_nid = ALC883_DIGIN_NID,
9996 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9997 .channel_mode = alc883_sixstack_modes,
9998 .input_mux = &alc883_capture_source,
9999 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010000 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010001 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010002 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10003 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010004 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10005 .dac_nids = alc883_dac_nids,
10006 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010007 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10008 .channel_mode = alc883_3ST_6ch_modes,
10009 .need_dac_fix = 1,
10010 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010011 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010012 .setup = alc882_targa_setup,
10013 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010014 },
10015 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010016 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010017 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10018 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010019 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10020 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010021 .adc_nids = alc883_adc_nids_alt,
10022 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010023 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010024 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10026 .channel_mode = alc883_3ST_2ch_modes,
10027 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010028 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010029 .setup = alc882_targa_setup,
10030 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010031 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010032 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010033 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10034 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010035 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010036 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010037 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10038 .dac_nids = alc883_dac_nids,
10039 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10040 .adc_nids = alc883_adc_nids_rev,
10041 .capsrc_nids = alc883_capsrc_nids_rev,
10042 .dig_out_nid = ALC883_DIGOUT_NID,
10043 .dig_in_nid = ALC883_DIGIN_NID,
10044 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10045 .channel_mode = alc883_4ST_8ch_modes,
10046 .need_dac_fix = 1,
10047 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010048 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010049 .setup = alc882_targa_setup,
10050 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010051 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010052 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010053 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010054 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10055 * and the headphone jack. Turn this on and rely on the
10056 * standard mute methods whenever the user wants to turn
10057 * these outputs off.
10058 */
10059 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10060 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10061 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010062 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10063 .channel_mode = alc883_3ST_2ch_modes,
10064 .input_mux = &alc883_capture_source,
10065 },
Tobin Davis2880a862007-08-07 11:50:26 +020010066 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010067 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010068 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010069 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10070 .dac_nids = alc883_dac_nids,
10071 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010072 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10073 .channel_mode = alc883_3ST_2ch_modes,
10074 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010075 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010076 .setup = alc883_acer_aspire_setup,
10077 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010078 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010079 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010080 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010081 alc883_chmode_mixer },
10082 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10083 alc888_acer_aspire_4930g_verbs },
10084 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10085 .dac_nids = alc883_dac_nids,
10086 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10087 .adc_nids = alc883_adc_nids_rev,
10088 .capsrc_nids = alc883_capsrc_nids_rev,
10089 .dig_out_nid = ALC883_DIGOUT_NID,
10090 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10091 .channel_mode = alc883_3ST_6ch_modes,
10092 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010093 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010094 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010095 ARRAY_SIZE(alc888_2_capture_sources),
10096 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010097 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010098 .setup = alc888_acer_aspire_4930g_setup,
10099 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010100 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010101 [ALC888_ACER_ASPIRE_6530G] = {
10102 .mixers = { alc888_acer_aspire_6530_mixer },
10103 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10104 alc888_acer_aspire_6530g_verbs },
10105 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10106 .dac_nids = alc883_dac_nids,
10107 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10108 .adc_nids = alc883_adc_nids_rev,
10109 .capsrc_nids = alc883_capsrc_nids_rev,
10110 .dig_out_nid = ALC883_DIGOUT_NID,
10111 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10112 .channel_mode = alc883_3ST_2ch_modes,
10113 .num_mux_defs =
10114 ARRAY_SIZE(alc888_2_capture_sources),
10115 .input_mux = alc888_acer_aspire_6530_sources,
10116 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010117 .setup = alc888_acer_aspire_6530g_setup,
10118 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010119 },
Hector Martin3b315d72009-06-02 10:54:19 +020010120 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010121 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010122 alc883_chmode_mixer },
10123 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010124 alc889_acer_aspire_8930g_verbs,
10125 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010126 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10127 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010128 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10129 .adc_nids = alc889_adc_nids,
10130 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010131 .dig_out_nid = ALC883_DIGOUT_NID,
10132 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10133 .channel_mode = alc883_3ST_6ch_modes,
10134 .need_dac_fix = 1,
10135 .const_channel_count = 6,
10136 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010137 ARRAY_SIZE(alc889_capture_sources),
10138 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010139 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010140 .setup = alc889_acer_aspire_8930g_setup,
10141 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010142#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010143 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010144#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010145 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010146 [ALC888_ACER_ASPIRE_7730G] = {
10147 .mixers = { alc883_3ST_6ch_mixer,
10148 alc883_chmode_mixer },
10149 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10150 alc888_acer_aspire_7730G_verbs },
10151 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10152 .dac_nids = alc883_dac_nids,
10153 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10154 .adc_nids = alc883_adc_nids_rev,
10155 .capsrc_nids = alc883_capsrc_nids_rev,
10156 .dig_out_nid = ALC883_DIGOUT_NID,
10157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10158 .channel_mode = alc883_3ST_6ch_modes,
10159 .need_dac_fix = 1,
10160 .const_channel_count = 6,
10161 .input_mux = &alc883_capture_source,
10162 .unsol_event = alc_automute_amp_unsol_event,
10163 .setup = alc888_acer_aspire_6530g_setup,
10164 .init_hook = alc_automute_amp,
10165 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010166 [ALC883_MEDION] = {
10167 .mixers = { alc883_fivestack_mixer,
10168 alc883_chmode_mixer },
10169 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010170 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010171 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10172 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010173 .adc_nids = alc883_adc_nids_alt,
10174 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010175 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010176 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10177 .channel_mode = alc883_sixstack_modes,
10178 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010179 },
Kailang Yang272a5272007-05-14 11:00:38 +020010180 [ALC883_MEDION_MD2] = {
10181 .mixers = { alc883_medion_md2_mixer},
10182 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10183 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10184 .dac_nids = alc883_dac_nids,
10185 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010186 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10187 .channel_mode = alc883_3ST_2ch_modes,
10188 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010189 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010190 .setup = alc883_medion_md2_setup,
10191 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010192 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010193 [ALC883_MEDION_WIM2160] = {
10194 .mixers = { alc883_medion_wim2160_mixer },
10195 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10196 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10197 .dac_nids = alc883_dac_nids,
10198 .dig_out_nid = ALC883_DIGOUT_NID,
10199 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10200 .adc_nids = alc883_adc_nids,
10201 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10202 .channel_mode = alc883_3ST_2ch_modes,
10203 .input_mux = &alc883_capture_source,
10204 .unsol_event = alc_automute_amp_unsol_event,
10205 .setup = alc883_medion_wim2160_setup,
10206 .init_hook = alc_automute_amp,
10207 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010208 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010209 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010210 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10211 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10212 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010213 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10214 .channel_mode = alc883_3ST_2ch_modes,
10215 .input_mux = &alc883_capture_source,
10216 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010217 [ALC883_CLEVO_M540R] = {
10218 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10219 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10220 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10221 .dac_nids = alc883_dac_nids,
10222 .dig_out_nid = ALC883_DIGOUT_NID,
10223 .dig_in_nid = ALC883_DIGIN_NID,
10224 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10225 .channel_mode = alc883_3ST_6ch_clevo_modes,
10226 .need_dac_fix = 1,
10227 .input_mux = &alc883_capture_source,
10228 /* This machine has the hardware HP auto-muting, thus
10229 * we need no software mute via unsol event
10230 */
10231 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010232 [ALC883_CLEVO_M720] = {
10233 .mixers = { alc883_clevo_m720_mixer },
10234 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010235 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10236 .dac_nids = alc883_dac_nids,
10237 .dig_out_nid = ALC883_DIGOUT_NID,
10238 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10239 .channel_mode = alc883_3ST_2ch_modes,
10240 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010241 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010242 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010243 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010244 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010245 [ALC883_LENOVO_101E_2ch] = {
10246 .mixers = { alc883_lenovo_101e_2ch_mixer},
10247 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10248 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10249 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010250 .adc_nids = alc883_adc_nids_alt,
10251 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010252 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010253 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10254 .channel_mode = alc883_3ST_2ch_modes,
10255 .input_mux = &alc883_lenovo_101e_capture_source,
10256 .unsol_event = alc883_lenovo_101e_unsol_event,
10257 .init_hook = alc883_lenovo_101e_all_automute,
10258 },
Kailang Yang272a5272007-05-14 11:00:38 +020010259 [ALC883_LENOVO_NB0763] = {
10260 .mixers = { alc883_lenovo_nb0763_mixer },
10261 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10262 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10263 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010264 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10265 .channel_mode = alc883_3ST_2ch_modes,
10266 .need_dac_fix = 1,
10267 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010268 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010269 .setup = alc883_medion_md2_setup,
10270 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010271 },
10272 [ALC888_LENOVO_MS7195_DIG] = {
10273 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10274 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10275 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10276 .dac_nids = alc883_dac_nids,
10277 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010278 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10279 .channel_mode = alc883_3ST_6ch_modes,
10280 .need_dac_fix = 1,
10281 .input_mux = &alc883_capture_source,
10282 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10283 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010284 },
10285 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010286 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010287 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10288 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10289 .dac_nids = alc883_dac_nids,
10290 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010291 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10292 .channel_mode = alc883_3ST_2ch_modes,
10293 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010294 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010295 .setup = alc883_haier_w66_setup,
10296 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010297 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010298 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010299 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010300 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010301 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10302 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010303 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10304 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010305 .need_dac_fix = 1,
10306 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010307 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010308 .setup = alc888_3st_hp_setup,
10309 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010310 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010311 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010312 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010313 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10314 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10315 .dac_nids = alc883_dac_nids,
10316 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010317 .dig_in_nid = ALC883_DIGIN_NID,
10318 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10319 .channel_mode = alc883_sixstack_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 = alc888_6st_dell_setup,
10323 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010324 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010325 [ALC883_MITAC] = {
10326 .mixers = { alc883_mitac_mixer },
10327 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10328 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10329 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010330 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10331 .channel_mode = alc883_3ST_2ch_modes,
10332 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010333 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010334 .setup = alc883_mitac_setup,
10335 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010336 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010337 [ALC883_FUJITSU_PI2515] = {
10338 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10339 .init_verbs = { alc883_init_verbs,
10340 alc883_2ch_fujitsu_pi2515_verbs},
10341 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10342 .dac_nids = alc883_dac_nids,
10343 .dig_out_nid = ALC883_DIGOUT_NID,
10344 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10345 .channel_mode = alc883_3ST_2ch_modes,
10346 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010347 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010348 .setup = alc883_2ch_fujitsu_pi2515_setup,
10349 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010350 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010351 [ALC888_FUJITSU_XA3530] = {
10352 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10353 .init_verbs = { alc883_init_verbs,
10354 alc888_fujitsu_xa3530_verbs },
10355 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10356 .dac_nids = alc883_dac_nids,
10357 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10358 .adc_nids = alc883_adc_nids_rev,
10359 .capsrc_nids = alc883_capsrc_nids_rev,
10360 .dig_out_nid = ALC883_DIGOUT_NID,
10361 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10362 .channel_mode = alc888_4ST_8ch_intel_modes,
10363 .num_mux_defs =
10364 ARRAY_SIZE(alc888_2_capture_sources),
10365 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010366 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010367 .setup = alc888_fujitsu_xa3530_setup,
10368 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010369 },
Kailang Yange2757d52008-08-26 13:17:46 +020010370 [ALC888_LENOVO_SKY] = {
10371 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10372 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10373 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10374 .dac_nids = alc883_dac_nids,
10375 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010376 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10377 .channel_mode = alc883_sixstack_modes,
10378 .need_dac_fix = 1,
10379 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010380 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010381 .setup = alc888_lenovo_sky_setup,
10382 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010383 },
10384 [ALC888_ASUS_M90V] = {
10385 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10386 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10387 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10388 .dac_nids = alc883_dac_nids,
10389 .dig_out_nid = ALC883_DIGOUT_NID,
10390 .dig_in_nid = ALC883_DIGIN_NID,
10391 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10392 .channel_mode = alc883_3ST_6ch_modes,
10393 .need_dac_fix = 1,
10394 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010395 .unsol_event = alc_sku_unsol_event,
10396 .setup = alc883_mode2_setup,
10397 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010398 },
10399 [ALC888_ASUS_EEE1601] = {
10400 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010401 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010402 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10404 .dac_nids = alc883_dac_nids,
10405 .dig_out_nid = ALC883_DIGOUT_NID,
10406 .dig_in_nid = ALC883_DIGIN_NID,
10407 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10408 .channel_mode = alc883_3ST_2ch_modes,
10409 .need_dac_fix = 1,
10410 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010411 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010412 .init_hook = alc883_eee1601_inithook,
10413 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010414 [ALC1200_ASUS_P5Q] = {
10415 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10416 .init_verbs = { alc883_init_verbs },
10417 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10418 .dac_nids = alc883_dac_nids,
10419 .dig_out_nid = ALC1200_DIGOUT_NID,
10420 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010421 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010422 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10423 .channel_mode = alc883_sixstack_modes,
10424 .input_mux = &alc883_capture_source,
10425 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010426 [ALC889A_MB31] = {
10427 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10428 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10429 alc880_gpio1_init_verbs },
10430 .adc_nids = alc883_adc_nids,
10431 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010432 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010433 .dac_nids = alc883_dac_nids,
10434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10435 .channel_mode = alc889A_mb31_6ch_modes,
10436 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10437 .input_mux = &alc889A_mb31_capture_source,
10438 .dig_out_nid = ALC883_DIGOUT_NID,
10439 .unsol_event = alc889A_mb31_unsol_event,
10440 .init_hook = alc889A_mb31_automute,
10441 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010442 [ALC883_SONY_VAIO_TT] = {
10443 .mixers = { alc883_vaiott_mixer },
10444 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10445 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10446 .dac_nids = alc883_dac_nids,
10447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10448 .channel_mode = alc883_3ST_2ch_modes,
10449 .input_mux = &alc883_capture_source,
10450 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010451 .setup = alc883_vaiott_setup,
10452 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010453 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010454};
10455
10456
10457/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010458 * Pin config fixes
10459 */
10460enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010461 PINFIX_ABIT_AW9D_MAX,
10462 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010463};
10464
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010465static const struct alc_fixup alc882_fixups[] = {
10466 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010467 .pins = (const struct alc_pincfg[]) {
10468 { 0x15, 0x01080104 }, /* side */
10469 { 0x16, 0x01011012 }, /* rear */
10470 { 0x17, 0x01016011 }, /* clfe */
10471 { }
10472 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010473 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010474 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010475 .verbs = (const struct hda_verb[]) {
10476 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10477 {}
10478 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010479 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010480};
10481
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010482static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010483 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010484 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10485 {}
10486};
10487
10488/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010489 * BIOS auto configuration
10490 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010491static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10492 const struct auto_pin_cfg *cfg)
10493{
10494 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10495}
10496
Takashi Iwai4953550a2009-06-30 15:28:30 +020010497static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010498 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010499 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010500{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010501 int idx;
10502
Takashi Iwai489008c2010-04-07 09:06:00 +020010503 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010504 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010505
Takashi Iwai489008c2010-04-07 09:06:00 +020010506 if (dac == 0x25)
10507 idx = 4;
10508 else if (dac >= 0x02 && dac <= 0x05)
10509 idx = dac - 2;
10510 else
10511 return;
10512 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010513}
10514
Takashi Iwai4953550a2009-06-30 15:28:30 +020010515static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010516{
10517 struct alc_spec *spec = codec->spec;
10518 int i;
10519
10520 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010521 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010522 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010523 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010524 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010525 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010526 }
10527}
10528
Takashi Iwai4953550a2009-06-30 15:28:30 +020010529static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010530{
10531 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010532 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010533
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010534 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010535 if (pin) {
10536 dac = spec->multiout.hp_nid;
10537 if (!dac)
10538 dac = spec->multiout.dac_nids[0]; /* to front */
10539 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10540 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010541 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010542 if (pin) {
10543 dac = spec->multiout.extra_out_nid[0];
10544 if (!dac)
10545 dac = spec->multiout.dac_nids[0]; /* to front */
10546 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10547 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010548}
10549
Takashi Iwai4953550a2009-06-30 15:28:30 +020010550static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010551{
10552 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010553 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010554 int i;
10555
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010556 for (i = 0; i < cfg->num_inputs; i++) {
10557 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010558 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010559 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10560 snd_hda_codec_write(codec, nid, 0,
10561 AC_VERB_SET_AMP_GAIN_MUTE,
10562 AMP_OUT_MUTE);
10563 }
10564}
10565
10566static void alc882_auto_init_input_src(struct hda_codec *codec)
10567{
10568 struct alc_spec *spec = codec->spec;
10569 int c;
10570
10571 for (c = 0; c < spec->num_adc_nids; c++) {
10572 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10573 hda_nid_t nid = spec->capsrc_nids[c];
10574 unsigned int mux_idx;
10575 const struct hda_input_mux *imux;
10576 int conns, mute, idx, item;
10577
10578 conns = snd_hda_get_connections(codec, nid, conn_list,
10579 ARRAY_SIZE(conn_list));
10580 if (conns < 0)
10581 continue;
10582 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10583 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010584 if (!imux->num_items && mux_idx > 0)
10585 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010586 for (idx = 0; idx < conns; idx++) {
10587 /* if the current connection is the selected one,
10588 * unmute it as default - otherwise mute it
10589 */
10590 mute = AMP_IN_MUTE(idx);
10591 for (item = 0; item < imux->num_items; item++) {
10592 if (imux->items[item].index == idx) {
10593 if (spec->cur_mux[c] == item)
10594 mute = AMP_IN_UNMUTE(idx);
10595 break;
10596 }
10597 }
10598 /* check if we have a selector or mixer
10599 * we could check for the widget type instead, but
10600 * just check for Amp-In presence (in case of mixer
10601 * without amp-in there is something wrong, this
10602 * function shouldn't be used or capsrc nid is wrong)
10603 */
10604 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010605 snd_hda_codec_write(codec, nid, 0,
10606 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010607 mute);
10608 else if (mute != AMP_IN_MUTE(idx))
10609 snd_hda_codec_write(codec, nid, 0,
10610 AC_VERB_SET_CONNECT_SEL,
10611 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010612 }
10613 }
10614}
10615
Takashi Iwai4953550a2009-06-30 15:28:30 +020010616/* add mic boosts if needed */
10617static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010618{
10619 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010620 struct auto_pin_cfg *cfg = &spec->autocfg;
10621 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010622 hda_nid_t nid;
10623
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010624 for (i = 0; i < cfg->num_inputs; i++) {
10625 if (cfg->inputs[i].type > AUTO_PIN_FRONT_MIC)
10626 break;
10627 nid = cfg->inputs[i].pin;
10628 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
10629 char label[32];
10630 snprintf(label, sizeof(label), "%s Boost",
10631 snd_hda_get_input_pin_label(cfg, i));
10632 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010633 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010634 if (err < 0)
10635 return err;
10636 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010637 }
10638 return 0;
10639}
10640
10641/* almost identical with ALC880 parser... */
10642static int alc882_parse_auto_config(struct hda_codec *codec)
10643{
10644 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010645 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010646 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010647
Takashi Iwai05f5f472009-08-25 13:10:18 +020010648 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10649 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010650 if (err < 0)
10651 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010652 if (!spec->autocfg.line_outs)
10653 return 0; /* can't find valid BIOS pin config */
10654
10655 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10656 if (err < 0)
10657 return err;
10658 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10659 if (err < 0)
10660 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010661 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10662 "Headphone");
10663 if (err < 0)
10664 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010665 err = alc880_auto_create_extra_out(spec,
10666 spec->autocfg.speaker_pins[0],
10667 "Speaker");
10668 if (err < 0)
10669 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010670 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10671 if (err < 0)
10672 return err;
10673
10674 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10675
Takashi Iwai757899a2010-07-30 10:48:14 +020010676 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010677
10678 if (spec->kctls.list)
10679 add_mixer(spec, spec->kctls.list);
10680
10681 add_verb(spec, alc883_auto_init_verbs);
10682 /* if ADC 0x07 is available, initialize it, too */
10683 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10684 add_verb(spec, alc882_adc1_init_verbs);
10685
10686 spec->num_mux_defs = 1;
10687 spec->input_mux = &spec->private_imux[0];
10688
Kailang Yang6227cdc2010-02-25 08:36:52 +010010689 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010690
10691 err = alc_auto_add_mic_boost(codec);
10692 if (err < 0)
10693 return err;
10694
Takashi Iwai776e1842007-08-29 15:07:11 +020010695 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010696}
10697
10698/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010699static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010700{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010701 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010702 alc882_auto_init_multi_out(codec);
10703 alc882_auto_init_hp_out(codec);
10704 alc882_auto_init_analog_input(codec);
10705 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010706 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010707 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010708 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010709}
10710
Takashi Iwai4953550a2009-06-30 15:28:30 +020010711static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010712{
10713 struct alc_spec *spec;
10714 int err, board_config;
10715
10716 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10717 if (spec == NULL)
10718 return -ENOMEM;
10719
10720 codec->spec = spec;
10721
Kailang Yangda00c242010-03-19 11:23:45 +010010722 alc_auto_parse_customize_define(codec);
10723
Takashi Iwai4953550a2009-06-30 15:28:30 +020010724 switch (codec->vendor_id) {
10725 case 0x10ec0882:
10726 case 0x10ec0885:
10727 break;
10728 default:
10729 /* ALC883 and variants */
10730 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10731 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010732 }
10733
Takashi Iwai4953550a2009-06-30 15:28:30 +020010734 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10735 alc882_models,
10736 alc882_cfg_tbl);
10737
10738 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10739 board_config = snd_hda_check_board_codec_sid_config(codec,
10740 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10741
10742 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010743 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010744 codec->chip_name);
10745 board_config = ALC882_AUTO;
10746 }
10747
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010748 if (board_config == ALC882_AUTO)
10749 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010750
10751 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010752 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010753 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010754 if (err < 0) {
10755 alc_free(codec);
10756 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010757 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010758 printk(KERN_INFO
10759 "hda_codec: Cannot set up configuration "
10760 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010761 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010762 }
10763 }
10764
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010765 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010766 err = snd_hda_attach_beep_device(codec, 0x1);
10767 if (err < 0) {
10768 alc_free(codec);
10769 return err;
10770 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010771 }
10772
Takashi Iwai4953550a2009-06-30 15:28:30 +020010773 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010774 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010775
Takashi Iwai4953550a2009-06-30 15:28:30 +020010776 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10777 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10778 /* FIXME: setup DAC5 */
10779 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10780 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10781
10782 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10783 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10784
Takashi Iwai4953550a2009-06-30 15:28:30 +020010785 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010786 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010787 spec->num_adc_nids = 0;
10788 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010789 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010790 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010791 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010792 hda_nid_t nid = alc882_adc_nids[i];
10793 unsigned int wcap = get_wcaps(codec, nid);
10794 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010795 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010796 if (wcap != AC_WID_AUD_IN)
10797 continue;
10798 spec->private_adc_nids[spec->num_adc_nids] = nid;
10799 err = snd_hda_get_connections(codec, nid, &cap, 1);
10800 if (err < 0)
10801 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010802 err = snd_hda_get_connections(codec, cap, items,
10803 ARRAY_SIZE(items));
10804 if (err < 0)
10805 continue;
10806 for (j = 0; j < imux->num_items; j++)
10807 if (imux->items[j].index >= err)
10808 break;
10809 if (j < imux->num_items)
10810 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010811 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10812 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010813 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010814 spec->adc_nids = spec->private_adc_nids;
10815 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010816 }
10817
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010818 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010819
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010820 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010821 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010822
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010823 if (board_config == ALC882_AUTO)
10824 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10825
Takashi Iwai2134ea42008-01-10 16:53:55 +010010826 spec->vmaster_nid = 0x0c;
10827
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010828 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010829 if (board_config == ALC882_AUTO)
10830 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010831#ifdef CONFIG_SND_HDA_POWER_SAVE
10832 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010833 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010834#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010835
10836 return 0;
10837}
10838
Takashi Iwai4953550a2009-06-30 15:28:30 +020010839
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010840/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010841 * ALC262 support
10842 */
10843
10844#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10845#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10846
10847#define alc262_dac_nids alc260_dac_nids
10848#define alc262_adc_nids alc882_adc_nids
10849#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010850#define alc262_capsrc_nids alc882_capsrc_nids
10851#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010852
10853#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010854#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010855
Kailang Yang4e555fe2008-08-26 13:05:55 +020010856static hda_nid_t alc262_dmic_adc_nids[1] = {
10857 /* ADC0 */
10858 0x09
10859};
10860
10861static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10862
Kailang Yangdf694da2005-12-05 19:42:22 +010010863static struct snd_kcontrol_new alc262_base_mixer[] = {
10864 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10865 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10866 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10867 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10868 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10869 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10871 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010872 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010873 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10874 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010875 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010876 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10877 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10878 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10879 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010880 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010881};
10882
Takashi Iwaice875f02008-01-28 18:17:43 +010010883/* update HP, line and mono-out pins according to the master switch */
10884static void alc262_hp_master_update(struct hda_codec *codec)
10885{
10886 struct alc_spec *spec = codec->spec;
10887 int val = spec->master_sw;
10888
10889 /* HP & line-out */
10890 snd_hda_codec_write_cache(codec, 0x1b, 0,
10891 AC_VERB_SET_PIN_WIDGET_CONTROL,
10892 val ? PIN_HP : 0);
10893 snd_hda_codec_write_cache(codec, 0x15, 0,
10894 AC_VERB_SET_PIN_WIDGET_CONTROL,
10895 val ? PIN_HP : 0);
10896 /* mono (speaker) depending on the HP jack sense */
10897 val = val && !spec->jack_present;
10898 snd_hda_codec_write_cache(codec, 0x16, 0,
10899 AC_VERB_SET_PIN_WIDGET_CONTROL,
10900 val ? PIN_OUT : 0);
10901}
10902
10903static void alc262_hp_bpc_automute(struct hda_codec *codec)
10904{
10905 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010906
10907 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010908 alc262_hp_master_update(codec);
10909}
10910
10911static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10912{
10913 if ((res >> 26) != ALC880_HP_EVENT)
10914 return;
10915 alc262_hp_bpc_automute(codec);
10916}
10917
10918static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10919{
10920 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010921
10922 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010923 alc262_hp_master_update(codec);
10924}
10925
10926static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10927 unsigned int res)
10928{
10929 if ((res >> 26) != ALC880_HP_EVENT)
10930 return;
10931 alc262_hp_wildwest_automute(codec);
10932}
10933
Takashi Iwaib72519b2009-05-08 14:31:55 +020010934#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010935
10936static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10937 struct snd_ctl_elem_value *ucontrol)
10938{
10939 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10940 struct alc_spec *spec = codec->spec;
10941 int val = !!*ucontrol->value.integer.value;
10942
10943 if (val == spec->master_sw)
10944 return 0;
10945 spec->master_sw = val;
10946 alc262_hp_master_update(codec);
10947 return 1;
10948}
10949
Takashi Iwaib72519b2009-05-08 14:31:55 +020010950#define ALC262_HP_MASTER_SWITCH \
10951 { \
10952 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10953 .name = "Master Playback Switch", \
10954 .info = snd_ctl_boolean_mono_info, \
10955 .get = alc262_hp_master_sw_get, \
10956 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010957 }, \
10958 { \
10959 .iface = NID_MAPPING, \
10960 .name = "Master Playback Switch", \
10961 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010962 }
10963
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010964
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010965static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010966 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010967 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10968 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010970 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10971 HDA_OUTPUT),
10972 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10973 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010980 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10981 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010984 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10985 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10986 { } /* end */
10987};
10988
Kailang Yangcd7509a2007-01-26 18:33:17 +010010989static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010990 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10992 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10993 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010995 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10996 HDA_OUTPUT),
10997 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10998 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010999 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11000 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011001 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11004 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11005 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011006 { } /* end */
11007};
11008
11009static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11010 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11011 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011012 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011013 { } /* end */
11014};
11015
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011016/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011017static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011018{
11019 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011020
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011021 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011022 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011023}
11024
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011025static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011026 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11027 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011028 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11029 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11030 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11032 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11033 { } /* end */
11034};
11035
11036static struct hda_verb alc262_hp_t5735_verbs[] = {
11037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11039
11040 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11041 { }
11042};
11043
Kailang Yang8c427222008-01-10 13:03:59 +010011044static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011045 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11046 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011047 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11048 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011049 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11050 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11051 { } /* end */
11052};
11053
11054static struct hda_verb alc262_hp_rp5700_verbs[] = {
11055 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11056 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11057 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11058 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11059 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11060 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11061 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11063 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11065 {}
11066};
11067
11068static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11069 .num_items = 1,
11070 .items = {
11071 { "Line", 0x1 },
11072 },
11073};
11074
Takashi Iwai42171c12009-05-08 14:11:43 +020011075/* bind hp and internal speaker mute (with plug check) as master switch */
11076static void alc262_hippo_master_update(struct hda_codec *codec)
11077{
11078 struct alc_spec *spec = codec->spec;
11079 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11080 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11081 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11082 unsigned int mute;
11083
11084 /* HP */
11085 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11086 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11087 HDA_AMP_MUTE, mute);
11088 /* mute internal speaker per jack sense */
11089 if (spec->jack_present)
11090 mute = HDA_AMP_MUTE;
11091 if (line_nid)
11092 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11093 HDA_AMP_MUTE, mute);
11094 if (speaker_nid && speaker_nid != line_nid)
11095 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11096 HDA_AMP_MUTE, mute);
11097}
11098
11099#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11100
11101static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11102 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011103{
11104 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011105 struct alc_spec *spec = codec->spec;
11106 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011107
Takashi Iwai42171c12009-05-08 14:11:43 +020011108 if (val == spec->master_sw)
11109 return 0;
11110 spec->master_sw = val;
11111 alc262_hippo_master_update(codec);
11112 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011113}
Takashi Iwai5b319542007-07-26 11:49:22 +020011114
Takashi Iwai42171c12009-05-08 14:11:43 +020011115#define ALC262_HIPPO_MASTER_SWITCH \
11116 { \
11117 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11118 .name = "Master Playback Switch", \
11119 .info = snd_ctl_boolean_mono_info, \
11120 .get = alc262_hippo_master_sw_get, \
11121 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011122 }, \
11123 { \
11124 .iface = NID_MAPPING, \
11125 .name = "Master Playback Switch", \
11126 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11127 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011128 }
11129
11130static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11131 ALC262_HIPPO_MASTER_SWITCH,
11132 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11133 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11134 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11138 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11139 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11140 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11141 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11142 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11143 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11144 { } /* end */
11145};
11146
11147static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11148 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11149 ALC262_HIPPO_MASTER_SWITCH,
11150 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11151 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11152 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11153 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11156 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11159 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11160 { } /* end */
11161};
11162
11163/* mute/unmute internal speaker according to the hp jack and mute state */
11164static void alc262_hippo_automute(struct hda_codec *codec)
11165{
11166 struct alc_spec *spec = codec->spec;
11167 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011168
Wu Fengguang864f92b2009-11-18 12:38:02 +080011169 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011170 alc262_hippo_master_update(codec);
11171}
11172
11173static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11174{
11175 if ((res >> 26) != ALC880_HP_EVENT)
11176 return;
11177 alc262_hippo_automute(codec);
11178}
11179
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011180static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011181{
11182 struct alc_spec *spec = codec->spec;
11183
11184 spec->autocfg.hp_pins[0] = 0x15;
11185 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011186}
11187
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011188static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011189{
11190 struct alc_spec *spec = codec->spec;
11191
11192 spec->autocfg.hp_pins[0] = 0x1b;
11193 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011194}
11195
11196
Kailang Yang272a5272007-05-14 11:00:38 +020011197static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011198 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011199 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11202 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11203 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11204 { } /* end */
11205};
11206
Kailang Yang83c34212007-07-05 11:43:05 +020011207static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011208 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11209 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011210 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11213 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11214 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11215 { } /* end */
11216};
Kailang Yang272a5272007-05-14 11:00:38 +020011217
Tony Vroonba340e82009-02-02 19:01:30 +000011218static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11219 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11220 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11221 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11222 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11223 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11224 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11227 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11228 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11229 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11230 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11231 { } /* end */
11232};
11233
11234static struct hda_verb alc262_tyan_verbs[] = {
11235 /* Headphone automute */
11236 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11237 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11239
11240 /* P11 AUX_IN, white 4-pin connector */
11241 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11242 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11243 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11244 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11245
11246 {}
11247};
11248
11249/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011250static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011251{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011252 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011253
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011254 spec->autocfg.hp_pins[0] = 0x1b;
11255 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011256}
11257
Tony Vroonba340e82009-02-02 19:01:30 +000011258
Kailang Yangdf694da2005-12-05 19:42:22 +010011259#define alc262_capture_mixer alc882_capture_mixer
11260#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11261
11262/*
11263 * generic initialization of ADC, input mixers and output mixers
11264 */
11265static struct hda_verb alc262_init_verbs[] = {
11266 /*
11267 * Unmute ADC0-2 and set the default input to mic-in
11268 */
11269 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11270 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11271 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11273 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11275
Takashi Iwaicb53c622007-08-10 17:21:45 +020011276 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011277 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011278 * Note: PASD motherboards uses the Line In 2 as the input for
11279 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011280 */
11281 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011282 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11283 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11284 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11285 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11286 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011287
11288 /*
11289 * Set up output mixers (0x0c - 0x0e)
11290 */
11291 /* set vol=0 to output mixers */
11292 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11294 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11295 /* set up input amps for analog loopback */
11296 /* Amp Indices: DAC = 0, mixer = 1 */
11297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11299 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11302 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11303
11304 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11305 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11306 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11307 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11308 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11310
11311 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11312 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11313 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11315 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011316
Kailang Yangdf694da2005-12-05 19:42:22 +010011317 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11318 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011319
Kailang Yangdf694da2005-12-05 19:42:22 +010011320 /* FIXME: use matrix-type input source selection */
11321 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11322 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11327 /* Input mixer2 */
11328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11330 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11331 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11332 /* Input mixer3 */
11333 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11334 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11335 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011337
11338 { }
11339};
11340
Kailang Yang4e555fe2008-08-26 13:05:55 +020011341static struct hda_verb alc262_eapd_verbs[] = {
11342 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11343 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11344 { }
11345};
11346
Kailang Yangccc656c2006-10-17 12:32:26 +020011347static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11348 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11349 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11350 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11351
11352 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11353 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11354 {}
11355};
11356
Kailang Yang272a5272007-05-14 11:00:38 +020011357static struct hda_verb alc262_sony_unsol_verbs[] = {
11358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11359 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11360 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11361
11362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11363 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011364 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011365};
11366
Kailang Yang4e555fe2008-08-26 13:05:55 +020011367static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11368 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11369 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11370 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011373 { } /* end */
11374};
11375
11376static struct hda_verb alc262_toshiba_s06_verbs[] = {
11377 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11380 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11381 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11382 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11383 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11384 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11385 {}
11386};
11387
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011388static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011389{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011390 struct alc_spec *spec = codec->spec;
11391
11392 spec->autocfg.hp_pins[0] = 0x15;
11393 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011394 spec->ext_mic.pin = 0x18;
11395 spec->ext_mic.mux_idx = 0;
11396 spec->int_mic.pin = 0x12;
11397 spec->int_mic.mux_idx = 9;
11398 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011399}
11400
Takashi Iwai834be882006-03-01 14:16:17 +010011401/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011402 * nec model
11403 * 0x15 = headphone
11404 * 0x16 = internal speaker
11405 * 0x18 = external mic
11406 */
11407
11408static struct snd_kcontrol_new alc262_nec_mixer[] = {
11409 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11410 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11411
11412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11415
11416 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11418 { } /* end */
11419};
11420
11421static struct hda_verb alc262_nec_verbs[] = {
11422 /* Unmute Speaker */
11423 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11424
11425 /* Headphone */
11426 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11428
11429 /* External mic to headphone */
11430 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11431 /* External mic to speaker */
11432 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11433 {}
11434};
11435
11436/*
Takashi Iwai834be882006-03-01 14:16:17 +010011437 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011438 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11439 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011440 */
11441
11442#define ALC_HP_EVENT 0x37
11443
11444static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11445 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11446 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011447 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011449 {}
11450};
11451
Jiang zhe0e31daf2008-03-20 12:12:39 +010011452static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11453 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11454 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11455 {}
11456};
11457
Daniel T Chene2595322009-12-19 18:19:02 -050011458static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11459 /* Front Mic pin: input vref at 50% */
11460 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11461 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11462 {}
11463};
11464
Takashi Iwai834be882006-03-01 14:16:17 +010011465static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011466 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011467 .items = {
11468 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011469 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011470 { "CD", 0x4 },
11471 },
11472};
11473
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011474static struct hda_input_mux alc262_HP_capture_source = {
11475 .num_items = 5,
11476 .items = {
11477 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011478 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011479 { "Line", 0x2 },
11480 { "CD", 0x4 },
11481 { "AUX IN", 0x6 },
11482 },
11483};
11484
zhejiangaccbe492007-08-31 12:36:05 +020011485static struct hda_input_mux alc262_HP_D7000_capture_source = {
11486 .num_items = 4,
11487 .items = {
11488 { "Mic", 0x0 },
11489 { "Front Mic", 0x2 },
11490 { "Line", 0x1 },
11491 { "CD", 0x4 },
11492 },
11493};
11494
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011495/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011496static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11497{
11498 struct alc_spec *spec = codec->spec;
11499 unsigned int mute;
11500
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011501 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011502 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11503 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011504 spec->sense_updated = 1;
11505 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011506 /* unmute internal speaker only if both HPs are unplugged and
11507 * master switch is on
11508 */
11509 if (spec->jack_present)
11510 mute = HDA_AMP_MUTE;
11511 else
Takashi Iwai834be882006-03-01 14:16:17 +010011512 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011513 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11514 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011515}
11516
11517/* unsolicited event for HP jack sensing */
11518static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11519 unsigned int res)
11520{
11521 if ((res >> 26) != ALC_HP_EVENT)
11522 return;
11523 alc262_fujitsu_automute(codec, 1);
11524}
11525
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011526static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11527{
11528 alc262_fujitsu_automute(codec, 1);
11529}
11530
Takashi Iwai834be882006-03-01 14:16:17 +010011531/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011532static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11533 .ops = &snd_hda_bind_vol,
11534 .values = {
11535 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11536 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11537 0
11538 },
11539};
Takashi Iwai834be882006-03-01 14:16:17 +010011540
Jiang zhe0e31daf2008-03-20 12:12:39 +010011541/* mute/unmute internal speaker according to the hp jack and mute state */
11542static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11543{
11544 struct alc_spec *spec = codec->spec;
11545 unsigned int mute;
11546
11547 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011548 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011549 spec->sense_updated = 1;
11550 }
11551 if (spec->jack_present) {
11552 /* mute internal speaker */
11553 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11554 HDA_AMP_MUTE, HDA_AMP_MUTE);
11555 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11556 HDA_AMP_MUTE, HDA_AMP_MUTE);
11557 } else {
11558 /* unmute internal speaker if necessary */
11559 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11560 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11561 HDA_AMP_MUTE, mute);
11562 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11563 HDA_AMP_MUTE, mute);
11564 }
11565}
11566
11567/* unsolicited event for HP jack sensing */
11568static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11569 unsigned int res)
11570{
11571 if ((res >> 26) != ALC_HP_EVENT)
11572 return;
11573 alc262_lenovo_3000_automute(codec, 1);
11574}
11575
Takashi Iwai8de56b72009-07-24 16:51:47 +020011576static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11577 int dir, int idx, long *valp)
11578{
11579 int i, change = 0;
11580
11581 for (i = 0; i < 2; i++, valp++)
11582 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11583 HDA_AMP_MUTE,
11584 *valp ? 0 : HDA_AMP_MUTE);
11585 return change;
11586}
11587
Takashi Iwai834be882006-03-01 14:16:17 +010011588/* bind hp and internal speaker mute (with plug check) */
11589static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11590 struct snd_ctl_elem_value *ucontrol)
11591{
11592 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11593 long *valp = ucontrol->value.integer.value;
11594 int change;
11595
Takashi Iwai8de56b72009-07-24 16:51:47 +020011596 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11597 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011598 if (change)
11599 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011600 return change;
11601}
11602
11603static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011604 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011605 {
11606 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11607 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011608 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011609 .info = snd_hda_mixer_amp_switch_info,
11610 .get = snd_hda_mixer_amp_switch_get,
11611 .put = alc262_fujitsu_master_sw_put,
11612 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11613 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011614 {
11615 .iface = NID_MAPPING,
11616 .name = "Master Playback Switch",
11617 .private_value = 0x1b,
11618 },
Takashi Iwai834be882006-03-01 14:16:17 +010011619 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11620 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11621 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11622 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11623 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011624 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11625 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11626 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011627 { } /* end */
11628};
11629
Jiang zhe0e31daf2008-03-20 12:12:39 +010011630/* bind hp and internal speaker mute (with plug check) */
11631static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11632 struct snd_ctl_elem_value *ucontrol)
11633{
11634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11635 long *valp = ucontrol->value.integer.value;
11636 int change;
11637
Takashi Iwai8de56b72009-07-24 16:51:47 +020011638 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011639 if (change)
11640 alc262_lenovo_3000_automute(codec, 0);
11641 return change;
11642}
11643
11644static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11645 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11646 {
11647 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11648 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011649 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011650 .info = snd_hda_mixer_amp_switch_info,
11651 .get = snd_hda_mixer_amp_switch_get,
11652 .put = alc262_lenovo_3000_master_sw_put,
11653 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11654 },
11655 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11656 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11657 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11658 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11659 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11660 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11661 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11662 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11663 { } /* end */
11664};
11665
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011666static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11667 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011668 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11671 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11672 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11673 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11674 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11675 { } /* end */
11676};
11677
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011678/* additional init verbs for Benq laptops */
11679static struct hda_verb alc262_EAPD_verbs[] = {
11680 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11681 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11682 {}
11683};
11684
Kailang Yang83c34212007-07-05 11:43:05 +020011685static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11686 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11688
11689 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11690 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11691 {}
11692};
11693
Tobin Davisf651b502007-10-26 12:40:47 +020011694/* Samsung Q1 Ultra Vista model setup */
11695static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011696 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11697 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011698 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11700 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011701 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011702 { } /* end */
11703};
11704
11705static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011706 /* output mixer */
11707 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11708 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11709 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11710 /* speaker */
11711 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11712 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11713 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11714 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11715 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011717 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11718 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11719 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11720 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11721 /* internal mic */
11722 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11723 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11724 /* ADC, choose mic */
11725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11726 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11727 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11728 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11729 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11730 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11731 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11732 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011735 {}
11736};
11737
Tobin Davisf651b502007-10-26 12:40:47 +020011738/* mute/unmute internal speaker according to the hp jack and mute state */
11739static void alc262_ultra_automute(struct hda_codec *codec)
11740{
11741 struct alc_spec *spec = codec->spec;
11742 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011743
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011744 mute = 0;
11745 /* auto-mute only when HP is used as HP */
11746 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011747 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011748 if (spec->jack_present)
11749 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011750 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011751 /* mute/unmute internal speaker */
11752 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11753 HDA_AMP_MUTE, mute);
11754 /* mute/unmute HP */
11755 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11756 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011757}
11758
11759/* unsolicited event for HP jack sensing */
11760static void alc262_ultra_unsol_event(struct hda_codec *codec,
11761 unsigned int res)
11762{
11763 if ((res >> 26) != ALC880_HP_EVENT)
11764 return;
11765 alc262_ultra_automute(codec);
11766}
11767
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011768static struct hda_input_mux alc262_ultra_capture_source = {
11769 .num_items = 2,
11770 .items = {
11771 { "Mic", 0x1 },
11772 { "Headphone", 0x7 },
11773 },
11774};
11775
11776static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11777 struct snd_ctl_elem_value *ucontrol)
11778{
11779 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11780 struct alc_spec *spec = codec->spec;
11781 int ret;
11782
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011783 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011784 if (!ret)
11785 return 0;
11786 /* reprogram the HP pin as mic or HP according to the input source */
11787 snd_hda_codec_write_cache(codec, 0x15, 0,
11788 AC_VERB_SET_PIN_WIDGET_CONTROL,
11789 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11790 alc262_ultra_automute(codec); /* mute/unmute HP */
11791 return ret;
11792}
11793
11794static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11795 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11796 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11797 {
11798 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11799 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011800 .info = alc_mux_enum_info,
11801 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011802 .put = alc262_ultra_mux_enum_put,
11803 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011804 {
11805 .iface = NID_MAPPING,
11806 .name = "Capture Source",
11807 .private_value = 0x15,
11808 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011809 { } /* end */
11810};
11811
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011812/* We use two mixers depending on the output pin; 0x16 is a mono output
11813 * and thus it's bound with a different mixer.
11814 * This function returns which mixer amp should be used.
11815 */
11816static int alc262_check_volbit(hda_nid_t nid)
11817{
11818 if (!nid)
11819 return 0;
11820 else if (nid == 0x16)
11821 return 2;
11822 else
11823 return 1;
11824}
11825
11826static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011827 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011828{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011829 unsigned long val;
11830 int vbit;
11831
11832 vbit = alc262_check_volbit(nid);
11833 if (!vbit)
11834 return 0;
11835 if (*vbits & vbit) /* a volume control for this mixer already there */
11836 return 0;
11837 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011838 if (vbit == 2)
11839 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11840 else
11841 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011842 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011843}
11844
11845static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011846 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011847{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011848 unsigned long val;
11849
11850 if (!nid)
11851 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011852 if (nid == 0x16)
11853 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11854 else
11855 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011856 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011857}
11858
Kailang Yangdf694da2005-12-05 19:42:22 +010011859/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011860static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11861 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011862{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011863 const char *pfx;
11864 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020011865 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011866
11867 spec->multiout.num_dacs = 1; /* only use one dac */
11868 spec->multiout.dac_nids = spec->private_dac_nids;
11869 spec->multiout.dac_nids[0] = 2;
11870
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011871 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11872 pfx = "Master";
11873 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11874 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020011875 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
11876 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011877 else
11878 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020011879 for (i = 0; i < 2; i++) {
11880 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
11881 if (err < 0)
11882 return err;
11883 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
11884 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
11885 "Speaker", i);
11886 if (err < 0)
11887 return err;
11888 }
11889 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
11890 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
11891 "Headphone", i);
11892 if (err < 0)
11893 return err;
11894 }
11895 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011896
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011897 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11898 alc262_check_volbit(cfg->speaker_pins[0]) |
11899 alc262_check_volbit(cfg->hp_pins[0]);
11900 if (vbits == 1 || vbits == 2)
11901 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011902 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020011903 for (i = 0; i < 2; i++) {
11904 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
11905 &vbits, i);
11906 if (err < 0)
11907 return err;
11908 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
11909 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
11910 "Speaker", &vbits, i);
11911 if (err < 0)
11912 return err;
11913 }
11914 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
11915 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
11916 "Headphone", &vbits, i);
11917 if (err < 0)
11918 return err;
11919 }
11920 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011921 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011922}
11923
Takashi Iwai05f5f472009-08-25 13:10:18 +020011924#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011925 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011926
11927/*
11928 * generic initialization of ADC, input mixers and output mixers
11929 */
11930static struct hda_verb alc262_volume_init_verbs[] = {
11931 /*
11932 * Unmute ADC0-2 and set the default input to mic-in
11933 */
11934 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11936 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11938 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11940
Takashi Iwaicb53c622007-08-10 17:21:45 +020011941 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011942 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011943 * Note: PASD motherboards uses the Line In 2 as the input for
11944 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011945 */
11946 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011947 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11948 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11949 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11950 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11951 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011952
11953 /*
11954 * Set up output mixers (0x0c - 0x0f)
11955 */
11956 /* set vol=0 to output mixers */
11957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11958 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11959 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011960
Kailang Yangdf694da2005-12-05 19:42:22 +010011961 /* set up input amps for analog loopback */
11962 /* Amp Indices: DAC = 0, mixer = 1 */
11963 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11964 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11965 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11966 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11967 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11968 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11969
11970 /* FIXME: use matrix-type input source selection */
11971 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11972 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11973 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11974 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11975 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11976 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11977 /* Input mixer2 */
11978 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11979 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11980 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11981 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11982 /* Input mixer3 */
11983 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11984 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11985 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11986 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11987
11988 { }
11989};
11990
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011991static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11992 /*
11993 * Unmute ADC0-2 and set the default input to mic-in
11994 */
11995 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11996 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11997 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11998 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11999 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12000 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12001
Takashi Iwaicb53c622007-08-10 17:21:45 +020012002 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012003 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012004 * Note: PASD motherboards uses the Line In 2 as the input for
12005 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012006 */
12007 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12011 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12012 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12013 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12014 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012015
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012016 /*
12017 * Set up output mixers (0x0c - 0x0e)
12018 */
12019 /* set vol=0 to output mixers */
12020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12021 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12022 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12023
12024 /* set up input amps for analog loopback */
12025 /* Amp Indices: DAC = 0, mixer = 1 */
12026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12032
Takashi Iwaice875f02008-01-28 18:17:43 +010012033 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12035 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12036
12037 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12038 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12039
12040 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12041 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12042
12043 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12044 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12045 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12046 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12048
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012049 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12051 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012052 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012053 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12054 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12055
12056
12057 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012058 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12059 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12064 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12065 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12066 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12067 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12068 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012069 /* Input mixer2 */
12070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12073 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12074 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12075 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12076 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12077 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12078 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012079 /* Input mixer3 */
12080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12083 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12084 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12085 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12086 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012089
Takashi Iwaice875f02008-01-28 18:17:43 +010012090 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12091
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012092 { }
12093};
12094
Kailang Yangcd7509a2007-01-26 18:33:17 +010012095static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12096 /*
12097 * Unmute ADC0-2 and set the default input to mic-in
12098 */
12099 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12101 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12102 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12105
Takashi Iwaicb53c622007-08-10 17:21:45 +020012106 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012107 * mixer widget
12108 * Note: PASD motherboards uses the Line In 2 as the input for front
12109 * panel mic (mic 2)
12110 */
12111 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012120 /*
12121 * Set up output mixers (0x0c - 0x0e)
12122 */
12123 /* set vol=0 to output mixers */
12124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12125 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12126 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12127
12128 /* set up input amps for analog loopback */
12129 /* Amp Indices: DAC = 0, mixer = 1 */
12130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12135 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12136
12137
12138 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12139 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12140 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12141 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12142 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12143 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12144 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12145
12146 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12148
12149 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12150 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12151
12152 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12153 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12154 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12155 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12156 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12157 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12158
12159 /* FIXME: use matrix-type input source selection */
12160 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12161 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12162 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12163 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12164 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12167 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12169 /* Input mixer2 */
12170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12171 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12173 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12175 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12176 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12177 /* Input mixer3 */
12178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12179 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12180 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12183 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12185
Takashi Iwaice875f02008-01-28 18:17:43 +010012186 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12187
Kailang Yangcd7509a2007-01-26 18:33:17 +010012188 { }
12189};
12190
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012191static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12192
12193 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12194 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12195 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12196
12197 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12198 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12199 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12200 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12201
12202 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12204 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12205 {}
12206};
12207
12208
Takashi Iwaicb53c622007-08-10 17:21:45 +020012209#ifdef CONFIG_SND_HDA_POWER_SAVE
12210#define alc262_loopbacks alc880_loopbacks
12211#endif
12212
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012213/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012214#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12215#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12216#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12217#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12218
12219/*
12220 * BIOS auto configuration
12221 */
12222static int alc262_parse_auto_config(struct hda_codec *codec)
12223{
12224 struct alc_spec *spec = codec->spec;
12225 int err;
12226 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12227
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012228 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12229 alc262_ignore);
12230 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012231 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012232 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012233 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012234 spec->multiout.max_channels = 2;
12235 spec->no_analog = 1;
12236 goto dig_only;
12237 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012238 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012239 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012240 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12241 if (err < 0)
12242 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012243 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012244 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012245 return err;
12246
12247 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12248
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012249 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012250 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012251
Takashi Iwai603c4012008-07-30 15:01:44 +020012252 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012253 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012254
Takashi Iwaid88897e2008-10-31 15:01:37 +010012255 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012256 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012257 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012258
Takashi Iwai776e1842007-08-29 15:07:11 +020012259 err = alc_auto_add_mic_boost(codec);
12260 if (err < 0)
12261 return err;
12262
Kailang Yang6227cdc2010-02-25 08:36:52 +010012263 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012264
Kailang Yangdf694da2005-12-05 19:42:22 +010012265 return 1;
12266}
12267
12268#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12269#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12270#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012271#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012272
12273
12274/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012275static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012276{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012277 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012278 alc262_auto_init_multi_out(codec);
12279 alc262_auto_init_hp_out(codec);
12280 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012281 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012282 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012283 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012284 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012285}
12286
12287/*
12288 * configuration and preset
12289 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012290static const char *alc262_models[ALC262_MODEL_LAST] = {
12291 [ALC262_BASIC] = "basic",
12292 [ALC262_HIPPO] = "hippo",
12293 [ALC262_HIPPO_1] = "hippo_1",
12294 [ALC262_FUJITSU] = "fujitsu",
12295 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012296 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012297 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012298 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012299 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012300 [ALC262_BENQ_T31] = "benq-t31",
12301 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012302 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012303 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012304 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012305 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012306 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012307 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012308 [ALC262_AUTO] = "auto",
12309};
12310
12311static struct snd_pci_quirk alc262_cfg_tbl[] = {
12312 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012313 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012314 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12315 ALC262_HP_BPC),
12316 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12317 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012318 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12319 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012320 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012321 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012322 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012323 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012324 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012325 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012326 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012327 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012328 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12329 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12330 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012331 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12332 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012333 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012334 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012335 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012336 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012337 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012338 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012339 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012340 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012341#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012342 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12343 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012344#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012345 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012346 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012347 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012348 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012349 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012350 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012351 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12352 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012353 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012354 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012355 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012356 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012357 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012358 {}
12359};
12360
12361static struct alc_config_preset alc262_presets[] = {
12362 [ALC262_BASIC] = {
12363 .mixers = { alc262_base_mixer },
12364 .init_verbs = { alc262_init_verbs },
12365 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12366 .dac_nids = alc262_dac_nids,
12367 .hp_nid = 0x03,
12368 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12369 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012370 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012371 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012372 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012373 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012374 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012375 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12376 .dac_nids = alc262_dac_nids,
12377 .hp_nid = 0x03,
12378 .dig_out_nid = ALC262_DIGOUT_NID,
12379 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12380 .channel_mode = alc262_modes,
12381 .input_mux = &alc262_capture_source,
12382 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012383 .setup = alc262_hippo_setup,
12384 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012385 },
12386 [ALC262_HIPPO_1] = {
12387 .mixers = { alc262_hippo1_mixer },
12388 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12389 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12390 .dac_nids = alc262_dac_nids,
12391 .hp_nid = 0x02,
12392 .dig_out_nid = ALC262_DIGOUT_NID,
12393 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12394 .channel_mode = alc262_modes,
12395 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012396 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012397 .setup = alc262_hippo1_setup,
12398 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012399 },
Takashi Iwai834be882006-03-01 14:16:17 +010012400 [ALC262_FUJITSU] = {
12401 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012402 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12403 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012404 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12405 .dac_nids = alc262_dac_nids,
12406 .hp_nid = 0x03,
12407 .dig_out_nid = ALC262_DIGOUT_NID,
12408 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12409 .channel_mode = alc262_modes,
12410 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012411 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012412 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012413 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012414 [ALC262_HP_BPC] = {
12415 .mixers = { alc262_HP_BPC_mixer },
12416 .init_verbs = { alc262_HP_BPC_init_verbs },
12417 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12418 .dac_nids = alc262_dac_nids,
12419 .hp_nid = 0x03,
12420 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12421 .channel_mode = alc262_modes,
12422 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012423 .unsol_event = alc262_hp_bpc_unsol_event,
12424 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012425 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012426 [ALC262_HP_BPC_D7000_WF] = {
12427 .mixers = { alc262_HP_BPC_WildWest_mixer },
12428 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12429 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12430 .dac_nids = alc262_dac_nids,
12431 .hp_nid = 0x03,
12432 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12433 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012434 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012435 .unsol_event = alc262_hp_wildwest_unsol_event,
12436 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012437 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012438 [ALC262_HP_BPC_D7000_WL] = {
12439 .mixers = { alc262_HP_BPC_WildWest_mixer,
12440 alc262_HP_BPC_WildWest_option_mixer },
12441 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12442 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12443 .dac_nids = alc262_dac_nids,
12444 .hp_nid = 0x03,
12445 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12446 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012447 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012448 .unsol_event = alc262_hp_wildwest_unsol_event,
12449 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012450 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012451 [ALC262_HP_TC_T5735] = {
12452 .mixers = { alc262_hp_t5735_mixer },
12453 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12454 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12455 .dac_nids = alc262_dac_nids,
12456 .hp_nid = 0x03,
12457 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12458 .channel_mode = alc262_modes,
12459 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012460 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012461 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012462 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012463 },
12464 [ALC262_HP_RP5700] = {
12465 .mixers = { alc262_hp_rp5700_mixer },
12466 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12467 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12468 .dac_nids = alc262_dac_nids,
12469 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12470 .channel_mode = alc262_modes,
12471 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012472 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012473 [ALC262_BENQ_ED8] = {
12474 .mixers = { alc262_base_mixer },
12475 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12476 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12477 .dac_nids = alc262_dac_nids,
12478 .hp_nid = 0x03,
12479 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12480 .channel_mode = alc262_modes,
12481 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012482 },
Kailang Yang272a5272007-05-14 11:00:38 +020012483 [ALC262_SONY_ASSAMD] = {
12484 .mixers = { alc262_sony_mixer },
12485 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12486 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12487 .dac_nids = alc262_dac_nids,
12488 .hp_nid = 0x02,
12489 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12490 .channel_mode = alc262_modes,
12491 .input_mux = &alc262_capture_source,
12492 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012493 .setup = alc262_hippo_setup,
12494 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012495 },
12496 [ALC262_BENQ_T31] = {
12497 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012498 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12499 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012500 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12501 .dac_nids = alc262_dac_nids,
12502 .hp_nid = 0x03,
12503 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12504 .channel_mode = alc262_modes,
12505 .input_mux = &alc262_capture_source,
12506 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012507 .setup = alc262_hippo_setup,
12508 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012509 },
Tobin Davisf651b502007-10-26 12:40:47 +020012510 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012511 .mixers = { alc262_ultra_mixer },
12512 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012513 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012514 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12515 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012516 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12517 .channel_mode = alc262_modes,
12518 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012519 .adc_nids = alc262_adc_nids, /* ADC0 */
12520 .capsrc_nids = alc262_capsrc_nids,
12521 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012522 .unsol_event = alc262_ultra_unsol_event,
12523 .init_hook = alc262_ultra_automute,
12524 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012525 [ALC262_LENOVO_3000] = {
12526 .mixers = { alc262_lenovo_3000_mixer },
12527 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012528 alc262_lenovo_3000_unsol_verbs,
12529 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012530 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12531 .dac_nids = alc262_dac_nids,
12532 .hp_nid = 0x03,
12533 .dig_out_nid = ALC262_DIGOUT_NID,
12534 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12535 .channel_mode = alc262_modes,
12536 .input_mux = &alc262_fujitsu_capture_source,
12537 .unsol_event = alc262_lenovo_3000_unsol_event,
12538 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012539 [ALC262_NEC] = {
12540 .mixers = { alc262_nec_mixer },
12541 .init_verbs = { alc262_nec_verbs },
12542 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12543 .dac_nids = alc262_dac_nids,
12544 .hp_nid = 0x03,
12545 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12546 .channel_mode = alc262_modes,
12547 .input_mux = &alc262_capture_source,
12548 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012549 [ALC262_TOSHIBA_S06] = {
12550 .mixers = { alc262_toshiba_s06_mixer },
12551 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12552 alc262_eapd_verbs },
12553 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12554 .capsrc_nids = alc262_dmic_capsrc_nids,
12555 .dac_nids = alc262_dac_nids,
12556 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012557 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012558 .dig_out_nid = ALC262_DIGOUT_NID,
12559 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12560 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012561 .unsol_event = alc_sku_unsol_event,
12562 .setup = alc262_toshiba_s06_setup,
12563 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012564 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012565 [ALC262_TOSHIBA_RX1] = {
12566 .mixers = { alc262_toshiba_rx1_mixer },
12567 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12568 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12569 .dac_nids = alc262_dac_nids,
12570 .hp_nid = 0x03,
12571 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12572 .channel_mode = alc262_modes,
12573 .input_mux = &alc262_capture_source,
12574 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012575 .setup = alc262_hippo_setup,
12576 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012577 },
Tony Vroonba340e82009-02-02 19:01:30 +000012578 [ALC262_TYAN] = {
12579 .mixers = { alc262_tyan_mixer },
12580 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12581 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12582 .dac_nids = alc262_dac_nids,
12583 .hp_nid = 0x02,
12584 .dig_out_nid = ALC262_DIGOUT_NID,
12585 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12586 .channel_mode = alc262_modes,
12587 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012588 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012589 .setup = alc262_tyan_setup,
12590 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012591 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012592};
12593
12594static int patch_alc262(struct hda_codec *codec)
12595{
12596 struct alc_spec *spec;
12597 int board_config;
12598 int err;
12599
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012600 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012601 if (spec == NULL)
12602 return -ENOMEM;
12603
12604 codec->spec = spec;
12605#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012606 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12607 * under-run
12608 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012609 {
12610 int tmp;
12611 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12612 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12613 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12614 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12615 }
12616#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012617 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012618
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012619 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12620
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012621 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12622 alc262_models,
12623 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012624
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012625 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012626 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12627 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012628 board_config = ALC262_AUTO;
12629 }
12630
12631 if (board_config == ALC262_AUTO) {
12632 /* automatic parse from the BIOS config */
12633 err = alc262_parse_auto_config(codec);
12634 if (err < 0) {
12635 alc_free(codec);
12636 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012637 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012638 printk(KERN_INFO
12639 "hda_codec: Cannot set up configuration "
12640 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012641 board_config = ALC262_BASIC;
12642 }
12643 }
12644
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012645 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012646 err = snd_hda_attach_beep_device(codec, 0x1);
12647 if (err < 0) {
12648 alc_free(codec);
12649 return err;
12650 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012651 }
12652
Kailang Yangdf694da2005-12-05 19:42:22 +010012653 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012654 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012655
Kailang Yangdf694da2005-12-05 19:42:22 +010012656 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12657 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012658
Kailang Yangdf694da2005-12-05 19:42:22 +010012659 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12660 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12661
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012662 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012663 int i;
12664 /* check whether the digital-mic has to be supported */
12665 for (i = 0; i < spec->input_mux->num_items; i++) {
12666 if (spec->input_mux->items[i].index >= 9)
12667 break;
12668 }
12669 if (i < spec->input_mux->num_items) {
12670 /* use only ADC0 */
12671 spec->adc_nids = alc262_dmic_adc_nids;
12672 spec->num_adc_nids = 1;
12673 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012674 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012675 /* all analog inputs */
12676 /* check whether NID 0x07 is valid */
12677 unsigned int wcap = get_wcaps(codec, 0x07);
12678
12679 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012680 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012681 if (wcap != AC_WID_AUD_IN) {
12682 spec->adc_nids = alc262_adc_nids_alt;
12683 spec->num_adc_nids =
12684 ARRAY_SIZE(alc262_adc_nids_alt);
12685 spec->capsrc_nids = alc262_capsrc_nids_alt;
12686 } else {
12687 spec->adc_nids = alc262_adc_nids;
12688 spec->num_adc_nids =
12689 ARRAY_SIZE(alc262_adc_nids);
12690 spec->capsrc_nids = alc262_capsrc_nids;
12691 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012692 }
12693 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012694 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012695 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012696 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012697 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012698
Takashi Iwai2134ea42008-01-10 16:53:55 +010012699 spec->vmaster_nid = 0x0c;
12700
Kailang Yangdf694da2005-12-05 19:42:22 +010012701 codec->patch_ops = alc_patch_ops;
12702 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012703 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012704#ifdef CONFIG_SND_HDA_POWER_SAVE
12705 if (!spec->loopback.amplist)
12706 spec->loopback.amplist = alc262_loopbacks;
12707#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012708
Kailang Yangdf694da2005-12-05 19:42:22 +010012709 return 0;
12710}
12711
Kailang Yangdf694da2005-12-05 19:42:22 +010012712/*
Kailang Yanga361d842007-06-05 12:30:55 +020012713 * ALC268 channel source setting (2 channel)
12714 */
12715#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12716#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012717
Kailang Yanga361d842007-06-05 12:30:55 +020012718static hda_nid_t alc268_dac_nids[2] = {
12719 /* front, hp */
12720 0x02, 0x03
12721};
12722
12723static hda_nid_t alc268_adc_nids[2] = {
12724 /* ADC0-1 */
12725 0x08, 0x07
12726};
12727
12728static hda_nid_t alc268_adc_nids_alt[1] = {
12729 /* ADC0 */
12730 0x08
12731};
12732
Takashi Iwaie1406342008-02-11 18:32:32 +010012733static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12734
Kailang Yanga361d842007-06-05 12:30:55 +020012735static struct snd_kcontrol_new alc268_base_mixer[] = {
12736 /* output mixer control */
12737 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12738 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12739 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12740 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012741 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12742 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12743 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012744 { }
12745};
12746
Takashi Iwai42171c12009-05-08 14:11:43 +020012747static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12748 /* output mixer control */
12749 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12750 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12751 ALC262_HIPPO_MASTER_SWITCH,
12752 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12753 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12754 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12755 { }
12756};
12757
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012758/* bind Beep switches of both NID 0x0f and 0x10 */
12759static struct hda_bind_ctls alc268_bind_beep_sw = {
12760 .ops = &snd_hda_bind_sw,
12761 .values = {
12762 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12763 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12764 0
12765 },
12766};
12767
12768static struct snd_kcontrol_new alc268_beep_mixer[] = {
12769 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12770 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12771 { }
12772};
12773
Kailang Yangd1a991a2007-08-15 16:21:59 +020012774static struct hda_verb alc268_eapd_verbs[] = {
12775 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12776 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12777 { }
12778};
12779
Takashi Iwaid2738092007-08-16 14:59:45 +020012780/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012781static struct hda_verb alc268_toshiba_verbs[] = {
12782 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12783 { } /* end */
12784};
12785
12786/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012787/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012788static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12789 .ops = &snd_hda_bind_vol,
12790 .values = {
12791 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12792 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12793 0
12794 },
12795};
12796
Takashi Iwai889c4392007-08-23 18:56:52 +020012797/* mute/unmute internal speaker according to the hp jack and mute state */
12798static void alc268_acer_automute(struct hda_codec *codec, int force)
12799{
12800 struct alc_spec *spec = codec->spec;
12801 unsigned int mute;
12802
12803 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012804 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012805 spec->sense_updated = 1;
12806 }
12807 if (spec->jack_present)
12808 mute = HDA_AMP_MUTE; /* mute internal speaker */
12809 else /* unmute internal speaker if necessary */
12810 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12811 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12812 HDA_AMP_MUTE, mute);
12813}
12814
12815
12816/* bind hp and internal speaker mute (with plug check) */
12817static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12818 struct snd_ctl_elem_value *ucontrol)
12819{
12820 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12821 long *valp = ucontrol->value.integer.value;
12822 int change;
12823
Takashi Iwai8de56b72009-07-24 16:51:47 +020012824 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012825 if (change)
12826 alc268_acer_automute(codec, 0);
12827 return change;
12828}
Takashi Iwaid2738092007-08-16 14:59:45 +020012829
Kailang Yang8ef355d2008-08-26 13:10:22 +020012830static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12831 /* output mixer control */
12832 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12833 {
12834 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12835 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012836 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012837 .info = snd_hda_mixer_amp_switch_info,
12838 .get = snd_hda_mixer_amp_switch_get,
12839 .put = alc268_acer_master_sw_put,
12840 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12841 },
12842 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12843 { }
12844};
12845
Takashi Iwaid2738092007-08-16 14:59:45 +020012846static struct snd_kcontrol_new alc268_acer_mixer[] = {
12847 /* output mixer control */
12848 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12849 {
12850 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12851 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012852 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012853 .info = snd_hda_mixer_amp_switch_info,
12854 .get = snd_hda_mixer_amp_switch_get,
12855 .put = alc268_acer_master_sw_put,
12856 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12857 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012858 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12859 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12860 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012861 { }
12862};
12863
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012864static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12865 /* output mixer control */
12866 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12867 {
12868 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12869 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012870 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012871 .info = snd_hda_mixer_amp_switch_info,
12872 .get = snd_hda_mixer_amp_switch_get,
12873 .put = alc268_acer_master_sw_put,
12874 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12875 },
12876 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12877 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12878 { }
12879};
12880
Kailang Yang8ef355d2008-08-26 13:10:22 +020012881static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12882 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12884 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12885 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12886 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12887 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12888 { }
12889};
12890
Takashi Iwaid2738092007-08-16 14:59:45 +020012891static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012892 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12893 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012894 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12895 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12897 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012898 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12899 { }
12900};
12901
12902/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012903#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012904#define alc268_toshiba_setup alc262_hippo_setup
12905#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012906
12907static void alc268_acer_unsol_event(struct hda_codec *codec,
12908 unsigned int res)
12909{
Takashi Iwai889c4392007-08-23 18:56:52 +020012910 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012911 return;
12912 alc268_acer_automute(codec, 1);
12913}
12914
Takashi Iwai889c4392007-08-23 18:56:52 +020012915static void alc268_acer_init_hook(struct hda_codec *codec)
12916{
12917 alc268_acer_automute(codec, 1);
12918}
12919
Kailang Yang8ef355d2008-08-26 13:10:22 +020012920/* toggle speaker-output according to the hp-jack state */
12921static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12922{
12923 unsigned int present;
12924 unsigned char bits;
12925
Wu Fengguang864f92b2009-11-18 12:38:02 +080012926 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012927 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012928 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012929 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012930 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012931 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012932}
12933
Kailang Yang8ef355d2008-08-26 13:10:22 +020012934static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12935 unsigned int res)
12936{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012937 switch (res >> 26) {
12938 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012939 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012940 break;
12941 case ALC880_MIC_EVENT:
12942 alc_mic_automute(codec);
12943 break;
12944 }
12945}
12946
12947static void alc268_acer_lc_setup(struct hda_codec *codec)
12948{
12949 struct alc_spec *spec = codec->spec;
12950 spec->ext_mic.pin = 0x18;
12951 spec->ext_mic.mux_idx = 0;
12952 spec->int_mic.pin = 0x12;
12953 spec->int_mic.mux_idx = 6;
12954 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012955}
12956
12957static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12958{
12959 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012960 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012961}
12962
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012963static struct snd_kcontrol_new alc268_dell_mixer[] = {
12964 /* output mixer control */
12965 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12966 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12967 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12970 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12971 { }
12972};
12973
12974static struct hda_verb alc268_dell_verbs[] = {
12975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012978 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012979 { }
12980};
12981
12982/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012983static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012984{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012985 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012986
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012987 spec->autocfg.hp_pins[0] = 0x15;
12988 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012989 spec->ext_mic.pin = 0x18;
12990 spec->ext_mic.mux_idx = 0;
12991 spec->int_mic.pin = 0x19;
12992 spec->int_mic.mux_idx = 1;
12993 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012994}
12995
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012996static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12998 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13001 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13002 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13003 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13004 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13005 { }
13006};
13007
13008static struct hda_verb alc267_quanta_il1_verbs[] = {
13009 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13011 { }
13012};
13013
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013014static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013015{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013016 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013017 spec->autocfg.hp_pins[0] = 0x15;
13018 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013019 spec->ext_mic.pin = 0x18;
13020 spec->ext_mic.mux_idx = 0;
13021 spec->int_mic.pin = 0x19;
13022 spec->int_mic.mux_idx = 1;
13023 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013024}
13025
Kailang Yanga361d842007-06-05 12:30:55 +020013026/*
13027 * generic initialization of ADC, input mixers and output mixers
13028 */
13029static struct hda_verb alc268_base_init_verbs[] = {
13030 /* Unmute DAC0-1 and set vol = 0 */
13031 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013032 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013033
13034 /*
13035 * Set up output mixers (0x0c - 0x0e)
13036 */
13037 /* set vol=0 to output mixers */
13038 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013039 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13040
13041 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13042 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13043
13044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13046 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13048 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13049 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13051 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13052
13053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13056 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013057 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013058
13059 /* set PCBEEP vol = 0, mute connections */
13060 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13062 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013063
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013064 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013065
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013066 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13068 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013070
Kailang Yanga361d842007-06-05 12:30:55 +020013071 { }
13072};
13073
13074/*
13075 * generic initialization of ADC, input mixers and output mixers
13076 */
13077static struct hda_verb alc268_volume_init_verbs[] = {
13078 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013079 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13080 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013081
13082 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13083 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13085 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13086 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13087
Kailang Yanga361d842007-06-05 12:30:55 +020013088 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13090 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13091
13092 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013094
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013095 /* set PCBEEP vol = 0, mute connections */
13096 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13097 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13098 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013099
13100 { }
13101};
13102
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013103static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13104 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13106 { } /* end */
13107};
13108
Kailang Yanga361d842007-06-05 12:30:55 +020013109static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13110 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013112 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013113 { } /* end */
13114};
13115
13116static struct snd_kcontrol_new alc268_capture_mixer[] = {
13117 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13118 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13119 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13120 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013121 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013122 { } /* end */
13123};
13124
13125static struct hda_input_mux alc268_capture_source = {
13126 .num_items = 4,
13127 .items = {
13128 { "Mic", 0x0 },
13129 { "Front Mic", 0x1 },
13130 { "Line", 0x2 },
13131 { "CD", 0x3 },
13132 },
13133};
13134
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013135static struct hda_input_mux alc268_acer_capture_source = {
13136 .num_items = 3,
13137 .items = {
13138 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013139 { "Internal Mic", 0x1 },
13140 { "Line", 0x2 },
13141 },
13142};
13143
13144static struct hda_input_mux alc268_acer_dmic_capture_source = {
13145 .num_items = 3,
13146 .items = {
13147 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013148 { "Internal Mic", 0x6 },
13149 { "Line", 0x2 },
13150 },
13151};
13152
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013153#ifdef CONFIG_SND_DEBUG
13154static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013155 /* Volume widgets */
13156 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13157 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13158 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13159 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13160 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13161 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13162 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13163 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13164 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13165 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13166 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13167 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13168 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013169 /* The below appears problematic on some hardwares */
13170 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013171 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13172 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13173 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13174 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13175
13176 /* Modes for retasking pin widgets */
13177 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13178 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13179 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13180 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13181
13182 /* Controls for GPIO pins, assuming they are configured as outputs */
13183 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13184 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13185 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13186 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13187
13188 /* Switches to allow the digital SPDIF output pin to be enabled.
13189 * The ALC268 does not have an SPDIF input.
13190 */
13191 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13192
13193 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13194 * this output to turn on an external amplifier.
13195 */
13196 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13197 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13198
13199 { } /* end */
13200};
13201#endif
13202
Kailang Yanga361d842007-06-05 12:30:55 +020013203/* create input playback/capture controls for the given pin */
13204static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13205 const char *ctlname, int idx)
13206{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013207 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013208 int err;
13209
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013210 switch (nid) {
13211 case 0x14:
13212 case 0x16:
13213 dac = 0x02;
13214 break;
13215 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013216 case 0x1a: /* ALC259/269 only */
13217 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013218 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013219 dac = 0x03;
13220 break;
13221 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013222 snd_printd(KERN_WARNING "hda_codec: "
13223 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013224 return 0;
13225 }
13226 if (spec->multiout.dac_nids[0] != dac &&
13227 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013228 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013229 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013230 HDA_OUTPUT));
13231 if (err < 0)
13232 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013233 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13234 }
13235
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013236 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013237 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013238 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013239 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013240 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013241 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013242 if (err < 0)
13243 return err;
13244 return 0;
13245}
13246
13247/* add playback controls from the parsed DAC table */
13248static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13249 const struct auto_pin_cfg *cfg)
13250{
13251 hda_nid_t nid;
13252 int err;
13253
Kailang Yanga361d842007-06-05 12:30:55 +020013254 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013255
13256 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013257 if (nid) {
13258 const char *name;
13259 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13260 name = "Speaker";
13261 else
13262 name = "Front";
13263 err = alc268_new_analog_output(spec, nid, name, 0);
13264 if (err < 0)
13265 return err;
13266 }
Kailang Yanga361d842007-06-05 12:30:55 +020013267
13268 nid = cfg->speaker_pins[0];
13269 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013270 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013271 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13272 if (err < 0)
13273 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013274 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013275 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13276 if (err < 0)
13277 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013278 }
13279 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013280 if (nid) {
13281 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13282 if (err < 0)
13283 return err;
13284 }
Kailang Yanga361d842007-06-05 12:30:55 +020013285
13286 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13287 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013288 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013289 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013290 if (err < 0)
13291 return err;
13292 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013293 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013294}
13295
13296/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013297static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013298 const struct auto_pin_cfg *cfg)
13299{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013300 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013301}
13302
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013303static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13304 hda_nid_t nid, int pin_type)
13305{
13306 int idx;
13307
13308 alc_set_pin_output(codec, nid, pin_type);
13309 if (nid == 0x14 || nid == 0x16)
13310 idx = 0;
13311 else
13312 idx = 1;
13313 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13314}
13315
13316static void alc268_auto_init_multi_out(struct hda_codec *codec)
13317{
13318 struct alc_spec *spec = codec->spec;
13319 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13320 if (nid) {
13321 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13322 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13323 }
13324}
13325
13326static void alc268_auto_init_hp_out(struct hda_codec *codec)
13327{
13328 struct alc_spec *spec = codec->spec;
13329 hda_nid_t pin;
13330
13331 pin = spec->autocfg.hp_pins[0];
13332 if (pin)
13333 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13334 pin = spec->autocfg.speaker_pins[0];
13335 if (pin)
13336 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13337}
13338
Kailang Yanga361d842007-06-05 12:30:55 +020013339static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13340{
13341 struct alc_spec *spec = codec->spec;
13342 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13343 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13344 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13345 unsigned int dac_vol1, dac_vol2;
13346
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013347 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013348 snd_hda_codec_write(codec, speaker_nid, 0,
13349 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013350 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013351 snd_hda_codec_write(codec, 0x0f, 0,
13352 AC_VERB_SET_AMP_GAIN_MUTE,
13353 AMP_IN_UNMUTE(1));
13354 snd_hda_codec_write(codec, 0x10, 0,
13355 AC_VERB_SET_AMP_GAIN_MUTE,
13356 AMP_IN_UNMUTE(1));
13357 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013358 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013359 snd_hda_codec_write(codec, 0x0f, 0,
13360 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13361 snd_hda_codec_write(codec, 0x10, 0,
13362 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13363 }
13364
13365 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013366 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013367 dac_vol2 = AMP_OUT_ZERO;
13368 else if (line_nid == 0x15)
13369 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013370 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013371 dac_vol2 = AMP_OUT_ZERO;
13372 else if (hp_nid == 0x15)
13373 dac_vol1 = AMP_OUT_ZERO;
13374 if (line_nid != 0x16 || hp_nid != 0x16 ||
13375 spec->autocfg.line_out_pins[1] != 0x16 ||
13376 spec->autocfg.line_out_pins[2] != 0x16)
13377 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13378
13379 snd_hda_codec_write(codec, 0x02, 0,
13380 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13381 snd_hda_codec_write(codec, 0x03, 0,
13382 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13383}
13384
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013385/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013386#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13387#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013388#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013389#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13390
13391/*
13392 * BIOS auto configuration
13393 */
13394static int alc268_parse_auto_config(struct hda_codec *codec)
13395{
13396 struct alc_spec *spec = codec->spec;
13397 int err;
13398 static hda_nid_t alc268_ignore[] = { 0 };
13399
13400 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13401 alc268_ignore);
13402 if (err < 0)
13403 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013404 if (!spec->autocfg.line_outs) {
13405 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13406 spec->multiout.max_channels = 2;
13407 spec->no_analog = 1;
13408 goto dig_only;
13409 }
Kailang Yanga361d842007-06-05 12:30:55 +020013410 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013411 }
Kailang Yanga361d842007-06-05 12:30:55 +020013412 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13413 if (err < 0)
13414 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013415 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013416 if (err < 0)
13417 return err;
13418
13419 spec->multiout.max_channels = 2;
13420
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013421 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013422 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013423 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013424 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013425 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013426
Takashi Iwai892981f2009-03-02 08:04:35 +010013427 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013428 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013429
Takashi Iwaid88897e2008-10-31 15:01:37 +010013430 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013431 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013432 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013433
Takashi Iwai776e1842007-08-29 15:07:11 +020013434 err = alc_auto_add_mic_boost(codec);
13435 if (err < 0)
13436 return err;
13437
Kailang Yang6227cdc2010-02-25 08:36:52 +010013438 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013439
Kailang Yanga361d842007-06-05 12:30:55 +020013440 return 1;
13441}
13442
Kailang Yanga361d842007-06-05 12:30:55 +020013443#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13444
13445/* init callback for auto-configuration model -- overriding the default init */
13446static void alc268_auto_init(struct hda_codec *codec)
13447{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013448 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013449 alc268_auto_init_multi_out(codec);
13450 alc268_auto_init_hp_out(codec);
13451 alc268_auto_init_mono_speaker_out(codec);
13452 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013453 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013454 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013455 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013456}
13457
13458/*
13459 * configuration and preset
13460 */
13461static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013462 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013463 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013464 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013465 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013466 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013467 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013468 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013469 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013470#ifdef CONFIG_SND_DEBUG
13471 [ALC268_TEST] = "test",
13472#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013473 [ALC268_AUTO] = "auto",
13474};
13475
13476static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013477 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013478 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013479 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013480 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013481 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013482 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13483 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013484 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013485 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13486 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013487 /* almost compatible with toshiba but with optional digital outs;
13488 * auto-probing seems working fine
13489 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013490 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013491 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013492 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013493 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013494 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013495 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013496 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013497 {}
13498};
13499
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013500/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13501static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13502 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13503 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13504 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13505 ALC268_TOSHIBA),
13506 {}
13507};
13508
Kailang Yanga361d842007-06-05 12:30:55 +020013509static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013510 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013511 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13512 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013513 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13514 alc267_quanta_il1_verbs },
13515 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13516 .dac_nids = alc268_dac_nids,
13517 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13518 .adc_nids = alc268_adc_nids_alt,
13519 .hp_nid = 0x03,
13520 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13521 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013522 .unsol_event = alc_sku_unsol_event,
13523 .setup = alc267_quanta_il1_setup,
13524 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013525 },
Kailang Yanga361d842007-06-05 12:30:55 +020013526 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013527 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13528 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013529 .init_verbs = { alc268_base_init_verbs },
13530 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13531 .dac_nids = alc268_dac_nids,
13532 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13533 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013534 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013535 .hp_nid = 0x03,
13536 .dig_out_nid = ALC268_DIGOUT_NID,
13537 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13538 .channel_mode = alc268_modes,
13539 .input_mux = &alc268_capture_source,
13540 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013541 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013542 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013543 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013544 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13545 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013546 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13547 .dac_nids = alc268_dac_nids,
13548 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13549 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013550 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013551 .hp_nid = 0x03,
13552 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13553 .channel_mode = alc268_modes,
13554 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013555 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013556 .setup = alc268_toshiba_setup,
13557 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013558 },
13559 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013560 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013561 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013562 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13563 alc268_acer_verbs },
13564 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13565 .dac_nids = alc268_dac_nids,
13566 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13567 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013568 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013569 .hp_nid = 0x02,
13570 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13571 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013572 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013573 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013574 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013575 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013576 [ALC268_ACER_DMIC] = {
13577 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13578 alc268_beep_mixer },
13579 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13580 alc268_acer_verbs },
13581 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13582 .dac_nids = alc268_dac_nids,
13583 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13584 .adc_nids = alc268_adc_nids_alt,
13585 .capsrc_nids = alc268_capsrc_nids,
13586 .hp_nid = 0x02,
13587 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13588 .channel_mode = alc268_modes,
13589 .input_mux = &alc268_acer_dmic_capture_source,
13590 .unsol_event = alc268_acer_unsol_event,
13591 .init_hook = alc268_acer_init_hook,
13592 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013593 [ALC268_ACER_ASPIRE_ONE] = {
13594 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013595 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013596 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013597 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13598 alc268_acer_aspire_one_verbs },
13599 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13600 .dac_nids = alc268_dac_nids,
13601 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13602 .adc_nids = alc268_adc_nids_alt,
13603 .capsrc_nids = alc268_capsrc_nids,
13604 .hp_nid = 0x03,
13605 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13606 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013607 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013608 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013609 .init_hook = alc268_acer_lc_init_hook,
13610 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013611 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013612 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13613 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013614 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13615 alc268_dell_verbs },
13616 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13617 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013618 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13619 .adc_nids = alc268_adc_nids_alt,
13620 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013621 .hp_nid = 0x02,
13622 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13623 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013624 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013625 .setup = alc268_dell_setup,
13626 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013627 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013628 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013629 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13630 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013631 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13632 alc268_toshiba_verbs },
13633 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13634 .dac_nids = alc268_dac_nids,
13635 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13636 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013637 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013638 .hp_nid = 0x03,
13639 .dig_out_nid = ALC268_DIGOUT_NID,
13640 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13641 .channel_mode = alc268_modes,
13642 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013643 .setup = alc268_toshiba_setup,
13644 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013645 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013646#ifdef CONFIG_SND_DEBUG
13647 [ALC268_TEST] = {
13648 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13649 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13650 alc268_volume_init_verbs },
13651 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13652 .dac_nids = alc268_dac_nids,
13653 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13654 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013655 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013656 .hp_nid = 0x03,
13657 .dig_out_nid = ALC268_DIGOUT_NID,
13658 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13659 .channel_mode = alc268_modes,
13660 .input_mux = &alc268_capture_source,
13661 },
13662#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013663};
13664
13665static int patch_alc268(struct hda_codec *codec)
13666{
13667 struct alc_spec *spec;
13668 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013669 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013670
Julia Lawallef86f582009-12-19 08:18:03 +010013671 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013672 if (spec == NULL)
13673 return -ENOMEM;
13674
13675 codec->spec = spec;
13676
13677 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13678 alc268_models,
13679 alc268_cfg_tbl);
13680
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013681 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13682 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013683 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013684
Kailang Yanga361d842007-06-05 12:30:55 +020013685 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013686 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13687 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013688 board_config = ALC268_AUTO;
13689 }
13690
13691 if (board_config == ALC268_AUTO) {
13692 /* automatic parse from the BIOS config */
13693 err = alc268_parse_auto_config(codec);
13694 if (err < 0) {
13695 alc_free(codec);
13696 return err;
13697 } else if (!err) {
13698 printk(KERN_INFO
13699 "hda_codec: Cannot set up configuration "
13700 "from BIOS. Using base mode...\n");
13701 board_config = ALC268_3ST;
13702 }
13703 }
13704
13705 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013706 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013707
Kailang Yanga361d842007-06-05 12:30:55 +020013708 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13709 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013710 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013711
Kailang Yanga361d842007-06-05 12:30:55 +020013712 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13713
Takashi Iwai22971e32009-02-10 11:56:44 +010013714 has_beep = 0;
13715 for (i = 0; i < spec->num_mixers; i++) {
13716 if (spec->mixers[i] == alc268_beep_mixer) {
13717 has_beep = 1;
13718 break;
13719 }
13720 }
13721
13722 if (has_beep) {
13723 err = snd_hda_attach_beep_device(codec, 0x1);
13724 if (err < 0) {
13725 alc_free(codec);
13726 return err;
13727 }
13728 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13729 /* override the amp caps for beep generator */
13730 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013731 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13732 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13733 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13734 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013735 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013736
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013737 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013738 /* check whether NID 0x07 is valid */
13739 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013740 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013741
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013742 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013743 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013744 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013745 if (spec->auto_mic ||
13746 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013747 spec->adc_nids = alc268_adc_nids_alt;
13748 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013749 if (spec->auto_mic)
13750 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013751 if (spec->auto_mic || spec->input_mux->num_items == 1)
13752 add_mixer(spec, alc268_capture_nosrc_mixer);
13753 else
13754 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013755 } else {
13756 spec->adc_nids = alc268_adc_nids;
13757 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013758 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013759 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013760 /* set default input source */
13761 for (i = 0; i < spec->num_adc_nids; i++)
13762 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13763 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013764 i < spec->num_mux_defs ?
13765 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013766 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013767 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013768
13769 spec->vmaster_nid = 0x02;
13770
Kailang Yanga361d842007-06-05 12:30:55 +020013771 codec->patch_ops = alc_patch_ops;
13772 if (board_config == ALC268_AUTO)
13773 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013774
Kailang Yanga361d842007-06-05 12:30:55 +020013775 return 0;
13776}
13777
13778/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013779 * ALC269 channel source setting (2 channel)
13780 */
13781#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13782
13783#define alc269_dac_nids alc260_dac_nids
13784
13785static hda_nid_t alc269_adc_nids[1] = {
13786 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013787 0x08,
13788};
13789
Takashi Iwaie01bf502008-08-21 16:25:07 +020013790static hda_nid_t alc269_capsrc_nids[1] = {
13791 0x23,
13792};
13793
Kailang Yang84898e82010-02-04 14:16:14 +010013794static hda_nid_t alc269vb_adc_nids[1] = {
13795 /* ADC1 */
13796 0x09,
13797};
13798
13799static hda_nid_t alc269vb_capsrc_nids[1] = {
13800 0x22,
13801};
13802
Takashi Iwai66946352010-03-29 17:21:45 +020013803static hda_nid_t alc269_adc_candidates[] = {
13804 0x08, 0x09, 0x07,
13805};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013806
Kailang Yangf6a92242007-12-13 16:52:54 +010013807#define alc269_modes alc260_modes
13808#define alc269_capture_source alc880_lg_lw_capture_source
13809
13810static struct snd_kcontrol_new alc269_base_mixer[] = {
13811 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13812 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13814 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
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("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13819 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13820 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13821 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13822 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13823 { } /* end */
13824};
13825
Kailang Yang60db6b52008-08-26 13:13:00 +020013826static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13827 /* output mixer control */
13828 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13829 {
13830 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13831 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013832 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013833 .info = snd_hda_mixer_amp_switch_info,
13834 .get = snd_hda_mixer_amp_switch_get,
13835 .put = alc268_acer_master_sw_put,
13836 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13837 },
13838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13839 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13840 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13841 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13842 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13843 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013844 { }
13845};
13846
Tony Vroon64154832008-11-06 15:08:49 +000013847static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13848 /* output mixer control */
13849 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13850 {
13851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13852 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013853 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013854 .info = snd_hda_mixer_amp_switch_info,
13855 .get = snd_hda_mixer_amp_switch_get,
13856 .put = alc268_acer_master_sw_put,
13857 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13858 },
13859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13860 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13861 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13862 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13863 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13864 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13865 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13866 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13867 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013868 { }
13869};
13870
Kailang Yang84898e82010-02-04 14:16:14 +010013871static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013872 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013873 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013874 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013875 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013876 { } /* end */
13877};
13878
Kailang Yang84898e82010-02-04 14:16:14 +010013879static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13880 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13881 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13883 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13884 { } /* end */
13885};
13886
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020013887static struct snd_kcontrol_new alc269_asus_mixer[] = {
13888 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13889 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
13890 { } /* end */
13891};
13892
Kailang Yangf6a92242007-12-13 16:52:54 +010013893/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013894static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13895 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13896 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13897 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13898 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13899 { } /* end */
13900};
13901
13902static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013903 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13904 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013905 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13906 { } /* end */
13907};
13908
Kailang Yang84898e82010-02-04 14:16:14 +010013909static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13910 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13911 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13912 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13913 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13914 { } /* end */
13915};
13916
13917static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13918 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13919 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13921 { } /* end */
13922};
13923
Takashi Iwai26f5df22008-11-03 17:39:46 +010013924/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013925#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013926
Kailang Yang60db6b52008-08-26 13:13:00 +020013927static struct hda_verb alc269_quanta_fl1_verbs[] = {
13928 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13931 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13932 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13933 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13934 { }
13935};
13936
Tony Vroon64154832008-11-06 15:08:49 +000013937static struct hda_verb alc269_lifebook_verbs[] = {
13938 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13939 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13940 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13942 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13943 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13944 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13945 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13946 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13947 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13948 { }
13949};
13950
Kailang Yang60db6b52008-08-26 13:13:00 +020013951/* toggle speaker-output according to the hp-jack state */
13952static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13953{
13954 unsigned int present;
13955 unsigned char bits;
13956
Wu Fengguang864f92b2009-11-18 12:38:02 +080013957 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013958 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013959 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013960 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013961 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013962 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013963
13964 snd_hda_codec_write(codec, 0x20, 0,
13965 AC_VERB_SET_COEF_INDEX, 0x0c);
13966 snd_hda_codec_write(codec, 0x20, 0,
13967 AC_VERB_SET_PROC_COEF, 0x680);
13968
13969 snd_hda_codec_write(codec, 0x20, 0,
13970 AC_VERB_SET_COEF_INDEX, 0x0c);
13971 snd_hda_codec_write(codec, 0x20, 0,
13972 AC_VERB_SET_PROC_COEF, 0x480);
13973}
13974
Tony Vroon64154832008-11-06 15:08:49 +000013975/* toggle speaker-output according to the hp-jacks state */
13976static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13977{
13978 unsigned int present;
13979 unsigned char bits;
13980
13981 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013982 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013983
13984 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013985 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013986
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013987 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013988 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013989 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013990 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013991 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013992
13993 snd_hda_codec_write(codec, 0x20, 0,
13994 AC_VERB_SET_COEF_INDEX, 0x0c);
13995 snd_hda_codec_write(codec, 0x20, 0,
13996 AC_VERB_SET_PROC_COEF, 0x680);
13997
13998 snd_hda_codec_write(codec, 0x20, 0,
13999 AC_VERB_SET_COEF_INDEX, 0x0c);
14000 snd_hda_codec_write(codec, 0x20, 0,
14001 AC_VERB_SET_PROC_COEF, 0x480);
14002}
14003
Tony Vroon64154832008-11-06 15:08:49 +000014004static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14005{
14006 unsigned int present_laptop;
14007 unsigned int present_dock;
14008
Wu Fengguang864f92b2009-11-18 12:38:02 +080014009 present_laptop = snd_hda_jack_detect(codec, 0x18);
14010 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014011
14012 /* Laptop mic port overrides dock mic port, design decision */
14013 if (present_dock)
14014 snd_hda_codec_write(codec, 0x23, 0,
14015 AC_VERB_SET_CONNECT_SEL, 0x3);
14016 if (present_laptop)
14017 snd_hda_codec_write(codec, 0x23, 0,
14018 AC_VERB_SET_CONNECT_SEL, 0x0);
14019 if (!present_dock && !present_laptop)
14020 snd_hda_codec_write(codec, 0x23, 0,
14021 AC_VERB_SET_CONNECT_SEL, 0x1);
14022}
14023
Kailang Yang60db6b52008-08-26 13:13:00 +020014024static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14025 unsigned int res)
14026{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014027 switch (res >> 26) {
14028 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014029 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014030 break;
14031 case ALC880_MIC_EVENT:
14032 alc_mic_automute(codec);
14033 break;
14034 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014035}
14036
Tony Vroon64154832008-11-06 15:08:49 +000014037static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14038 unsigned int res)
14039{
14040 if ((res >> 26) == ALC880_HP_EVENT)
14041 alc269_lifebook_speaker_automute(codec);
14042 if ((res >> 26) == ALC880_MIC_EVENT)
14043 alc269_lifebook_mic_autoswitch(codec);
14044}
14045
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014046static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14047{
14048 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014049 spec->autocfg.hp_pins[0] = 0x15;
14050 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014051 spec->ext_mic.pin = 0x18;
14052 spec->ext_mic.mux_idx = 0;
14053 spec->int_mic.pin = 0x19;
14054 spec->int_mic.mux_idx = 1;
14055 spec->auto_mic = 1;
14056}
14057
Kailang Yang60db6b52008-08-26 13:13:00 +020014058static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14059{
14060 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014061 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014062}
14063
Tony Vroon64154832008-11-06 15:08:49 +000014064static void alc269_lifebook_init_hook(struct hda_codec *codec)
14065{
14066 alc269_lifebook_speaker_automute(codec);
14067 alc269_lifebook_mic_autoswitch(codec);
14068}
14069
Kailang Yang84898e82010-02-04 14:16:14 +010014070static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014071 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14072 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14073 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14075 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14077 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14078 {}
14079};
14080
Kailang Yang84898e82010-02-04 14:16:14 +010014081static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14083 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14084 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14085 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14086 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14087 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14088 {}
14089};
14090
Kailang Yang84898e82010-02-04 14:16:14 +010014091static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14092 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14093 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14094 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14095 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14096 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14097 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14098 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14099 {}
14100};
14101
14102static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14103 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14104 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14105 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14106 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14107 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14109 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14110 {}
14111};
14112
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014113static struct hda_verb alc271_acer_dmic_verbs[] = {
14114 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14115 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14116 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14117 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14118 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14119 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14120 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14121 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14122 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14123 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14124 { }
14125};
14126
Kailang Yang60db6b52008-08-26 13:13:00 +020014127/* toggle speaker-output according to the hp-jack state */
14128static void alc269_speaker_automute(struct hda_codec *codec)
14129{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014130 struct alc_spec *spec = codec->spec;
14131 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014132 unsigned int present;
14133 unsigned char bits;
14134
Kailang Yangebb83ee2009-12-17 12:23:00 +010014135 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014136 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014137 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014138 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014139 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014140 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014141}
14142
Kailang Yang60db6b52008-08-26 13:13:00 +020014143/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014144static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014145 unsigned int res)
14146{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014147 switch (res >> 26) {
14148 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014149 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014150 break;
14151 case ALC880_MIC_EVENT:
14152 alc_mic_automute(codec);
14153 break;
14154 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014155}
14156
Kailang Yang226b1ec2010-04-09 11:01:20 +020014157static void alc269_laptop_amic_setup(struct hda_codec *codec)
14158{
14159 struct alc_spec *spec = codec->spec;
14160 spec->autocfg.hp_pins[0] = 0x15;
14161 spec->autocfg.speaker_pins[0] = 0x14;
14162 spec->ext_mic.pin = 0x18;
14163 spec->ext_mic.mux_idx = 0;
14164 spec->int_mic.pin = 0x19;
14165 spec->int_mic.mux_idx = 1;
14166 spec->auto_mic = 1;
14167}
14168
Kailang Yang84898e82010-02-04 14:16:14 +010014169static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014170{
14171 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014172 spec->autocfg.hp_pins[0] = 0x15;
14173 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014174 spec->ext_mic.pin = 0x18;
14175 spec->ext_mic.mux_idx = 0;
14176 spec->int_mic.pin = 0x12;
14177 spec->int_mic.mux_idx = 5;
14178 spec->auto_mic = 1;
14179}
14180
Kailang Yang226b1ec2010-04-09 11:01:20 +020014181static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014182{
14183 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014184 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014185 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014186 spec->ext_mic.pin = 0x18;
14187 spec->ext_mic.mux_idx = 0;
14188 spec->int_mic.pin = 0x19;
14189 spec->int_mic.mux_idx = 1;
14190 spec->auto_mic = 1;
14191}
14192
Kailang Yang226b1ec2010-04-09 11:01:20 +020014193static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14194{
14195 struct alc_spec *spec = codec->spec;
14196 spec->autocfg.hp_pins[0] = 0x21;
14197 spec->autocfg.speaker_pins[0] = 0x14;
14198 spec->ext_mic.pin = 0x18;
14199 spec->ext_mic.mux_idx = 0;
14200 spec->int_mic.pin = 0x12;
14201 spec->int_mic.mux_idx = 6;
14202 spec->auto_mic = 1;
14203}
14204
Kailang Yang84898e82010-02-04 14:16:14 +010014205static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014206{
14207 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014208 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014209}
14210
Kailang Yangf6a92242007-12-13 16:52:54 +010014211/*
14212 * generic initialization of ADC, input mixers and output mixers
14213 */
14214static struct hda_verb alc269_init_verbs[] = {
14215 /*
14216 * Unmute ADC0 and set the default input to mic-in
14217 */
Kailang Yang84898e82010-02-04 14:16:14 +010014218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014219
14220 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014221 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014222 */
14223 /* set vol=0 to output mixers */
14224 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14225 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14226
14227 /* set up input amps for analog loopback */
14228 /* Amp Indices: DAC = 0, mixer = 1 */
14229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14233 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14234 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14235
14236 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14238 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14239 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14240 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14243
14244 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14245 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014246
Kailang Yang84898e82010-02-04 14:16:14 +010014247 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014248 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14249 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014250 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014251
14252 /* set EAPD */
14253 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014254 { }
14255};
14256
14257static struct hda_verb alc269vb_init_verbs[] = {
14258 /*
14259 * Unmute ADC0 and set the default input to mic-in
14260 */
14261 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14262
14263 /*
14264 * Set up output mixers (0x02 - 0x03)
14265 */
14266 /* set vol=0 to output mixers */
14267 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14268 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14269
14270 /* set up input amps for analog loopback */
14271 /* Amp Indices: DAC = 0, mixer = 1 */
14272 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14273 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14274 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14275 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14276 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14277 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14278
14279 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14280 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14281 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14282 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14283 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14284 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14285 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14286
14287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14288 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14289
14290 /* FIXME: use Mux-type input source selection */
14291 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14292 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14293 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14294
14295 /* set EAPD */
14296 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014297 { }
14298};
14299
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014300#define alc269_auto_create_multi_out_ctls \
14301 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014302#define alc269_auto_create_input_ctls \
14303 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014304
14305#ifdef CONFIG_SND_HDA_POWER_SAVE
14306#define alc269_loopbacks alc880_loopbacks
14307#endif
14308
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014309/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014310#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14311#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14312#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14313#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14314
Takashi Iwaif03d3112009-03-05 14:18:16 +010014315static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14316 .substreams = 1,
14317 .channels_min = 2,
14318 .channels_max = 8,
14319 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14320 /* NID is set in alc_build_pcms */
14321 .ops = {
14322 .open = alc880_playback_pcm_open,
14323 .prepare = alc880_playback_pcm_prepare,
14324 .cleanup = alc880_playback_pcm_cleanup
14325 },
14326};
14327
14328static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14329 .substreams = 1,
14330 .channels_min = 2,
14331 .channels_max = 2,
14332 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14333 /* NID is set in alc_build_pcms */
14334};
14335
Takashi Iwaiad358792010-03-30 18:00:59 +020014336#ifdef CONFIG_SND_HDA_POWER_SAVE
14337static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14338{
14339 switch (codec->subsystem_id) {
14340 case 0x103c1586:
14341 return 1;
14342 }
14343 return 0;
14344}
14345
14346static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14347{
14348 /* update mute-LED according to the speaker mute state */
14349 if (nid == 0x01 || nid == 0x14) {
14350 int pinval;
14351 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14352 HDA_AMP_MUTE)
14353 pinval = 0x24;
14354 else
14355 pinval = 0x20;
14356 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014357 snd_hda_codec_update_cache(codec, 0x19, 0,
14358 AC_VERB_SET_PIN_WIDGET_CONTROL,
14359 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014360 }
14361 return alc_check_power_status(codec, nid);
14362}
14363#endif /* CONFIG_SND_HDA_POWER_SAVE */
14364
Takashi Iwai840b64c2010-07-13 22:49:01 +020014365static int alc275_setup_dual_adc(struct hda_codec *codec)
14366{
14367 struct alc_spec *spec = codec->spec;
14368
14369 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14370 return 0;
14371 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14372 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14373 if (spec->ext_mic.pin <= 0x12) {
14374 spec->private_adc_nids[0] = 0x08;
14375 spec->private_adc_nids[1] = 0x11;
14376 spec->private_capsrc_nids[0] = 0x23;
14377 spec->private_capsrc_nids[1] = 0x22;
14378 } else {
14379 spec->private_adc_nids[0] = 0x11;
14380 spec->private_adc_nids[1] = 0x08;
14381 spec->private_capsrc_nids[0] = 0x22;
14382 spec->private_capsrc_nids[1] = 0x23;
14383 }
14384 spec->adc_nids = spec->private_adc_nids;
14385 spec->capsrc_nids = spec->private_capsrc_nids;
14386 spec->num_adc_nids = 2;
14387 spec->dual_adc_switch = 1;
14388 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14389 spec->adc_nids[0], spec->adc_nids[1]);
14390 return 1;
14391 }
14392 return 0;
14393}
14394
Kailang Yangf6a92242007-12-13 16:52:54 +010014395/*
14396 * BIOS auto configuration
14397 */
14398static int alc269_parse_auto_config(struct hda_codec *codec)
14399{
14400 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014401 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014402 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14403
14404 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14405 alc269_ignore);
14406 if (err < 0)
14407 return err;
14408
14409 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14410 if (err < 0)
14411 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014412 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014413 if (err < 0)
14414 return err;
14415
14416 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14417
Takashi Iwai757899a2010-07-30 10:48:14 +020014418 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014419
Takashi Iwai603c4012008-07-30 15:01:44 +020014420 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014421 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014422
Kailang Yang84898e82010-02-04 14:16:14 +010014423 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14424 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014425 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014426 } else {
14427 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014428 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014429 }
14430
Kailang Yangf6a92242007-12-13 16:52:54 +010014431 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014432 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014433
14434 if (!alc275_setup_dual_adc(codec))
14435 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14436 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014437
Takashi Iwaie01bf502008-08-21 16:25:07 +020014438 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014439 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014440 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14441 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014442
14443 err = alc_auto_add_mic_boost(codec);
14444 if (err < 0)
14445 return err;
14446
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014447 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014448 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014449
Kailang Yangf6a92242007-12-13 16:52:54 +010014450 return 1;
14451}
14452
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014453#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14454#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014455#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14456
14457
14458/* init callback for auto-configuration model -- overriding the default init */
14459static void alc269_auto_init(struct hda_codec *codec)
14460{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014461 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014462 alc269_auto_init_multi_out(codec);
14463 alc269_auto_init_hp_out(codec);
14464 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014465 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014466 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014467 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014468}
14469
Takashi Iwaiff818c22010-04-12 08:59:25 +020014470enum {
14471 ALC269_FIXUP_SONY_VAIO,
14472};
14473
Takashi Iwaiff818c22010-04-12 08:59:25 +020014474static const struct alc_fixup alc269_fixups[] = {
14475 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014476 .verbs = (const struct hda_verb[]) {
14477 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14478 {}
14479 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014480 },
14481};
14482
14483static struct snd_pci_quirk alc269_fixup_tbl[] = {
14484 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014485 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014486 {}
14487};
14488
14489
Kailang Yangf6a92242007-12-13 16:52:54 +010014490/*
14491 * configuration and preset
14492 */
14493static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014494 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014495 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014496 [ALC269_AMIC] = "laptop-amic",
14497 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014498 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014499 [ALC269_LIFEBOOK] = "lifebook",
14500 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014501};
14502
14503static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014504 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014505 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014506 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014507 ALC269_AMIC),
14508 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14509 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14510 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14511 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14512 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14513 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14514 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14515 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14516 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14517 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14518 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14519 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14520 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14521 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14522 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14523 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14524 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14525 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14526 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14527 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14528 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14529 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14530 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14531 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14532 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14533 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14534 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14535 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14536 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14537 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14538 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14539 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14540 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14541 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14542 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14543 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014544 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014545 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014546 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014547 ALC269_DMIC),
14548 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14549 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014550 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014551 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014552 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14553 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14554 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14555 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14556 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14557 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014558 {}
14559};
14560
14561static struct alc_config_preset alc269_presets[] = {
14562 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014563 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014564 .init_verbs = { alc269_init_verbs },
14565 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14566 .dac_nids = alc269_dac_nids,
14567 .hp_nid = 0x03,
14568 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14569 .channel_mode = alc269_modes,
14570 .input_mux = &alc269_capture_source,
14571 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014572 [ALC269_QUANTA_FL1] = {
14573 .mixers = { alc269_quanta_fl1_mixer },
14574 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14575 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14576 .dac_nids = alc269_dac_nids,
14577 .hp_nid = 0x03,
14578 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14579 .channel_mode = alc269_modes,
14580 .input_mux = &alc269_capture_source,
14581 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014582 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014583 .init_hook = alc269_quanta_fl1_init_hook,
14584 },
Kailang Yang84898e82010-02-04 14:16:14 +010014585 [ALC269_AMIC] = {
14586 .mixers = { alc269_laptop_mixer },
14587 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014588 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014589 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014590 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14591 .dac_nids = alc269_dac_nids,
14592 .hp_nid = 0x03,
14593 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14594 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014595 .unsol_event = alc269_laptop_unsol_event,
14596 .setup = alc269_laptop_amic_setup,
14597 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014598 },
Kailang Yang84898e82010-02-04 14:16:14 +010014599 [ALC269_DMIC] = {
14600 .mixers = { alc269_laptop_mixer },
14601 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014602 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014603 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014604 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14605 .dac_nids = alc269_dac_nids,
14606 .hp_nid = 0x03,
14607 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14608 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014609 .unsol_event = alc269_laptop_unsol_event,
14610 .setup = alc269_laptop_dmic_setup,
14611 .init_hook = alc269_laptop_inithook,
14612 },
14613 [ALC269VB_AMIC] = {
14614 .mixers = { alc269vb_laptop_mixer },
14615 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14616 .init_verbs = { alc269vb_init_verbs,
14617 alc269vb_laptop_amic_init_verbs },
14618 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14619 .dac_nids = alc269_dac_nids,
14620 .hp_nid = 0x03,
14621 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14622 .channel_mode = alc269_modes,
14623 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014624 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014625 .init_hook = alc269_laptop_inithook,
14626 },
14627 [ALC269VB_DMIC] = {
14628 .mixers = { alc269vb_laptop_mixer },
14629 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14630 .init_verbs = { alc269vb_init_verbs,
14631 alc269vb_laptop_dmic_init_verbs },
14632 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14633 .dac_nids = alc269_dac_nids,
14634 .hp_nid = 0x03,
14635 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14636 .channel_mode = alc269_modes,
14637 .unsol_event = alc269_laptop_unsol_event,
14638 .setup = alc269vb_laptop_dmic_setup,
14639 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014640 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014641 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014642 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014643 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014644 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014645 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014646 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14647 .dac_nids = alc269_dac_nids,
14648 .hp_nid = 0x03,
14649 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14650 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014651 .unsol_event = alc269_laptop_unsol_event,
14652 .setup = alc269_laptop_dmic_setup,
14653 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014654 },
Tony Vroon64154832008-11-06 15:08:49 +000014655 [ALC269_LIFEBOOK] = {
14656 .mixers = { alc269_lifebook_mixer },
14657 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14658 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14659 .dac_nids = alc269_dac_nids,
14660 .hp_nid = 0x03,
14661 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14662 .channel_mode = alc269_modes,
14663 .input_mux = &alc269_capture_source,
14664 .unsol_event = alc269_lifebook_unsol_event,
14665 .init_hook = alc269_lifebook_init_hook,
14666 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014667 [ALC271_ACER] = {
14668 .mixers = { alc269_asus_mixer },
14669 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14670 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14671 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14672 .dac_nids = alc269_dac_nids,
14673 .adc_nids = alc262_dmic_adc_nids,
14674 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14675 .capsrc_nids = alc262_dmic_capsrc_nids,
14676 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14677 .channel_mode = alc269_modes,
14678 .input_mux = &alc269_capture_source,
14679 .dig_out_nid = ALC880_DIGOUT_NID,
14680 .unsol_event = alc_sku_unsol_event,
14681 .setup = alc269vb_laptop_dmic_setup,
14682 .init_hook = alc_inithook,
14683 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014684};
14685
14686static int patch_alc269(struct hda_codec *codec)
14687{
14688 struct alc_spec *spec;
14689 int board_config;
14690 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014691 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014692
14693 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14694 if (spec == NULL)
14695 return -ENOMEM;
14696
14697 codec->spec = spec;
14698
Kailang Yangda00c242010-03-19 11:23:45 +010014699 alc_auto_parse_customize_define(codec);
14700
Kailang Yang274693f2009-12-03 10:07:50 +010014701 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014702 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14703 spec->cdefine.platform_type == 1)
14704 alc_codec_rename(codec, "ALC271X");
14705 else
14706 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014707 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014708 } else
14709 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014710
Kailang Yangf6a92242007-12-13 16:52:54 +010014711 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14712 alc269_models,
14713 alc269_cfg_tbl);
14714
14715 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014716 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14717 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014718 board_config = ALC269_AUTO;
14719 }
14720
Takashi Iwaiff818c22010-04-12 08:59:25 +020014721 if (board_config == ALC269_AUTO)
14722 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14723
Kailang Yangf6a92242007-12-13 16:52:54 +010014724 if (board_config == ALC269_AUTO) {
14725 /* automatic parse from the BIOS config */
14726 err = alc269_parse_auto_config(codec);
14727 if (err < 0) {
14728 alc_free(codec);
14729 return err;
14730 } else if (!err) {
14731 printk(KERN_INFO
14732 "hda_codec: Cannot set up configuration "
14733 "from BIOS. Using base mode...\n");
14734 board_config = ALC269_BASIC;
14735 }
14736 }
14737
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014738 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014739 err = snd_hda_attach_beep_device(codec, 0x1);
14740 if (err < 0) {
14741 alc_free(codec);
14742 return err;
14743 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014744 }
14745
Kailang Yangf6a92242007-12-13 16:52:54 +010014746 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014747 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014748
Kailang Yang84898e82010-02-04 14:16:14 +010014749 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014750 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14751 * fix the sample rate of analog I/O to 44.1kHz
14752 */
14753 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14754 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014755 } else if (spec->dual_adc_switch) {
14756 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14757 /* switch ADC dynamically */
14758 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014759 } else {
14760 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14761 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14762 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014763 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14764 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14765
Takashi Iwai66946352010-03-29 17:21:45 +020014766 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14767 if (!is_alc269vb) {
14768 spec->adc_nids = alc269_adc_nids;
14769 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14770 spec->capsrc_nids = alc269_capsrc_nids;
14771 } else {
14772 spec->adc_nids = alc269vb_adc_nids;
14773 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14774 spec->capsrc_nids = alc269vb_capsrc_nids;
14775 }
Kailang Yang84898e82010-02-04 14:16:14 +010014776 }
14777
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014778 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014779 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014780 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014781 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014782
Takashi Iwaiff818c22010-04-12 08:59:25 +020014783 if (board_config == ALC269_AUTO)
14784 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14785
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014786 spec->vmaster_nid = 0x02;
14787
Kailang Yangf6a92242007-12-13 16:52:54 +010014788 codec->patch_ops = alc_patch_ops;
14789 if (board_config == ALC269_AUTO)
14790 spec->init_hook = alc269_auto_init;
14791#ifdef CONFIG_SND_HDA_POWER_SAVE
14792 if (!spec->loopback.amplist)
14793 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014794 if (alc269_mic2_for_mute_led(codec))
14795 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014796#endif
14797
14798 return 0;
14799}
14800
14801/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014802 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14803 */
14804
14805/*
14806 * set the path ways for 2 channel output
14807 * need to set the codec line out and mic 1 pin widgets to inputs
14808 */
14809static struct hda_verb alc861_threestack_ch2_init[] = {
14810 /* set pin widget 1Ah (line in) for input */
14811 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014812 /* set pin widget 18h (mic1/2) for input, for mic also enable
14813 * the vref
14814 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014815 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14816
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014817 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14818#if 0
14819 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14820 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14821#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014822 { } /* end */
14823};
14824/*
14825 * 6ch mode
14826 * need to set the codec line out and mic 1 pin widgets to outputs
14827 */
14828static struct hda_verb alc861_threestack_ch6_init[] = {
14829 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14830 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14831 /* set pin widget 18h (mic1) for output (CLFE)*/
14832 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14833
14834 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014835 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014836
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014837 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14838#if 0
14839 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14840 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14841#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014842 { } /* end */
14843};
14844
14845static struct hda_channel_mode alc861_threestack_modes[2] = {
14846 { 2, alc861_threestack_ch2_init },
14847 { 6, alc861_threestack_ch6_init },
14848};
Takashi Iwai22309c32006-08-09 16:57:28 +020014849/* Set mic1 as input and unmute the mixer */
14850static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14851 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14852 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14853 { } /* end */
14854};
14855/* Set mic1 as output and mute mixer */
14856static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14857 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14859 { } /* end */
14860};
14861
14862static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14863 { 2, alc861_uniwill_m31_ch2_init },
14864 { 4, alc861_uniwill_m31_ch4_init },
14865};
Kailang Yangdf694da2005-12-05 19:42:22 +010014866
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014867/* Set mic1 and line-in as input and unmute the mixer */
14868static struct hda_verb alc861_asus_ch2_init[] = {
14869 /* set pin widget 1Ah (line in) for input */
14870 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014871 /* set pin widget 18h (mic1/2) for input, for mic also enable
14872 * the vref
14873 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014874 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14875
14876 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14877#if 0
14878 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14879 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14880#endif
14881 { } /* end */
14882};
14883/* Set mic1 nad line-in as output and mute mixer */
14884static struct hda_verb alc861_asus_ch6_init[] = {
14885 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14886 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14887 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14888 /* set pin widget 18h (mic1) for output (CLFE)*/
14889 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14890 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14891 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14892 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14893
14894 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14895#if 0
14896 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14897 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14898#endif
14899 { } /* end */
14900};
14901
14902static struct hda_channel_mode alc861_asus_modes[2] = {
14903 { 2, alc861_asus_ch2_init },
14904 { 6, alc861_asus_ch6_init },
14905};
14906
Kailang Yangdf694da2005-12-05 19:42:22 +010014907/* patch-ALC861 */
14908
14909static struct snd_kcontrol_new alc861_base_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 { } /* end */
14930};
14931
14932static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14933 /* output mixer control */
14934 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14935 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14936 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14937 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14938 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14939
14940 /* Input mixer control */
14941 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14942 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14943 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14944 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14945 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14946 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14947 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14948 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14949 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14950 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014951
Kailang Yangdf694da2005-12-05 19:42:22 +010014952 {
14953 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14954 .name = "Channel Mode",
14955 .info = alc_ch_mode_info,
14956 .get = alc_ch_mode_get,
14957 .put = alc_ch_mode_put,
14958 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14959 },
14960 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014961};
14962
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014963static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014964 /* output mixer control */
14965 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14966 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14967 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014968
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014969 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014970};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014971
Takashi Iwai22309c32006-08-09 16:57:28 +020014972static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14973 /* output mixer control */
14974 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14975 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14976 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14977 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14978 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14979
14980 /* Input mixer control */
14981 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14982 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14983 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14984 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14985 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14986 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14987 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14988 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14989 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014991
Takashi Iwai22309c32006-08-09 16:57:28 +020014992 {
14993 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14994 .name = "Channel Mode",
14995 .info = alc_ch_mode_info,
14996 .get = alc_ch_mode_get,
14997 .put = alc_ch_mode_put,
14998 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14999 },
15000 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015001};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015002
15003static struct snd_kcontrol_new alc861_asus_mixer[] = {
15004 /* output mixer control */
15005 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15006 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15007 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15008 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15009 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15010
15011 /* Input mixer control */
15012 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15013 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15014 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15015 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15016 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15017 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15019 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15020 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15022
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015023 {
15024 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15025 .name = "Channel Mode",
15026 .info = alc_ch_mode_info,
15027 .get = alc_ch_mode_get,
15028 .put = alc_ch_mode_put,
15029 .private_value = ARRAY_SIZE(alc861_asus_modes),
15030 },
15031 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015032};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015033
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015034/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015035static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015036 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15037 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015038 { }
15039};
15040
Kailang Yangdf694da2005-12-05 19:42:22 +010015041/*
15042 * generic initialization of ADC, input mixers and output mixers
15043 */
15044static struct hda_verb alc861_base_init_verbs[] = {
15045 /*
15046 * Unmute ADC0 and set the default input to mic-in
15047 */
15048 /* port-A for surround (rear panel) */
15049 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15050 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15051 /* port-B for mic-in (rear panel) with vref */
15052 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15053 /* port-C for line-in (rear panel) */
15054 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15055 /* port-D for Front */
15056 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15057 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15058 /* port-E for HP out (front panel) */
15059 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15060 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015061 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015062 /* port-F for mic-in (front panel) with vref */
15063 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15064 /* port-G for CLFE (rear panel) */
15065 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15066 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15067 /* port-H for side (rear panel) */
15068 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15069 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15070 /* CD-in */
15071 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15072 /* route front mic to ADC1*/
15073 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15074 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015075
Kailang Yangdf694da2005-12-05 19:42:22 +010015076 /* Unmute DAC0~3 & spdif out*/
15077 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15078 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15079 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15080 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15081 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015082
Kailang Yangdf694da2005-12-05 19:42:22 +010015083 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15084 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15085 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15086 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15087 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015088
Kailang Yangdf694da2005-12-05 19:42:22 +010015089 /* Unmute Stereo Mixer 15 */
15090 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015093 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015094
15095 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15096 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15097 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15098 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15099 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15100 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15101 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015103 /* hp used DAC 3 (Front) */
15104 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015105 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15106
15107 { }
15108};
15109
15110static struct hda_verb alc861_threestack_init_verbs[] = {
15111 /*
15112 * Unmute ADC0 and set the default input to mic-in
15113 */
15114 /* port-A for surround (rear panel) */
15115 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15116 /* port-B for mic-in (rear panel) with vref */
15117 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15118 /* port-C for line-in (rear panel) */
15119 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15120 /* port-D for Front */
15121 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15122 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15123 /* port-E for HP out (front panel) */
15124 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15125 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015126 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015127 /* port-F for mic-in (front panel) with vref */
15128 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15129 /* port-G for CLFE (rear panel) */
15130 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15131 /* port-H for side (rear panel) */
15132 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15133 /* CD-in */
15134 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15135 /* route front mic to ADC1*/
15136 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15137 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15138 /* Unmute DAC0~3 & spdif out*/
15139 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15140 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15141 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15142 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15143 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015144
Kailang Yangdf694da2005-12-05 19:42:22 +010015145 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15146 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15147 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15148 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15149 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015150
Kailang Yangdf694da2005-12-05 19:42:22 +010015151 /* Unmute Stereo Mixer 15 */
15152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15153 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015156
15157 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15158 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15159 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15161 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15162 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15164 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015165 /* hp used DAC 3 (Front) */
15166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15168 { }
15169};
Takashi Iwai22309c32006-08-09 16:57:28 +020015170
15171static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15172 /*
15173 * Unmute ADC0 and set the default input to mic-in
15174 */
15175 /* port-A for surround (rear panel) */
15176 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15177 /* port-B for mic-in (rear panel) with vref */
15178 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15179 /* port-C for line-in (rear panel) */
15180 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15181 /* port-D for Front */
15182 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15183 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15184 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015185 /* this has to be set to VREF80 */
15186 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015187 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015188 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015189 /* port-F for mic-in (front panel) with vref */
15190 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15191 /* port-G for CLFE (rear panel) */
15192 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15193 /* port-H for side (rear panel) */
15194 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15195 /* CD-in */
15196 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15197 /* route front mic to ADC1*/
15198 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15199 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15200 /* Unmute DAC0~3 & spdif out*/
15201 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15202 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15203 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15204 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015206
Takashi Iwai22309c32006-08-09 16:57:28 +020015207 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15208 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15209 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15210 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15211 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015212
Takashi Iwai22309c32006-08-09 16:57:28 +020015213 /* Unmute Stereo Mixer 15 */
15214 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15216 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015218
15219 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15220 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15221 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15222 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15223 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15225 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015227 /* hp used DAC 3 (Front) */
15228 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015229 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15230 { }
15231};
15232
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015233static struct hda_verb alc861_asus_init_verbs[] = {
15234 /*
15235 * Unmute ADC0 and set the default input to mic-in
15236 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015237 /* port-A for surround (rear panel)
15238 * according to codec#0 this is the HP jack
15239 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015240 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15241 /* route front PCM to HP */
15242 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15243 /* port-B for mic-in (rear panel) with vref */
15244 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15245 /* port-C for line-in (rear panel) */
15246 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15247 /* port-D for Front */
15248 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15249 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15250 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015251 /* this has to be set to VREF80 */
15252 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015253 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015254 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015255 /* port-F for mic-in (front panel) with vref */
15256 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15257 /* port-G for CLFE (rear panel) */
15258 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15259 /* port-H for side (rear panel) */
15260 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15261 /* CD-in */
15262 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15263 /* route front mic to ADC1*/
15264 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15266 /* Unmute DAC0~3 & spdif out*/
15267 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15269 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15270 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15271 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15272 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15273 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15274 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15275 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15276 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015277
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015278 /* Unmute Stereo Mixer 15 */
15279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15281 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015283
15284 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15285 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15286 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15287 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15288 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15289 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15290 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15291 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015292 /* hp used DAC 3 (Front) */
15293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15295 { }
15296};
15297
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015298/* additional init verbs for ASUS laptops */
15299static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15300 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15301 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15302 { }
15303};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015304
Kailang Yangdf694da2005-12-05 19:42:22 +010015305/*
15306 * generic initialization of ADC, input mixers and output mixers
15307 */
15308static struct hda_verb alc861_auto_init_verbs[] = {
15309 /*
15310 * Unmute ADC0 and set the default input to mic-in
15311 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015312 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015313 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015314
Kailang Yangdf694da2005-12-05 19:42:22 +010015315 /* Unmute DAC0~3 & spdif out*/
15316 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15317 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15318 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15319 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15320 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015321
Kailang Yangdf694da2005-12-05 19:42:22 +010015322 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15323 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15324 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15325 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15326 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015327
Kailang Yangdf694da2005-12-05 19:42:22 +010015328 /* Unmute Stereo Mixer 15 */
15329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15330 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15331 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15332 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15333
Takashi Iwai1c209302009-07-22 15:17:45 +020015334 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15335 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15336 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15337 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15339 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15341 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015342
15343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015345 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15346 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015347 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15348 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015349 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15350 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015351
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015352 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015353
15354 { }
15355};
15356
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015357static struct hda_verb alc861_toshiba_init_verbs[] = {
15358 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015359
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015360 { }
15361};
15362
15363/* toggle speaker-output according to the hp-jack state */
15364static void alc861_toshiba_automute(struct hda_codec *codec)
15365{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015366 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015367
Takashi Iwai47fd8302007-08-10 17:11:07 +020015368 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15369 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15370 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15371 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015372}
15373
15374static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15375 unsigned int res)
15376{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015377 if ((res >> 26) == ALC880_HP_EVENT)
15378 alc861_toshiba_automute(codec);
15379}
15380
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015381/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015382#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15383#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15384#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15385#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15386
15387
15388#define ALC861_DIGOUT_NID 0x07
15389
15390static struct hda_channel_mode alc861_8ch_modes[1] = {
15391 { 8, NULL }
15392};
15393
15394static hda_nid_t alc861_dac_nids[4] = {
15395 /* front, surround, clfe, side */
15396 0x03, 0x06, 0x05, 0x04
15397};
15398
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015399static hda_nid_t alc660_dac_nids[3] = {
15400 /* front, clfe, surround */
15401 0x03, 0x05, 0x06
15402};
15403
Kailang Yangdf694da2005-12-05 19:42:22 +010015404static hda_nid_t alc861_adc_nids[1] = {
15405 /* ADC0-2 */
15406 0x08,
15407};
15408
15409static struct hda_input_mux alc861_capture_source = {
15410 .num_items = 5,
15411 .items = {
15412 { "Mic", 0x0 },
15413 { "Front Mic", 0x3 },
15414 { "Line", 0x1 },
15415 { "CD", 0x4 },
15416 { "Mixer", 0x5 },
15417 },
15418};
15419
Takashi Iwai1c209302009-07-22 15:17:45 +020015420static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15421{
15422 struct alc_spec *spec = codec->spec;
15423 hda_nid_t mix, srcs[5];
15424 int i, j, num;
15425
15426 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15427 return 0;
15428 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15429 if (num < 0)
15430 return 0;
15431 for (i = 0; i < num; i++) {
15432 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015433 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015434 if (type != AC_WID_AUD_OUT)
15435 continue;
15436 for (j = 0; j < spec->multiout.num_dacs; j++)
15437 if (spec->multiout.dac_nids[j] == srcs[i])
15438 break;
15439 if (j >= spec->multiout.num_dacs)
15440 return srcs[i];
15441 }
15442 return 0;
15443}
15444
Kailang Yangdf694da2005-12-05 19:42:22 +010015445/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015446static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015447 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015448{
Takashi Iwai1c209302009-07-22 15:17:45 +020015449 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015450 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015451 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015452
15453 spec->multiout.dac_nids = spec->private_dac_nids;
15454 for (i = 0; i < cfg->line_outs; i++) {
15455 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015456 dac = alc861_look_for_dac(codec, nid);
15457 if (!dac)
15458 continue;
15459 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015460 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015461 return 0;
15462}
15463
Takashi Iwai1c209302009-07-22 15:17:45 +020015464static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15465 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015466{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015467 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015468 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15469}
15470
15471/* add playback controls from the parsed DAC table */
15472static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15473 const struct auto_pin_cfg *cfg)
15474{
15475 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015476 static const char *chname[4] = {
15477 "Front", "Surround", NULL /*CLFE*/, "Side"
15478 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015479 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015480 int i, err;
15481
15482 if (cfg->line_outs == 1) {
15483 const char *pfx = NULL;
15484 if (!cfg->hp_outs)
15485 pfx = "Master";
15486 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15487 pfx = "Speaker";
15488 if (pfx) {
15489 nid = spec->multiout.dac_nids[0];
15490 return alc861_create_out_sw(codec, pfx, nid, 3);
15491 }
15492 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015493
15494 for (i = 0; i < cfg->line_outs; i++) {
15495 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015496 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015497 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015498 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015499 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015500 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015501 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015502 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015503 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015504 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015505 return err;
15506 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015507 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015508 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015509 return err;
15510 }
15511 }
15512 return 0;
15513}
15514
Takashi Iwai1c209302009-07-22 15:17:45 +020015515static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015516{
Takashi Iwai1c209302009-07-22 15:17:45 +020015517 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015518 int err;
15519 hda_nid_t nid;
15520
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015521 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015522 return 0;
15523
15524 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015525 nid = alc861_look_for_dac(codec, pin);
15526 if (nid) {
15527 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15528 if (err < 0)
15529 return err;
15530 spec->multiout.hp_nid = nid;
15531 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015532 }
15533 return 0;
15534}
15535
15536/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015537static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015538 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015539{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015540 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015541}
15542
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015543static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15544 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015545 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015546{
Takashi Iwai1c209302009-07-22 15:17:45 +020015547 hda_nid_t mix, srcs[5];
15548 int i, num;
15549
Jacek Luczak564c5be2008-05-03 18:41:23 +020015550 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15551 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015552 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015553 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015554 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15555 return;
15556 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15557 if (num < 0)
15558 return;
15559 for (i = 0; i < num; i++) {
15560 unsigned int mute;
15561 if (srcs[i] == dac || srcs[i] == 0x15)
15562 mute = AMP_IN_UNMUTE(i);
15563 else
15564 mute = AMP_IN_MUTE(i);
15565 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15566 mute);
15567 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015568}
15569
15570static void alc861_auto_init_multi_out(struct hda_codec *codec)
15571{
15572 struct alc_spec *spec = codec->spec;
15573 int i;
15574
15575 for (i = 0; i < spec->autocfg.line_outs; i++) {
15576 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015577 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015578 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015579 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015580 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015581 }
15582}
15583
15584static void alc861_auto_init_hp_out(struct hda_codec *codec)
15585{
15586 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015587
Takashi Iwai15870f02009-10-05 08:25:13 +020015588 if (spec->autocfg.hp_outs)
15589 alc861_auto_set_output_and_unmute(codec,
15590 spec->autocfg.hp_pins[0],
15591 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015592 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015593 if (spec->autocfg.speaker_outs)
15594 alc861_auto_set_output_and_unmute(codec,
15595 spec->autocfg.speaker_pins[0],
15596 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015597 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015598}
15599
15600static void alc861_auto_init_analog_input(struct hda_codec *codec)
15601{
15602 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015603 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015604 int i;
15605
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015606 for (i = 0; i < cfg->num_inputs; i++) {
15607 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015608 if (nid >= 0x0c && nid <= 0x11)
15609 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 }
15611}
15612
15613/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015614/* return 1 if successful, 0 if the proper config is not found,
15615 * or a negative error code
15616 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015617static int alc861_parse_auto_config(struct hda_codec *codec)
15618{
15619 struct alc_spec *spec = codec->spec;
15620 int err;
15621 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015623 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15624 alc861_ignore);
15625 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015626 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015627 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015628 return 0; /* can't find valid BIOS pin config */
15629
Takashi Iwai1c209302009-07-22 15:17:45 +020015630 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015631 if (err < 0)
15632 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015633 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015634 if (err < 0)
15635 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015636 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015637 if (err < 0)
15638 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015639 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015640 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015641 return err;
15642
15643 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15644
Takashi Iwai757899a2010-07-30 10:48:14 +020015645 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015646
Takashi Iwai603c4012008-07-30 15:01:44 +020015647 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015648 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015649
Takashi Iwaid88897e2008-10-31 15:01:37 +010015650 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015651
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015652 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015653 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015654
15655 spec->adc_nids = alc861_adc_nids;
15656 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015657 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015658
Kailang Yang6227cdc2010-02-25 08:36:52 +010015659 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015660
Kailang Yangdf694da2005-12-05 19:42:22 +010015661 return 1;
15662}
15663
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015664/* additional initialization for auto-configuration model */
15665static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015666{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015667 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015668 alc861_auto_init_multi_out(codec);
15669 alc861_auto_init_hp_out(codec);
15670 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015671 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015672 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015673 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015674}
15675
Takashi Iwaicb53c622007-08-10 17:21:45 +020015676#ifdef CONFIG_SND_HDA_POWER_SAVE
15677static struct hda_amp_list alc861_loopbacks[] = {
15678 { 0x15, HDA_INPUT, 0 },
15679 { 0x15, HDA_INPUT, 1 },
15680 { 0x15, HDA_INPUT, 2 },
15681 { 0x15, HDA_INPUT, 3 },
15682 { } /* end */
15683};
15684#endif
15685
Kailang Yangdf694da2005-12-05 19:42:22 +010015686
15687/*
15688 * configuration and preset
15689 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015690static const char *alc861_models[ALC861_MODEL_LAST] = {
15691 [ALC861_3ST] = "3stack",
15692 [ALC660_3ST] = "3stack-660",
15693 [ALC861_3ST_DIG] = "3stack-dig",
15694 [ALC861_6ST_DIG] = "6stack-dig",
15695 [ALC861_UNIWILL_M31] = "uniwill-m31",
15696 [ALC861_TOSHIBA] = "toshiba",
15697 [ALC861_ASUS] = "asus",
15698 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15699 [ALC861_AUTO] = "auto",
15700};
15701
15702static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015703 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015704 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15705 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15706 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015707 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015708 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015709 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015710 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15711 * Any other models that need this preset?
15712 */
15713 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015714 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15715 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015716 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15717 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15718 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15719 /* FIXME: the below seems conflict */
15720 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15721 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15722 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015723 {}
15724};
15725
15726static struct alc_config_preset alc861_presets[] = {
15727 [ALC861_3ST] = {
15728 .mixers = { alc861_3ST_mixer },
15729 .init_verbs = { alc861_threestack_init_verbs },
15730 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15731 .dac_nids = alc861_dac_nids,
15732 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15733 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015734 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015735 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15736 .adc_nids = alc861_adc_nids,
15737 .input_mux = &alc861_capture_source,
15738 },
15739 [ALC861_3ST_DIG] = {
15740 .mixers = { alc861_base_mixer },
15741 .init_verbs = { alc861_threestack_init_verbs },
15742 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15743 .dac_nids = alc861_dac_nids,
15744 .dig_out_nid = ALC861_DIGOUT_NID,
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,
Kailang Yangdf694da2005-12-05 19:42:22 +010015748 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15749 .adc_nids = alc861_adc_nids,
15750 .input_mux = &alc861_capture_source,
15751 },
15752 [ALC861_6ST_DIG] = {
15753 .mixers = { alc861_base_mixer },
15754 .init_verbs = { alc861_base_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_8ch_modes),
15759 .channel_mode = alc861_8ch_modes,
15760 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15761 .adc_nids = alc861_adc_nids,
15762 .input_mux = &alc861_capture_source,
15763 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015764 [ALC660_3ST] = {
15765 .mixers = { alc861_3ST_mixer },
15766 .init_verbs = { alc861_threestack_init_verbs },
15767 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15768 .dac_nids = alc660_dac_nids,
15769 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15770 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015771 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015772 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15773 .adc_nids = alc861_adc_nids,
15774 .input_mux = &alc861_capture_source,
15775 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015776 [ALC861_UNIWILL_M31] = {
15777 .mixers = { alc861_uniwill_m31_mixer },
15778 .init_verbs = { alc861_uniwill_m31_init_verbs },
15779 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15780 .dac_nids = alc861_dac_nids,
15781 .dig_out_nid = ALC861_DIGOUT_NID,
15782 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15783 .channel_mode = alc861_uniwill_m31_modes,
15784 .need_dac_fix = 1,
15785 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15786 .adc_nids = alc861_adc_nids,
15787 .input_mux = &alc861_capture_source,
15788 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015789 [ALC861_TOSHIBA] = {
15790 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015791 .init_verbs = { alc861_base_init_verbs,
15792 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015793 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15794 .dac_nids = alc861_dac_nids,
15795 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15796 .channel_mode = alc883_3ST_2ch_modes,
15797 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15798 .adc_nids = alc861_adc_nids,
15799 .input_mux = &alc861_capture_source,
15800 .unsol_event = alc861_toshiba_unsol_event,
15801 .init_hook = alc861_toshiba_automute,
15802 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015803 [ALC861_ASUS] = {
15804 .mixers = { alc861_asus_mixer },
15805 .init_verbs = { alc861_asus_init_verbs },
15806 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15807 .dac_nids = alc861_dac_nids,
15808 .dig_out_nid = ALC861_DIGOUT_NID,
15809 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15810 .channel_mode = alc861_asus_modes,
15811 .need_dac_fix = 1,
15812 .hp_nid = 0x06,
15813 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15814 .adc_nids = alc861_adc_nids,
15815 .input_mux = &alc861_capture_source,
15816 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015817 [ALC861_ASUS_LAPTOP] = {
15818 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15819 .init_verbs = { alc861_asus_init_verbs,
15820 alc861_asus_laptop_init_verbs },
15821 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15822 .dac_nids = alc861_dac_nids,
15823 .dig_out_nid = ALC861_DIGOUT_NID,
15824 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15825 .channel_mode = alc883_3ST_2ch_modes,
15826 .need_dac_fix = 1,
15827 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15828 .adc_nids = alc861_adc_nids,
15829 .input_mux = &alc861_capture_source,
15830 },
15831};
Kailang Yangdf694da2005-12-05 19:42:22 +010015832
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015833/* Pin config fixes */
15834enum {
15835 PINFIX_FSC_AMILO_PI1505,
15836};
15837
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015838static const struct alc_fixup alc861_fixups[] = {
15839 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020015840 .pins = (const struct alc_pincfg[]) {
15841 { 0x0b, 0x0221101f }, /* HP */
15842 { 0x0f, 0x90170310 }, /* speaker */
15843 { }
15844 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015845 },
15846};
15847
15848static struct snd_pci_quirk alc861_fixup_tbl[] = {
15849 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15850 {}
15851};
Kailang Yangdf694da2005-12-05 19:42:22 +010015852
15853static int patch_alc861(struct hda_codec *codec)
15854{
15855 struct alc_spec *spec;
15856 int board_config;
15857 int err;
15858
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015859 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015860 if (spec == NULL)
15861 return -ENOMEM;
15862
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015863 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015864
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015865 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15866 alc861_models,
15867 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015868
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015869 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015870 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15871 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015872 board_config = ALC861_AUTO;
15873 }
15874
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015875 if (board_config == ALC861_AUTO)
15876 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015877
Kailang Yangdf694da2005-12-05 19:42:22 +010015878 if (board_config == ALC861_AUTO) {
15879 /* automatic parse from the BIOS config */
15880 err = alc861_parse_auto_config(codec);
15881 if (err < 0) {
15882 alc_free(codec);
15883 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015884 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015885 printk(KERN_INFO
15886 "hda_codec: Cannot set up configuration "
15887 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015888 board_config = ALC861_3ST_DIG;
15889 }
15890 }
15891
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015892 err = snd_hda_attach_beep_device(codec, 0x23);
15893 if (err < 0) {
15894 alc_free(codec);
15895 return err;
15896 }
15897
Kailang Yangdf694da2005-12-05 19:42:22 +010015898 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015899 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015900
Kailang Yangdf694da2005-12-05 19:42:22 +010015901 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15902 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15903
Kailang Yangdf694da2005-12-05 19:42:22 +010015904 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15905 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15906
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015907 if (!spec->cap_mixer)
15908 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015909 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15910
Takashi Iwai2134ea42008-01-10 16:53:55 +010015911 spec->vmaster_nid = 0x03;
15912
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015913 if (board_config == ALC861_AUTO)
15914 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15915
Kailang Yangdf694da2005-12-05 19:42:22 +010015916 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015917 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015918 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015919#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015920 spec->power_hook = alc_power_eapd;
15921#endif
15922 }
15923#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015924 if (!spec->loopback.amplist)
15925 spec->loopback.amplist = alc861_loopbacks;
15926#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015927
Kailang Yangdf694da2005-12-05 19:42:22 +010015928 return 0;
15929}
15930
15931/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015932 * ALC861-VD support
15933 *
15934 * Based on ALC882
15935 *
15936 * In addition, an independent DAC
15937 */
15938#define ALC861VD_DIGOUT_NID 0x06
15939
15940static hda_nid_t alc861vd_dac_nids[4] = {
15941 /* front, surr, clfe, side surr */
15942 0x02, 0x03, 0x04, 0x05
15943};
15944
15945/* dac_nids for ALC660vd are in a different order - according to
15946 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015947 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015948 * of ALC660vd codecs, but for now there is only 3stack mixer
15949 * - and it is the same as in 861vd.
15950 * adc_nids in ALC660vd are (is) the same as in 861vd
15951 */
15952static hda_nid_t alc660vd_dac_nids[3] = {
15953 /* front, rear, clfe, rear_surr */
15954 0x02, 0x04, 0x03
15955};
15956
15957static hda_nid_t alc861vd_adc_nids[1] = {
15958 /* ADC0 */
15959 0x09,
15960};
15961
Takashi Iwaie1406342008-02-11 18:32:32 +010015962static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15963
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015964/* input MUX */
15965/* FIXME: should be a matrix-type input source selection */
15966static struct hda_input_mux alc861vd_capture_source = {
15967 .num_items = 4,
15968 .items = {
15969 { "Mic", 0x0 },
15970 { "Front Mic", 0x1 },
15971 { "Line", 0x2 },
15972 { "CD", 0x4 },
15973 },
15974};
15975
Kailang Yang272a5272007-05-14 11:00:38 +020015976static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015977 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015978 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015979 { "Ext Mic", 0x0 },
15980 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015981 },
15982};
15983
Kailang Yangd1a991a2007-08-15 16:21:59 +020015984static struct hda_input_mux alc861vd_hp_capture_source = {
15985 .num_items = 2,
15986 .items = {
15987 { "Front Mic", 0x0 },
15988 { "ATAPI Mic", 0x1 },
15989 },
15990};
15991
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015992/*
15993 * 2ch mode
15994 */
15995static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15996 { 2, NULL }
15997};
15998
15999/*
16000 * 6ch mode
16001 */
16002static struct hda_verb alc861vd_6stack_ch6_init[] = {
16003 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16004 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16005 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16006 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16007 { } /* end */
16008};
16009
16010/*
16011 * 8ch mode
16012 */
16013static struct hda_verb alc861vd_6stack_ch8_init[] = {
16014 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16015 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16016 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16017 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16018 { } /* end */
16019};
16020
16021static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16022 { 6, alc861vd_6stack_ch6_init },
16023 { 8, alc861vd_6stack_ch8_init },
16024};
16025
16026static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16027 {
16028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16029 .name = "Channel Mode",
16030 .info = alc_ch_mode_info,
16031 .get = alc_ch_mode_get,
16032 .put = alc_ch_mode_put,
16033 },
16034 { } /* end */
16035};
16036
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016037/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16038 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16039 */
16040static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16041 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16042 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16043
16044 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16045 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16046
16047 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16048 HDA_OUTPUT),
16049 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16050 HDA_OUTPUT),
16051 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16052 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16053
16054 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16055 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16056
16057 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16058
16059 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16060 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16061 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16062
16063 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16064 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16065 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16066
16067 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16068 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16069
16070 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16071 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16072
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016073 { } /* end */
16074};
16075
16076static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16077 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16078 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16091 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16092
16093 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16094 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16095
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016096 { } /* end */
16097};
16098
Kailang Yangbdd148a2007-05-08 15:19:08 +020016099static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16100 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16101 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16102 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16103
16104 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16105
16106 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16109
16110 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16111 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16112 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16113
16114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16116
16117 { } /* end */
16118};
16119
Tobin Davisb419f342008-03-07 11:57:51 +010016120/* Pin assignment: Speaker=0x14, HP = 0x15,
16121 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016122 */
16123static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016124 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16125 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016126 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16127 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016128 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16129 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16130 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16131 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16132 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16133 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016134 { } /* end */
16135};
16136
Kailang Yangd1a991a2007-08-15 16:21:59 +020016137/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16138 * Front Mic=0x18, ATAPI Mic = 0x19,
16139 */
16140static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16141 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16142 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16143 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16144 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16145 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16146 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16147 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16148 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016149
Kailang Yangd1a991a2007-08-15 16:21:59 +020016150 { } /* end */
16151};
16152
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016153/*
16154 * generic initialization of ADC, input mixers and output mixers
16155 */
16156static struct hda_verb alc861vd_volume_init_verbs[] = {
16157 /*
16158 * Unmute ADC0 and set the default input to mic-in
16159 */
16160 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16161 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16162
16163 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16164 * the analog-loopback mixer widget
16165 */
16166 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16168 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16169 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16170 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16171 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016172
16173 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016177 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016178
16179 /*
16180 * Set up output mixers (0x02 - 0x05)
16181 */
16182 /* set vol=0 to output mixers */
16183 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16184 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16185 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16186 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16187
16188 /* set up input amps for analog loopback */
16189 /* Amp Indices: DAC = 0, mixer = 1 */
16190 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16191 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16192 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16194 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16196 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16197 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16198
16199 { }
16200};
16201
16202/*
16203 * 3-stack pin configuration:
16204 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16205 */
16206static struct hda_verb alc861vd_3stack_init_verbs[] = {
16207 /*
16208 * Set pin mode and muting
16209 */
16210 /* set front pin widgets 0x14 for output */
16211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16213 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16214
16215 /* Mic (rear) pin: input vref at 80% */
16216 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16217 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16218 /* Front Mic pin: input vref at 80% */
16219 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16220 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16221 /* Line In pin: input */
16222 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16223 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16224 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16226 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16227 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16228 /* CD pin widget for input */
16229 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16230
16231 { }
16232};
16233
16234/*
16235 * 6-stack pin configuration:
16236 */
16237static struct hda_verb alc861vd_6stack_init_verbs[] = {
16238 /*
16239 * Set pin mode and muting
16240 */
16241 /* set front pin widgets 0x14 for output */
16242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16243 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16244 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16245
16246 /* Rear Pin: output 1 (0x0d) */
16247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16248 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16249 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16250 /* CLFE Pin: output 2 (0x0e) */
16251 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16252 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16253 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16254 /* Side Pin: output 3 (0x0f) */
16255 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16256 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16257 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16258
16259 /* Mic (rear) pin: input vref at 80% */
16260 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16261 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16262 /* Front Mic pin: input vref at 80% */
16263 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16265 /* Line In pin: input */
16266 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16267 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16268 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16269 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16270 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16271 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16272 /* CD pin widget for input */
16273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16274
16275 { }
16276};
16277
Kailang Yangbdd148a2007-05-08 15:19:08 +020016278static struct hda_verb alc861vd_eapd_verbs[] = {
16279 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16280 { }
16281};
16282
Kailang Yangf9423e72008-05-27 12:32:25 +020016283static struct hda_verb alc660vd_eapd_verbs[] = {
16284 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16285 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16286 { }
16287};
16288
Kailang Yangbdd148a2007-05-08 15:19:08 +020016289static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16293 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016294 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016295 {}
16296};
16297
Kailang Yangbdd148a2007-05-08 15:19:08 +020016298static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16299{
16300 unsigned int present;
16301 unsigned char bits;
16302
Wu Fengguang864f92b2009-11-18 12:38:02 +080016303 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016304 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016305
Takashi Iwai47fd8302007-08-10 17:11:07 +020016306 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16307 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016308}
16309
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016310static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016311{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016312 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016313 spec->autocfg.hp_pins[0] = 0x1b;
16314 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016315}
16316
16317static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16318{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016319 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016320 alc861vd_lenovo_mic_automute(codec);
16321}
16322
16323static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16324 unsigned int res)
16325{
16326 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016327 case ALC880_MIC_EVENT:
16328 alc861vd_lenovo_mic_automute(codec);
16329 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016330 default:
16331 alc_automute_amp_unsol_event(codec, res);
16332 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016333 }
16334}
16335
Kailang Yang272a5272007-05-14 11:00:38 +020016336static struct hda_verb alc861vd_dallas_verbs[] = {
16337 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16338 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16339 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16340 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16341
16342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16348 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16349 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016350
Kailang Yang272a5272007-05-14 11:00:38 +020016351 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16356 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16357 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16358 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16359
16360 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16361 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16364 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16365 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16366 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16367 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16368
16369 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16370 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16371 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16372 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16373
16374 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016375 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16377
16378 { } /* end */
16379};
16380
16381/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016382static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016383{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016384 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016385
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016386 spec->autocfg.hp_pins[0] = 0x15;
16387 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016388}
16389
Takashi Iwaicb53c622007-08-10 17:21:45 +020016390#ifdef CONFIG_SND_HDA_POWER_SAVE
16391#define alc861vd_loopbacks alc880_loopbacks
16392#endif
16393
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016394/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016395#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16396#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16397#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16398#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16399
16400/*
16401 * configuration and preset
16402 */
16403static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16404 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016405 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016406 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016407 [ALC861VD_3ST] = "3stack",
16408 [ALC861VD_3ST_DIG] = "3stack-digout",
16409 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016410 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016411 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016412 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016413 [ALC861VD_AUTO] = "auto",
16414};
16415
16416static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016417 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16418 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016419 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016420 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016421 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016422 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016423 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016424 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016425 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016426 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016427 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016428 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016429 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016430 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016431 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016432 {}
16433};
16434
16435static struct alc_config_preset alc861vd_presets[] = {
16436 [ALC660VD_3ST] = {
16437 .mixers = { alc861vd_3st_mixer },
16438 .init_verbs = { alc861vd_volume_init_verbs,
16439 alc861vd_3stack_init_verbs },
16440 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16441 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016442 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16443 .channel_mode = alc861vd_3stack_2ch_modes,
16444 .input_mux = &alc861vd_capture_source,
16445 },
Mike Crash6963f842007-06-25 12:12:51 +020016446 [ALC660VD_3ST_DIG] = {
16447 .mixers = { alc861vd_3st_mixer },
16448 .init_verbs = { alc861vd_volume_init_verbs,
16449 alc861vd_3stack_init_verbs },
16450 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16451 .dac_nids = alc660vd_dac_nids,
16452 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016453 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16454 .channel_mode = alc861vd_3stack_2ch_modes,
16455 .input_mux = &alc861vd_capture_source,
16456 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016457 [ALC861VD_3ST] = {
16458 .mixers = { alc861vd_3st_mixer },
16459 .init_verbs = { alc861vd_volume_init_verbs,
16460 alc861vd_3stack_init_verbs },
16461 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16462 .dac_nids = alc861vd_dac_nids,
16463 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16464 .channel_mode = alc861vd_3stack_2ch_modes,
16465 .input_mux = &alc861vd_capture_source,
16466 },
16467 [ALC861VD_3ST_DIG] = {
16468 .mixers = { alc861vd_3st_mixer },
16469 .init_verbs = { alc861vd_volume_init_verbs,
16470 alc861vd_3stack_init_verbs },
16471 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16472 .dac_nids = alc861vd_dac_nids,
16473 .dig_out_nid = ALC861VD_DIGOUT_NID,
16474 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16475 .channel_mode = alc861vd_3stack_2ch_modes,
16476 .input_mux = &alc861vd_capture_source,
16477 },
16478 [ALC861VD_6ST_DIG] = {
16479 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16480 .init_verbs = { alc861vd_volume_init_verbs,
16481 alc861vd_6stack_init_verbs },
16482 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16483 .dac_nids = alc861vd_dac_nids,
16484 .dig_out_nid = ALC861VD_DIGOUT_NID,
16485 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16486 .channel_mode = alc861vd_6stack_modes,
16487 .input_mux = &alc861vd_capture_source,
16488 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016489 [ALC861VD_LENOVO] = {
16490 .mixers = { alc861vd_lenovo_mixer },
16491 .init_verbs = { alc861vd_volume_init_verbs,
16492 alc861vd_3stack_init_verbs,
16493 alc861vd_eapd_verbs,
16494 alc861vd_lenovo_unsol_verbs },
16495 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16496 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016497 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16498 .channel_mode = alc861vd_3stack_2ch_modes,
16499 .input_mux = &alc861vd_capture_source,
16500 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016501 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016502 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016503 },
Kailang Yang272a5272007-05-14 11:00:38 +020016504 [ALC861VD_DALLAS] = {
16505 .mixers = { alc861vd_dallas_mixer },
16506 .init_verbs = { alc861vd_dallas_verbs },
16507 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16508 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016509 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16510 .channel_mode = alc861vd_3stack_2ch_modes,
16511 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016512 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016513 .setup = alc861vd_dallas_setup,
16514 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016515 },
16516 [ALC861VD_HP] = {
16517 .mixers = { alc861vd_hp_mixer },
16518 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16519 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16520 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016521 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016522 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16523 .channel_mode = alc861vd_3stack_2ch_modes,
16524 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016525 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016526 .setup = alc861vd_dallas_setup,
16527 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016528 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016529 [ALC660VD_ASUS_V1S] = {
16530 .mixers = { alc861vd_lenovo_mixer },
16531 .init_verbs = { alc861vd_volume_init_verbs,
16532 alc861vd_3stack_init_verbs,
16533 alc861vd_eapd_verbs,
16534 alc861vd_lenovo_unsol_verbs },
16535 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16536 .dac_nids = alc660vd_dac_nids,
16537 .dig_out_nid = ALC861VD_DIGOUT_NID,
16538 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16539 .channel_mode = alc861vd_3stack_2ch_modes,
16540 .input_mux = &alc861vd_capture_source,
16541 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016542 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016543 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016544 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016545};
16546
16547/*
16548 * BIOS auto configuration
16549 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016550static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16551 const struct auto_pin_cfg *cfg)
16552{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016553 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016554}
16555
16556
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016557static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16558 hda_nid_t nid, int pin_type, int dac_idx)
16559{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016560 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016561}
16562
16563static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16564{
16565 struct alc_spec *spec = codec->spec;
16566 int i;
16567
16568 for (i = 0; i <= HDA_SIDE; i++) {
16569 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016570 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016571 if (nid)
16572 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016573 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016574 }
16575}
16576
16577
16578static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16579{
16580 struct alc_spec *spec = codec->spec;
16581 hda_nid_t pin;
16582
16583 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016584 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016585 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016586 pin = spec->autocfg.speaker_pins[0];
16587 if (pin)
16588 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016589}
16590
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016591#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16592
16593static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16594{
16595 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016596 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016597 int i;
16598
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016599 for (i = 0; i < cfg->num_inputs; i++) {
16600 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016601 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016602 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016603 if (nid != ALC861VD_PIN_CD_NID &&
16604 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016605 snd_hda_codec_write(codec, nid, 0,
16606 AC_VERB_SET_AMP_GAIN_MUTE,
16607 AMP_OUT_MUTE);
16608 }
16609 }
16610}
16611
Takashi Iwaif511b012008-08-15 16:46:42 +020016612#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16613
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016614#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16615#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16616
16617/* add playback controls from the parsed DAC table */
16618/* Based on ALC880 version. But ALC861VD has separate,
16619 * different NIDs for mute/unmute switch and volume control */
16620static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16621 const struct auto_pin_cfg *cfg)
16622{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016623 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16624 hda_nid_t nid_v, nid_s;
16625 int i, err;
16626
16627 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016628 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016629 continue;
16630 nid_v = alc861vd_idx_to_mixer_vol(
16631 alc880_dac_to_idx(
16632 spec->multiout.dac_nids[i]));
16633 nid_s = alc861vd_idx_to_mixer_switch(
16634 alc880_dac_to_idx(
16635 spec->multiout.dac_nids[i]));
16636
16637 if (i == 2) {
16638 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016639 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16640 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016641 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16642 HDA_OUTPUT));
16643 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016644 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016645 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16646 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016647 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16648 HDA_OUTPUT));
16649 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016650 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016651 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16652 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016653 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16654 HDA_INPUT));
16655 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016656 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016657 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16658 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016659 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16660 HDA_INPUT));
16661 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016662 return err;
16663 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016664 const char *pfx;
16665 if (cfg->line_outs == 1 &&
16666 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16667 if (!cfg->hp_pins)
16668 pfx = "Speaker";
16669 else
16670 pfx = "PCM";
16671 } else
16672 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016673 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016674 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16675 HDA_OUTPUT));
16676 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016677 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016678 if (cfg->line_outs == 1 &&
16679 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16680 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016681 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016682 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016683 HDA_INPUT));
16684 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016685 return err;
16686 }
16687 }
16688 return 0;
16689}
16690
16691/* add playback controls for speaker and HP outputs */
16692/* Based on ALC880 version. But ALC861VD has separate,
16693 * different NIDs for mute/unmute switch and volume control */
16694static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16695 hda_nid_t pin, const char *pfx)
16696{
16697 hda_nid_t nid_v, nid_s;
16698 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016699
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016700 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016701 return 0;
16702
16703 if (alc880_is_fixed_pin(pin)) {
16704 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16705 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016706 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016707 spec->multiout.hp_nid = nid_v;
16708 else
16709 spec->multiout.extra_out_nid[0] = nid_v;
16710 /* control HP volume/switch on the output mixer amp */
16711 nid_v = alc861vd_idx_to_mixer_vol(
16712 alc880_fixed_pin_idx(pin));
16713 nid_s = alc861vd_idx_to_mixer_switch(
16714 alc880_fixed_pin_idx(pin));
16715
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016716 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016717 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16718 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016719 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016720 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016721 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16722 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016723 return err;
16724 } else if (alc880_is_multi_pin(pin)) {
16725 /* set manual connection */
16726 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016727 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016728 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16729 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016730 return err;
16731 }
16732 return 0;
16733}
16734
16735/* parse the BIOS configuration and set up the alc_spec
16736 * return 1 if successful, 0 if the proper config is not found,
16737 * or a negative error code
16738 * Based on ALC880 version - had to change it to override
16739 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16740static int alc861vd_parse_auto_config(struct hda_codec *codec)
16741{
16742 struct alc_spec *spec = codec->spec;
16743 int err;
16744 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16745
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016746 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16747 alc861vd_ignore);
16748 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016749 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016750 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016751 return 0; /* can't find valid BIOS pin config */
16752
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016753 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16754 if (err < 0)
16755 return err;
16756 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16757 if (err < 0)
16758 return err;
16759 err = alc861vd_auto_create_extra_out(spec,
16760 spec->autocfg.speaker_pins[0],
16761 "Speaker");
16762 if (err < 0)
16763 return err;
16764 err = alc861vd_auto_create_extra_out(spec,
16765 spec->autocfg.hp_pins[0],
16766 "Headphone");
16767 if (err < 0)
16768 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016769 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016770 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016771 return err;
16772
16773 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16774
Takashi Iwai757899a2010-07-30 10:48:14 +020016775 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016776
Takashi Iwai603c4012008-07-30 15:01:44 +020016777 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016778 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016779
Takashi Iwaid88897e2008-10-31 15:01:37 +010016780 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016781
16782 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016783 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016784
Takashi Iwai776e1842007-08-29 15:07:11 +020016785 err = alc_auto_add_mic_boost(codec);
16786 if (err < 0)
16787 return err;
16788
Kailang Yang6227cdc2010-02-25 08:36:52 +010016789 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016790
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016791 return 1;
16792}
16793
16794/* additional initialization for auto-configuration model */
16795static void alc861vd_auto_init(struct hda_codec *codec)
16796{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016797 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016798 alc861vd_auto_init_multi_out(codec);
16799 alc861vd_auto_init_hp_out(codec);
16800 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016801 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016802 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016803 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016804 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016805}
16806
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016807enum {
16808 ALC660VD_FIX_ASUS_GPIO1
16809};
16810
16811/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016812static const struct alc_fixup alc861vd_fixups[] = {
16813 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016814 .verbs = (const struct hda_verb[]) {
16815 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16816 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16817 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16818 { }
16819 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016820 },
16821};
16822
16823static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16824 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16825 {}
16826};
16827
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016828static int patch_alc861vd(struct hda_codec *codec)
16829{
16830 struct alc_spec *spec;
16831 int err, board_config;
16832
16833 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16834 if (spec == NULL)
16835 return -ENOMEM;
16836
16837 codec->spec = spec;
16838
16839 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16840 alc861vd_models,
16841 alc861vd_cfg_tbl);
16842
16843 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016844 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16845 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016846 board_config = ALC861VD_AUTO;
16847 }
16848
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016849 if (board_config == ALC861VD_AUTO)
16850 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016851
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016852 if (board_config == ALC861VD_AUTO) {
16853 /* automatic parse from the BIOS config */
16854 err = alc861vd_parse_auto_config(codec);
16855 if (err < 0) {
16856 alc_free(codec);
16857 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016858 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016859 printk(KERN_INFO
16860 "hda_codec: Cannot set up configuration "
16861 "from BIOS. Using base mode...\n");
16862 board_config = ALC861VD_3ST;
16863 }
16864 }
16865
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016866 err = snd_hda_attach_beep_device(codec, 0x23);
16867 if (err < 0) {
16868 alc_free(codec);
16869 return err;
16870 }
16871
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016872 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016873 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016874
Kailang Yang2f893282008-05-27 12:14:47 +020016875 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016876 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016877 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016878 }
16879
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016880 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16881 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16882
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016883 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16884 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16885
Takashi Iwaidd704692009-08-11 08:45:11 +020016886 if (!spec->adc_nids) {
16887 spec->adc_nids = alc861vd_adc_nids;
16888 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16889 }
16890 if (!spec->capsrc_nids)
16891 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016892
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016893 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016894 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016895
Takashi Iwai2134ea42008-01-10 16:53:55 +010016896 spec->vmaster_nid = 0x02;
16897
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016898 if (board_config == ALC861VD_AUTO)
16899 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16900
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016901 codec->patch_ops = alc_patch_ops;
16902
16903 if (board_config == ALC861VD_AUTO)
16904 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016905#ifdef CONFIG_SND_HDA_POWER_SAVE
16906 if (!spec->loopback.amplist)
16907 spec->loopback.amplist = alc861vd_loopbacks;
16908#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016909
16910 return 0;
16911}
16912
16913/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016914 * ALC662 support
16915 *
16916 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16917 * configuration. Each pin widget can choose any input DACs and a mixer.
16918 * Each ADC is connected from a mixer of all inputs. This makes possible
16919 * 6-channel independent captures.
16920 *
16921 * In addition, an independent DAC for the multi-playback (not used in this
16922 * driver yet).
16923 */
16924#define ALC662_DIGOUT_NID 0x06
16925#define ALC662_DIGIN_NID 0x0a
16926
16927static hda_nid_t alc662_dac_nids[4] = {
16928 /* front, rear, clfe, rear_surr */
16929 0x02, 0x03, 0x04
16930};
16931
Kailang Yang622e84c2009-04-21 07:39:04 +020016932static hda_nid_t alc272_dac_nids[2] = {
16933 0x02, 0x03
16934};
16935
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016936static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016937 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016938 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016939};
Takashi Iwaie1406342008-02-11 18:32:32 +010016940
Kailang Yang622e84c2009-04-21 07:39:04 +020016941static hda_nid_t alc272_adc_nids[1] = {
16942 /* ADC1-2 */
16943 0x08,
16944};
16945
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016946static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016947static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16948
Takashi Iwaie1406342008-02-11 18:32:32 +010016949
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016950/* input MUX */
16951/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016952static struct hda_input_mux alc662_capture_source = {
16953 .num_items = 4,
16954 .items = {
16955 { "Mic", 0x0 },
16956 { "Front Mic", 0x1 },
16957 { "Line", 0x2 },
16958 { "CD", 0x4 },
16959 },
16960};
16961
16962static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16963 .num_items = 2,
16964 .items = {
16965 { "Mic", 0x1 },
16966 { "Line", 0x2 },
16967 },
16968};
Kailang Yang291702f2007-10-16 14:28:03 +020016969
Kailang Yang6dda9f42008-05-27 12:05:31 +020016970static struct hda_input_mux alc663_capture_source = {
16971 .num_items = 3,
16972 .items = {
16973 { "Mic", 0x0 },
16974 { "Front Mic", 0x1 },
16975 { "Line", 0x2 },
16976 },
16977};
16978
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016979#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016980static struct hda_input_mux alc272_nc10_capture_source = {
16981 .num_items = 16,
16982 .items = {
16983 { "Autoselect Mic", 0x0 },
16984 { "Internal Mic", 0x1 },
16985 { "In-0x02", 0x2 },
16986 { "In-0x03", 0x3 },
16987 { "In-0x04", 0x4 },
16988 { "In-0x05", 0x5 },
16989 { "In-0x06", 0x6 },
16990 { "In-0x07", 0x7 },
16991 { "In-0x08", 0x8 },
16992 { "In-0x09", 0x9 },
16993 { "In-0x0a", 0x0a },
16994 { "In-0x0b", 0x0b },
16995 { "In-0x0c", 0x0c },
16996 { "In-0x0d", 0x0d },
16997 { "In-0x0e", 0x0e },
16998 { "In-0x0f", 0x0f },
16999 },
17000};
17001#endif
17002
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017003/*
17004 * 2ch mode
17005 */
17006static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17007 { 2, NULL }
17008};
17009
17010/*
17011 * 2ch mode
17012 */
17013static struct hda_verb alc662_3ST_ch2_init[] = {
17014 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17015 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17016 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17017 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17018 { } /* end */
17019};
17020
17021/*
17022 * 6ch mode
17023 */
17024static struct hda_verb alc662_3ST_ch6_init[] = {
17025 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17026 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17027 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17028 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17029 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17030 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17031 { } /* end */
17032};
17033
17034static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17035 { 2, alc662_3ST_ch2_init },
17036 { 6, alc662_3ST_ch6_init },
17037};
17038
17039/*
17040 * 2ch mode
17041 */
17042static struct hda_verb alc662_sixstack_ch6_init[] = {
17043 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17044 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17045 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17046 { } /* end */
17047};
17048
17049/*
17050 * 6ch mode
17051 */
17052static struct hda_verb alc662_sixstack_ch8_init[] = {
17053 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17054 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17055 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17056 { } /* end */
17057};
17058
17059static struct hda_channel_mode alc662_5stack_modes[2] = {
17060 { 2, alc662_sixstack_ch6_init },
17061 { 6, alc662_sixstack_ch8_init },
17062};
17063
17064/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17065 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17066 */
17067
17068static struct snd_kcontrol_new alc662_base_mixer[] = {
17069 /* output mixer control */
17070 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017071 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017072 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017073 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017074 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17075 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017076 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17077 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17079
17080 /*Input mixer control */
17081 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17082 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17083 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17084 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17085 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17086 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17087 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17088 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017089 { } /* end */
17090};
17091
17092static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17093 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017094 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017095 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17096 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17097 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17098 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17099 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17100 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17101 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17102 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17103 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017104 { } /* end */
17105};
17106
17107static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17108 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017109 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017110 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017111 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017112 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17113 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017114 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17115 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017116 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17117 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17118 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17119 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17120 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17122 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17123 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17124 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017125 { } /* end */
17126};
17127
17128static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17129 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17130 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017131 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17132 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17134 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17135 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17136 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17137 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017138 { } /* end */
17139};
17140
Kailang Yang291702f2007-10-16 14:28:03 +020017141static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017142 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17143 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017144
17145 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17146 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17147 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17148
17149 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17150 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17151 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17152 { } /* end */
17153};
17154
Kailang Yang8c427222008-01-10 13:03:59 +010017155static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017156 ALC262_HIPPO_MASTER_SWITCH,
17157 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017158 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017159 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17160 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017161 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17162 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17163 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17166 { } /* end */
17167};
17168
Kailang Yangf1d4e282008-08-26 14:03:29 +020017169static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17170 .ops = &snd_hda_bind_vol,
17171 .values = {
17172 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17173 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17174 0
17175 },
17176};
17177
17178static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17179 .ops = &snd_hda_bind_sw,
17180 .values = {
17181 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17182 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17183 0
17184 },
17185};
17186
Kailang Yang6dda9f42008-05-27 12:05:31 +020017187static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017188 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17189 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17190 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17191 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17192 { } /* end */
17193};
17194
17195static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17196 .ops = &snd_hda_bind_sw,
17197 .values = {
17198 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17199 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17200 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17201 0
17202 },
17203};
17204
17205static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17206 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17207 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17208 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17210 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17211 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17212
17213 { } /* end */
17214};
17215
17216static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17217 .ops = &snd_hda_bind_sw,
17218 .values = {
17219 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17220 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17221 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17222 0
17223 },
17224};
17225
17226static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17227 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17228 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17231 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17232 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17233 { } /* end */
17234};
17235
17236static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017237 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17238 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017239 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17242 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17243 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17244 { } /* end */
17245};
17246
17247static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17248 .ops = &snd_hda_bind_vol,
17249 .values = {
17250 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17251 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17252 0
17253 },
17254};
17255
17256static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17257 .ops = &snd_hda_bind_sw,
17258 .values = {
17259 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17260 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17261 0
17262 },
17263};
17264
17265static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17266 HDA_BIND_VOL("Master Playback Volume",
17267 &alc663_asus_two_bind_master_vol),
17268 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017270 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017273 { } /* end */
17274};
17275
17276static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17277 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17278 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17279 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17280 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17281 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17282 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017283 { } /* end */
17284};
17285
17286static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17287 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17288 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17289 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17290 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17292
17293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17295 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17296 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17297 { } /* end */
17298};
17299
17300static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17301 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17302 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17303 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17304
17305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17307 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17308 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17309 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17310 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17311 { } /* end */
17312};
17313
Kailang Yangebb83ee2009-12-17 12:23:00 +010017314static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17315 .ops = &snd_hda_bind_sw,
17316 .values = {
17317 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17318 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17319 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17320 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17321 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17322 0
17323 },
17324};
17325
17326static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17327 .ops = &snd_hda_bind_sw,
17328 .values = {
17329 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17330 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17331 0
17332 },
17333};
17334
17335static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17336 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17337 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17338 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17339 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17340 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17341 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17342 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17345 { } /* end */
17346};
17347
17348static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17349 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17350 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17351 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17352 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17353 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17356 { } /* end */
17357};
17358
17359
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17361 {
17362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17363 .name = "Channel Mode",
17364 .info = alc_ch_mode_info,
17365 .get = alc_ch_mode_get,
17366 .put = alc_ch_mode_put,
17367 },
17368 { } /* end */
17369};
17370
17371static struct hda_verb alc662_init_verbs[] = {
17372 /* ADC: mute amp left and right */
17373 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17374 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375
Kailang Yangb60dd392007-09-20 12:50:29 +020017376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017382
17383 /* Front Pin: output 0 (0x0c) */
17384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17386
17387 /* Rear Pin: output 1 (0x0d) */
17388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17390
17391 /* CLFE Pin: output 2 (0x0e) */
17392 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17393 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17394
17395 /* Mic (rear) pin: input vref at 80% */
17396 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17397 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17398 /* Front Mic pin: input vref at 80% */
17399 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17400 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17401 /* Line In pin: input */
17402 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17403 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17404 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17405 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17406 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17407 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17408 /* CD pin widget for input */
17409 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17410
17411 /* FIXME: use matrix-type input source selection */
17412 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17413 /* Input mixer */
17414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017415 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017416
17417 /* always trun on EAPD */
17418 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17419 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17420
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421 { }
17422};
17423
Kailang Yangcec27c82010-02-04 14:18:18 +010017424static struct hda_verb alc663_init_verbs[] = {
17425 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17426 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17427 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17428 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17429 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17430 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17431 { }
17432};
17433
17434static struct hda_verb alc272_init_verbs[] = {
17435 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17436 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17437 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17438 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17439 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17440 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17441 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17442 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17443 { }
17444};
17445
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017446static struct hda_verb alc662_sue_init_verbs[] = {
17447 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17448 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017449 {}
17450};
17451
17452static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17453 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17454 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17455 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456};
17457
Kailang Yang8c427222008-01-10 13:03:59 +010017458/* Set Unsolicited Event*/
17459static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17460 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17461 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17462 {}
17463};
17464
Kailang Yang6dda9f42008-05-27 12:05:31 +020017465static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017466 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17467 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017468 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17469 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017470 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17471 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17472 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017473 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17474 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17475 {}
17476};
17477
Kailang Yangf1d4e282008-08-26 14:03:29 +020017478static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17479 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17480 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17481 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17483 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17484 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17485 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17486 {}
17487};
17488
17489static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17491 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17493 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17494 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17495 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17496 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17497 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17498 {}
17499};
17500
17501static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17502 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17504 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17507 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17508 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17509 {}
17510};
17511
17512static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17513 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17514 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17515 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17516 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17517 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17518 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17519 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17520 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17521 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17522 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17523 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17524 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17525 {}
17526};
17527
17528static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17529 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17530 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17531 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17532 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17535 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17538 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17539 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17540 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17541 {}
17542};
17543
Kailang Yang6dda9f42008-05-27 12:05:31 +020017544static struct hda_verb alc663_g71v_init_verbs[] = {
17545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17546 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17547 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17548
17549 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17550 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17551 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17552
17553 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17554 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17555 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17556 {}
17557};
17558
17559static struct hda_verb alc663_g50v_init_verbs[] = {
17560 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17561 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17562 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17563
17564 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17565 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17566 {}
17567};
17568
Kailang Yangf1d4e282008-08-26 14:03:29 +020017569static struct hda_verb alc662_ecs_init_verbs[] = {
17570 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17572 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17573 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17574 {}
17575};
17576
Kailang Yang622e84c2009-04-21 07:39:04 +020017577static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17578 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17579 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17581 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17582 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17583 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17584 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17587 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17588 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17589 {}
17590};
17591
17592static struct hda_verb alc272_dell_init_verbs[] = {
17593 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17594 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17595 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17596 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17597 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17598 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17599 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17602 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17603 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17604 {}
17605};
17606
Kailang Yangebb83ee2009-12-17 12:23:00 +010017607static struct hda_verb alc663_mode7_init_verbs[] = {
17608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17609 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17610 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17611 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17612 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17613 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17614 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17615 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17616 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17617 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17618 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17620 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17621 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17622 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17623 {}
17624};
17625
17626static struct hda_verb alc663_mode8_init_verbs[] = {
17627 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17628 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17629 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17630 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17632 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17633 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17635 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17636 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17637 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17638 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17639 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17640 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17641 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17642 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17643 {}
17644};
17645
Kailang Yangf1d4e282008-08-26 14:03:29 +020017646static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17647 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17648 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17649 { } /* end */
17650};
17651
Kailang Yang622e84c2009-04-21 07:39:04 +020017652static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17653 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17654 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17655 { } /* end */
17656};
17657
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017658static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17659{
17660 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017661 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017662
Wu Fengguang864f92b2009-11-18 12:38:02 +080017663 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017664 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017665
Takashi Iwai47fd8302007-08-10 17:11:07 +020017666 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17667 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017668}
17669
17670static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17671{
17672 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017673 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017674
Wu Fengguang864f92b2009-11-18 12:38:02 +080017675 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017676 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017677
Takashi Iwai47fd8302007-08-10 17:11:07 +020017678 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17679 HDA_AMP_MUTE, bits);
17680 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17681 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017682}
17683
17684static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17685 unsigned int res)
17686{
17687 if ((res >> 26) == ALC880_HP_EVENT)
17688 alc662_lenovo_101e_all_automute(codec);
17689 if ((res >> 26) == ALC880_FRONT_EVENT)
17690 alc662_lenovo_101e_ispeaker_automute(codec);
17691}
17692
Kailang Yang291702f2007-10-16 14:28:03 +020017693/* unsolicited event for HP jack sensing */
17694static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17695 unsigned int res)
17696{
Kailang Yang291702f2007-10-16 14:28:03 +020017697 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017698 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017699 else
17700 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017701}
17702
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017703static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017704{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017705 struct alc_spec *spec = codec->spec;
17706
17707 alc262_hippo1_setup(codec);
17708 spec->ext_mic.pin = 0x18;
17709 spec->ext_mic.mux_idx = 0;
17710 spec->int_mic.pin = 0x19;
17711 spec->int_mic.mux_idx = 1;
17712 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017713}
17714
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017715static void alc662_eeepc_inithook(struct hda_codec *codec)
17716{
17717 alc262_hippo_automute(codec);
17718 alc_mic_automute(codec);
17719}
17720
17721static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017722{
Takashi Iwai42171c12009-05-08 14:11:43 +020017723 struct alc_spec *spec = codec->spec;
17724
17725 spec->autocfg.hp_pins[0] = 0x14;
17726 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017727}
17728
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017729#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17730
Kailang Yang6dda9f42008-05-27 12:05:31 +020017731static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17732{
17733 unsigned int present;
17734 unsigned char bits;
17735
Wu Fengguang864f92b2009-11-18 12:38:02 +080017736 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017737 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017738 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017739 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017740 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017741 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017742}
17743
17744static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17745{
17746 unsigned int present;
17747 unsigned char bits;
17748
Wu Fengguang864f92b2009-11-18 12:38:02 +080017749 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017750 bits = present ? HDA_AMP_MUTE : 0;
17751 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017752 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017753 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017754 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017755 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017756 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017757 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017758 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017759}
17760
17761static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17762{
17763 unsigned int present;
17764 unsigned char bits;
17765
Wu Fengguang864f92b2009-11-18 12:38:02 +080017766 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017767 bits = present ? HDA_AMP_MUTE : 0;
17768 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017769 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017770 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017771 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017772 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017773 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017774 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017775 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017776}
17777
17778static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17779{
17780 unsigned int present;
17781 unsigned char bits;
17782
Wu Fengguang864f92b2009-11-18 12:38:02 +080017783 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017784 bits = present ? 0 : PIN_OUT;
17785 snd_hda_codec_write(codec, 0x14, 0,
17786 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17787}
17788
17789static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17790{
17791 unsigned int present1, present2;
17792
Wu Fengguang864f92b2009-11-18 12:38:02 +080017793 present1 = snd_hda_jack_detect(codec, 0x21);
17794 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017795
17796 if (present1 || present2) {
17797 snd_hda_codec_write_cache(codec, 0x14, 0,
17798 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17799 } else {
17800 snd_hda_codec_write_cache(codec, 0x14, 0,
17801 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17802 }
17803}
17804
17805static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17806{
17807 unsigned int present1, present2;
17808
Wu Fengguang864f92b2009-11-18 12:38:02 +080017809 present1 = snd_hda_jack_detect(codec, 0x1b);
17810 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017811
17812 if (present1 || present2) {
17813 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017814 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017815 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017816 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017817 } else {
17818 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017819 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017820 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017821 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017822 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017823}
17824
Kailang Yangebb83ee2009-12-17 12:23:00 +010017825static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17826{
17827 unsigned int present1, present2;
17828
17829 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17830 AC_VERB_GET_PIN_SENSE, 0)
17831 & AC_PINSENSE_PRESENCE;
17832 present2 = snd_hda_codec_read(codec, 0x21, 0,
17833 AC_VERB_GET_PIN_SENSE, 0)
17834 & AC_PINSENSE_PRESENCE;
17835
17836 if (present1 || present2) {
17837 snd_hda_codec_write_cache(codec, 0x14, 0,
17838 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17839 snd_hda_codec_write_cache(codec, 0x17, 0,
17840 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17841 } else {
17842 snd_hda_codec_write_cache(codec, 0x14, 0,
17843 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17844 snd_hda_codec_write_cache(codec, 0x17, 0,
17845 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17846 }
17847}
17848
17849static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17850{
17851 unsigned int present1, present2;
17852
17853 present1 = snd_hda_codec_read(codec, 0x21, 0,
17854 AC_VERB_GET_PIN_SENSE, 0)
17855 & AC_PINSENSE_PRESENCE;
17856 present2 = snd_hda_codec_read(codec, 0x15, 0,
17857 AC_VERB_GET_PIN_SENSE, 0)
17858 & AC_PINSENSE_PRESENCE;
17859
17860 if (present1 || present2) {
17861 snd_hda_codec_write_cache(codec, 0x14, 0,
17862 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17863 snd_hda_codec_write_cache(codec, 0x17, 0,
17864 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17865 } else {
17866 snd_hda_codec_write_cache(codec, 0x14, 0,
17867 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17868 snd_hda_codec_write_cache(codec, 0x17, 0,
17869 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17870 }
17871}
17872
Kailang Yang6dda9f42008-05-27 12:05:31 +020017873static void alc663_m51va_unsol_event(struct hda_codec *codec,
17874 unsigned int res)
17875{
17876 switch (res >> 26) {
17877 case ALC880_HP_EVENT:
17878 alc663_m51va_speaker_automute(codec);
17879 break;
17880 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017881 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017882 break;
17883 }
17884}
17885
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017886static void alc663_m51va_setup(struct hda_codec *codec)
17887{
17888 struct alc_spec *spec = codec->spec;
17889 spec->ext_mic.pin = 0x18;
17890 spec->ext_mic.mux_idx = 0;
17891 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017892 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017893 spec->auto_mic = 1;
17894}
17895
Kailang Yang6dda9f42008-05-27 12:05:31 +020017896static void alc663_m51va_inithook(struct hda_codec *codec)
17897{
17898 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017899 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017900}
17901
Kailang Yangf1d4e282008-08-26 14:03:29 +020017902/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017903#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017904
17905static void alc663_mode1_setup(struct hda_codec *codec)
17906{
17907 struct alc_spec *spec = codec->spec;
17908 spec->ext_mic.pin = 0x18;
17909 spec->ext_mic.mux_idx = 0;
17910 spec->int_mic.pin = 0x19;
17911 spec->int_mic.mux_idx = 1;
17912 spec->auto_mic = 1;
17913}
17914
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017915#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017916
Kailang Yangf1d4e282008-08-26 14:03:29 +020017917/* ***************** Mode2 ******************************/
17918static void alc662_mode2_unsol_event(struct hda_codec *codec,
17919 unsigned int res)
17920{
17921 switch (res >> 26) {
17922 case ALC880_HP_EVENT:
17923 alc662_f5z_speaker_automute(codec);
17924 break;
17925 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017926 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017927 break;
17928 }
17929}
17930
Kailang Yangebb83ee2009-12-17 12:23:00 +010017931#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017932
Kailang Yangf1d4e282008-08-26 14:03:29 +020017933static void alc662_mode2_inithook(struct hda_codec *codec)
17934{
17935 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017936 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017937}
17938/* ***************** Mode3 ******************************/
17939static void alc663_mode3_unsol_event(struct hda_codec *codec,
17940 unsigned int res)
17941{
17942 switch (res >> 26) {
17943 case ALC880_HP_EVENT:
17944 alc663_two_hp_m1_speaker_automute(codec);
17945 break;
17946 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017947 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017948 break;
17949 }
17950}
17951
Kailang Yangebb83ee2009-12-17 12:23:00 +010017952#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017953
Kailang Yangf1d4e282008-08-26 14:03:29 +020017954static void alc663_mode3_inithook(struct hda_codec *codec)
17955{
17956 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017957 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017958}
17959/* ***************** Mode4 ******************************/
17960static void alc663_mode4_unsol_event(struct hda_codec *codec,
17961 unsigned int res)
17962{
17963 switch (res >> 26) {
17964 case ALC880_HP_EVENT:
17965 alc663_21jd_two_speaker_automute(codec);
17966 break;
17967 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017968 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017969 break;
17970 }
17971}
17972
Kailang Yangebb83ee2009-12-17 12:23:00 +010017973#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017974
Kailang Yangf1d4e282008-08-26 14:03:29 +020017975static void alc663_mode4_inithook(struct hda_codec *codec)
17976{
17977 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017978 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017979}
17980/* ***************** Mode5 ******************************/
17981static void alc663_mode5_unsol_event(struct hda_codec *codec,
17982 unsigned int res)
17983{
17984 switch (res >> 26) {
17985 case ALC880_HP_EVENT:
17986 alc663_15jd_two_speaker_automute(codec);
17987 break;
17988 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017989 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017990 break;
17991 }
17992}
17993
Kailang Yangebb83ee2009-12-17 12:23:00 +010017994#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017995
Kailang Yangf1d4e282008-08-26 14:03:29 +020017996static void alc663_mode5_inithook(struct hda_codec *codec)
17997{
17998 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017999 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018000}
18001/* ***************** Mode6 ******************************/
18002static void alc663_mode6_unsol_event(struct hda_codec *codec,
18003 unsigned int res)
18004{
18005 switch (res >> 26) {
18006 case ALC880_HP_EVENT:
18007 alc663_two_hp_m2_speaker_automute(codec);
18008 break;
18009 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018010 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018011 break;
18012 }
18013}
18014
Kailang Yangebb83ee2009-12-17 12:23:00 +010018015#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018016
Kailang Yangf1d4e282008-08-26 14:03:29 +020018017static void alc663_mode6_inithook(struct hda_codec *codec)
18018{
18019 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018020 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018021}
18022
Kailang Yangebb83ee2009-12-17 12:23:00 +010018023/* ***************** Mode7 ******************************/
18024static void alc663_mode7_unsol_event(struct hda_codec *codec,
18025 unsigned int res)
18026{
18027 switch (res >> 26) {
18028 case ALC880_HP_EVENT:
18029 alc663_two_hp_m7_speaker_automute(codec);
18030 break;
18031 case ALC880_MIC_EVENT:
18032 alc_mic_automute(codec);
18033 break;
18034 }
18035}
18036
18037#define alc663_mode7_setup alc663_mode1_setup
18038
18039static void alc663_mode7_inithook(struct hda_codec *codec)
18040{
18041 alc663_two_hp_m7_speaker_automute(codec);
18042 alc_mic_automute(codec);
18043}
18044
18045/* ***************** Mode8 ******************************/
18046static void alc663_mode8_unsol_event(struct hda_codec *codec,
18047 unsigned int res)
18048{
18049 switch (res >> 26) {
18050 case ALC880_HP_EVENT:
18051 alc663_two_hp_m8_speaker_automute(codec);
18052 break;
18053 case ALC880_MIC_EVENT:
18054 alc_mic_automute(codec);
18055 break;
18056 }
18057}
18058
18059#define alc663_mode8_setup alc663_m51va_setup
18060
18061static void alc663_mode8_inithook(struct hda_codec *codec)
18062{
18063 alc663_two_hp_m8_speaker_automute(codec);
18064 alc_mic_automute(codec);
18065}
18066
Kailang Yang6dda9f42008-05-27 12:05:31 +020018067static void alc663_g71v_hp_automute(struct hda_codec *codec)
18068{
18069 unsigned int present;
18070 unsigned char bits;
18071
Wu Fengguang864f92b2009-11-18 12:38:02 +080018072 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018073 bits = present ? HDA_AMP_MUTE : 0;
18074 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18075 HDA_AMP_MUTE, bits);
18076 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18077 HDA_AMP_MUTE, bits);
18078}
18079
18080static void alc663_g71v_front_automute(struct hda_codec *codec)
18081{
18082 unsigned int present;
18083 unsigned char bits;
18084
Wu Fengguang864f92b2009-11-18 12:38:02 +080018085 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018086 bits = present ? HDA_AMP_MUTE : 0;
18087 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18088 HDA_AMP_MUTE, bits);
18089}
18090
18091static void alc663_g71v_unsol_event(struct hda_codec *codec,
18092 unsigned int res)
18093{
18094 switch (res >> 26) {
18095 case ALC880_HP_EVENT:
18096 alc663_g71v_hp_automute(codec);
18097 break;
18098 case ALC880_FRONT_EVENT:
18099 alc663_g71v_front_automute(codec);
18100 break;
18101 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018102 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018103 break;
18104 }
18105}
18106
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018107#define alc663_g71v_setup alc663_m51va_setup
18108
Kailang Yang6dda9f42008-05-27 12:05:31 +020018109static void alc663_g71v_inithook(struct hda_codec *codec)
18110{
18111 alc663_g71v_front_automute(codec);
18112 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018113 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018114}
18115
18116static void alc663_g50v_unsol_event(struct hda_codec *codec,
18117 unsigned int res)
18118{
18119 switch (res >> 26) {
18120 case ALC880_HP_EVENT:
18121 alc663_m51va_speaker_automute(codec);
18122 break;
18123 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018124 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018125 break;
18126 }
18127}
18128
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018129#define alc663_g50v_setup alc663_m51va_setup
18130
Kailang Yang6dda9f42008-05-27 12:05:31 +020018131static void alc663_g50v_inithook(struct hda_codec *codec)
18132{
18133 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018134 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018135}
18136
Kailang Yangf1d4e282008-08-26 14:03:29 +020018137static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18138 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018139 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018140
18141 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18142 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18143 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18144
18145 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18146 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18147 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18148 { } /* end */
18149};
18150
Chris Pockelé9541ba12009-05-12 08:08:53 +020018151static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18152 /* Master Playback automatically created from Speaker and Headphone */
18153 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18154 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18155 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18156 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18157
18158 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18159 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18160 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18161
18162 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18163 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18164 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18165 { } /* end */
18166};
18167
Takashi Iwaicb53c622007-08-10 17:21:45 +020018168#ifdef CONFIG_SND_HDA_POWER_SAVE
18169#define alc662_loopbacks alc880_loopbacks
18170#endif
18171
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018172
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018173/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018174#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18175#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18176#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18177#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18178
18179/*
18180 * configuration and preset
18181 */
18182static const char *alc662_models[ALC662_MODEL_LAST] = {
18183 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18184 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18185 [ALC662_3ST_6ch] = "3stack-6ch",
18186 [ALC662_5ST_DIG] = "6stack-dig",
18187 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018188 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018189 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018190 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018191 [ALC663_ASUS_M51VA] = "m51va",
18192 [ALC663_ASUS_G71V] = "g71v",
18193 [ALC663_ASUS_H13] = "h13",
18194 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018195 [ALC663_ASUS_MODE1] = "asus-mode1",
18196 [ALC662_ASUS_MODE2] = "asus-mode2",
18197 [ALC663_ASUS_MODE3] = "asus-mode3",
18198 [ALC663_ASUS_MODE4] = "asus-mode4",
18199 [ALC663_ASUS_MODE5] = "asus-mode5",
18200 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018201 [ALC663_ASUS_MODE7] = "asus-mode7",
18202 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018203 [ALC272_DELL] = "dell",
18204 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018205 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018206 [ALC662_AUTO] = "auto",
18207};
18208
18209static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018210 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018211 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18212 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018213 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18214 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018215 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018216 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18217 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18218 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18219 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018220 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18221 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018222 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018223 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18224 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18225 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18226 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18227 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018228 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018229 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18230 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018231 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18232 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18233 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18234 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018235 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018236 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18237 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18238 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018239 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18240 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18241 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18242 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018243 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018244 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18245 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018246 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018247 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18248 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18249 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018250 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018251 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018252 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18253 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018254 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18255 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18256 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018257 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018258 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18259 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018260 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018261 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018262 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018263 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18264 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18265 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018266 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018267 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18268 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018269 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018270 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018271 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018272 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018273 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18274 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018275 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018276 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018277 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18278 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018279 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018280 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018281 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018282 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018283 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018284 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018285 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18286 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018287 {}
18288};
18289
18290static struct alc_config_preset alc662_presets[] = {
18291 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018292 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018293 .init_verbs = { alc662_init_verbs },
18294 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18295 .dac_nids = alc662_dac_nids,
18296 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018297 .dig_in_nid = ALC662_DIGIN_NID,
18298 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18299 .channel_mode = alc662_3ST_2ch_modes,
18300 .input_mux = &alc662_capture_source,
18301 },
18302 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018303 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018304 .init_verbs = { alc662_init_verbs },
18305 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18306 .dac_nids = alc662_dac_nids,
18307 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018308 .dig_in_nid = ALC662_DIGIN_NID,
18309 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18310 .channel_mode = alc662_3ST_6ch_modes,
18311 .need_dac_fix = 1,
18312 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018313 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018314 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018315 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018316 .init_verbs = { alc662_init_verbs },
18317 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18318 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018319 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18320 .channel_mode = alc662_3ST_6ch_modes,
18321 .need_dac_fix = 1,
18322 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018323 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018324 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018325 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018326 .init_verbs = { alc662_init_verbs },
18327 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18328 .dac_nids = alc662_dac_nids,
18329 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018330 .dig_in_nid = ALC662_DIGIN_NID,
18331 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18332 .channel_mode = alc662_5stack_modes,
18333 .input_mux = &alc662_capture_source,
18334 },
18335 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018336 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018337 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18338 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18339 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018340 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18341 .channel_mode = alc662_3ST_2ch_modes,
18342 .input_mux = &alc662_lenovo_101e_capture_source,
18343 .unsol_event = alc662_lenovo_101e_unsol_event,
18344 .init_hook = alc662_lenovo_101e_all_automute,
18345 },
Kailang Yang291702f2007-10-16 14:28:03 +020018346 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018347 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018348 .init_verbs = { alc662_init_verbs,
18349 alc662_eeepc_sue_init_verbs },
18350 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18351 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018352 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18353 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018354 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018355 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018356 .init_hook = alc662_eeepc_inithook,
18357 },
Kailang Yang8c427222008-01-10 13:03:59 +010018358 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018359 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018360 alc662_chmode_mixer },
18361 .init_verbs = { alc662_init_verbs,
18362 alc662_eeepc_ep20_sue_init_verbs },
18363 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18364 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018365 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18366 .channel_mode = alc662_3ST_6ch_modes,
18367 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018368 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018369 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018370 .init_hook = alc662_eeepc_ep20_inithook,
18371 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018372 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018373 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018374 .init_verbs = { alc662_init_verbs,
18375 alc662_ecs_init_verbs },
18376 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18377 .dac_nids = alc662_dac_nids,
18378 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18379 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018380 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018381 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018382 .init_hook = alc662_eeepc_inithook,
18383 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018384 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018385 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018386 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18387 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18388 .dac_nids = alc662_dac_nids,
18389 .dig_out_nid = ALC662_DIGOUT_NID,
18390 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18391 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018392 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018393 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018394 .init_hook = alc663_m51va_inithook,
18395 },
18396 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018397 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018398 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18399 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18400 .dac_nids = alc662_dac_nids,
18401 .dig_out_nid = ALC662_DIGOUT_NID,
18402 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18403 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018404 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018405 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018406 .init_hook = alc663_g71v_inithook,
18407 },
18408 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018409 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018410 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18411 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18412 .dac_nids = alc662_dac_nids,
18413 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18414 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018415 .unsol_event = alc663_m51va_unsol_event,
18416 .init_hook = alc663_m51va_inithook,
18417 },
18418 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018419 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018420 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18421 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18422 .dac_nids = alc662_dac_nids,
18423 .dig_out_nid = ALC662_DIGOUT_NID,
18424 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18425 .channel_mode = alc662_3ST_6ch_modes,
18426 .input_mux = &alc663_capture_source,
18427 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018428 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018429 .init_hook = alc663_g50v_inithook,
18430 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018431 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018432 .mixers = { alc663_m51va_mixer },
18433 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018434 .init_verbs = { alc662_init_verbs,
18435 alc663_21jd_amic_init_verbs },
18436 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18437 .hp_nid = 0x03,
18438 .dac_nids = alc662_dac_nids,
18439 .dig_out_nid = ALC662_DIGOUT_NID,
18440 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18441 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018442 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018443 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018444 .init_hook = alc663_mode1_inithook,
18445 },
18446 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018447 .mixers = { alc662_1bjd_mixer },
18448 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018449 .init_verbs = { alc662_init_verbs,
18450 alc662_1bjd_amic_init_verbs },
18451 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18452 .dac_nids = alc662_dac_nids,
18453 .dig_out_nid = ALC662_DIGOUT_NID,
18454 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18455 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018456 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018457 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018458 .init_hook = alc662_mode2_inithook,
18459 },
18460 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018461 .mixers = { alc663_two_hp_m1_mixer },
18462 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018463 .init_verbs = { alc662_init_verbs,
18464 alc663_two_hp_amic_m1_init_verbs },
18465 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18466 .hp_nid = 0x03,
18467 .dac_nids = alc662_dac_nids,
18468 .dig_out_nid = ALC662_DIGOUT_NID,
18469 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18470 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018471 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018472 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018473 .init_hook = alc663_mode3_inithook,
18474 },
18475 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018476 .mixers = { alc663_asus_21jd_clfe_mixer },
18477 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018478 .init_verbs = { alc662_init_verbs,
18479 alc663_21jd_amic_init_verbs},
18480 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18481 .hp_nid = 0x03,
18482 .dac_nids = alc662_dac_nids,
18483 .dig_out_nid = ALC662_DIGOUT_NID,
18484 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18485 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018486 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018487 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018488 .init_hook = alc663_mode4_inithook,
18489 },
18490 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018491 .mixers = { alc663_asus_15jd_clfe_mixer },
18492 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018493 .init_verbs = { alc662_init_verbs,
18494 alc663_15jd_amic_init_verbs },
18495 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18496 .hp_nid = 0x03,
18497 .dac_nids = alc662_dac_nids,
18498 .dig_out_nid = ALC662_DIGOUT_NID,
18499 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18500 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018501 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018502 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018503 .init_hook = alc663_mode5_inithook,
18504 },
18505 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018506 .mixers = { alc663_two_hp_m2_mixer },
18507 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018508 .init_verbs = { alc662_init_verbs,
18509 alc663_two_hp_amic_m2_init_verbs },
18510 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18511 .hp_nid = 0x03,
18512 .dac_nids = alc662_dac_nids,
18513 .dig_out_nid = ALC662_DIGOUT_NID,
18514 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18515 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018516 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018517 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018518 .init_hook = alc663_mode6_inithook,
18519 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018520 [ALC663_ASUS_MODE7] = {
18521 .mixers = { alc663_mode7_mixer },
18522 .cap_mixer = alc662_auto_capture_mixer,
18523 .init_verbs = { alc662_init_verbs,
18524 alc663_mode7_init_verbs },
18525 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18526 .hp_nid = 0x03,
18527 .dac_nids = alc662_dac_nids,
18528 .dig_out_nid = ALC662_DIGOUT_NID,
18529 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18530 .channel_mode = alc662_3ST_2ch_modes,
18531 .unsol_event = alc663_mode7_unsol_event,
18532 .setup = alc663_mode7_setup,
18533 .init_hook = alc663_mode7_inithook,
18534 },
18535 [ALC663_ASUS_MODE8] = {
18536 .mixers = { alc663_mode8_mixer },
18537 .cap_mixer = alc662_auto_capture_mixer,
18538 .init_verbs = { alc662_init_verbs,
18539 alc663_mode8_init_verbs },
18540 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18541 .hp_nid = 0x03,
18542 .dac_nids = alc662_dac_nids,
18543 .dig_out_nid = ALC662_DIGOUT_NID,
18544 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18545 .channel_mode = alc662_3ST_2ch_modes,
18546 .unsol_event = alc663_mode8_unsol_event,
18547 .setup = alc663_mode8_setup,
18548 .init_hook = alc663_mode8_inithook,
18549 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018550 [ALC272_DELL] = {
18551 .mixers = { alc663_m51va_mixer },
18552 .cap_mixer = alc272_auto_capture_mixer,
18553 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18554 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18555 .dac_nids = alc662_dac_nids,
18556 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18557 .adc_nids = alc272_adc_nids,
18558 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18559 .capsrc_nids = alc272_capsrc_nids,
18560 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018561 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018562 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018563 .init_hook = alc663_m51va_inithook,
18564 },
18565 [ALC272_DELL_ZM1] = {
18566 .mixers = { alc663_m51va_mixer },
18567 .cap_mixer = alc662_auto_capture_mixer,
18568 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18569 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18570 .dac_nids = alc662_dac_nids,
18571 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18572 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018573 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018574 .capsrc_nids = alc662_capsrc_nids,
18575 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018576 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018577 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018578 .init_hook = alc663_m51va_inithook,
18579 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018580 [ALC272_SAMSUNG_NC10] = {
18581 .mixers = { alc272_nc10_mixer },
18582 .init_verbs = { alc662_init_verbs,
18583 alc663_21jd_amic_init_verbs },
18584 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18585 .dac_nids = alc272_dac_nids,
18586 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18587 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018588 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018589 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018590 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018591 .init_hook = alc663_mode4_inithook,
18592 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018593};
18594
18595
18596/*
18597 * BIOS auto configuration
18598 */
18599
Takashi Iwai7085ec12009-10-02 09:03:58 +020018600/* convert from MIX nid to DAC */
18601static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18602{
18603 if (nid == 0x0f)
18604 return 0x02;
18605 else if (nid >= 0x0c && nid <= 0x0e)
18606 return nid - 0x0c + 0x02;
18607 else
18608 return 0;
18609}
18610
18611/* get MIX nid connected to the given pin targeted to DAC */
18612static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18613 hda_nid_t dac)
18614{
18615 hda_nid_t mix[4];
18616 int i, num;
18617
18618 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18619 for (i = 0; i < num; i++) {
18620 if (alc662_mix_to_dac(mix[i]) == dac)
18621 return mix[i];
18622 }
18623 return 0;
18624}
18625
18626/* look for an empty DAC slot */
18627static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18628{
18629 struct alc_spec *spec = codec->spec;
18630 hda_nid_t srcs[5];
18631 int i, j, num;
18632
18633 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18634 if (num < 0)
18635 return 0;
18636 for (i = 0; i < num; i++) {
18637 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18638 if (!nid)
18639 continue;
18640 for (j = 0; j < spec->multiout.num_dacs; j++)
18641 if (spec->multiout.dac_nids[j] == nid)
18642 break;
18643 if (j >= spec->multiout.num_dacs)
18644 return nid;
18645 }
18646 return 0;
18647}
18648
18649/* fill in the dac_nids table from the parsed pin configuration */
18650static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18651 const struct auto_pin_cfg *cfg)
18652{
18653 struct alc_spec *spec = codec->spec;
18654 int i;
18655 hda_nid_t dac;
18656
18657 spec->multiout.dac_nids = spec->private_dac_nids;
18658 for (i = 0; i < cfg->line_outs; i++) {
18659 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18660 if (!dac)
18661 continue;
18662 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18663 }
18664 return 0;
18665}
18666
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018667static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018668 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018669{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018670 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018671 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18672}
18673
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018674static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018675 hda_nid_t nid, unsigned int chs)
18676{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018677 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018678 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18679}
18680
18681#define alc662_add_stereo_vol(spec, pfx, nid) \
18682 alc662_add_vol_ctl(spec, pfx, nid, 3)
18683#define alc662_add_stereo_sw(spec, pfx, nid) \
18684 alc662_add_sw_ctl(spec, pfx, nid, 3)
18685
18686/* add playback controls from the parsed DAC table */
18687static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18688 const struct auto_pin_cfg *cfg)
18689{
18690 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018691 static const char *chname[4] = {
18692 "Front", "Surround", NULL /*CLFE*/, "Side"
18693 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018694 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018695 int i, err;
18696
18697 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018698 nid = spec->multiout.dac_nids[i];
18699 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018700 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018701 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18702 if (!mix)
18703 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704 if (i == 2) {
18705 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018706 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018707 if (err < 0)
18708 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018709 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018710 if (err < 0)
18711 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018712 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018713 if (err < 0)
18714 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018715 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018716 if (err < 0)
18717 return err;
18718 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018719 const char *pfx;
18720 if (cfg->line_outs == 1 &&
18721 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018722 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018723 pfx = "Speaker";
18724 else
18725 pfx = "PCM";
18726 } else
18727 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018728 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018729 if (err < 0)
18730 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018731 if (cfg->line_outs == 1 &&
18732 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18733 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018734 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018735 if (err < 0)
18736 return err;
18737 }
18738 }
18739 return 0;
18740}
18741
18742/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018743/* return DAC nid if any new DAC is assigned */
18744static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018745 const char *pfx)
18746{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018747 struct alc_spec *spec = codec->spec;
18748 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018749 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018750
18751 if (!pin)
18752 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018753 nid = alc662_look_for_dac(codec, pin);
18754 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018755 /* the corresponding DAC is already occupied */
18756 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18757 return 0; /* no way */
18758 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018759 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018760 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18761 }
18762
18763 mix = alc662_dac_to_mix(codec, pin, nid);
18764 if (!mix)
18765 return 0;
18766 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18767 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018768 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018769 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18770 if (err < 0)
18771 return err;
18772 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018773}
18774
18775/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018776#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018777 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018778
18779static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18780 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018781 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018782{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018783 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020018784 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018785
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018786 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018787 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018788 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18789 if (num <= 1)
18790 return;
18791 for (i = 0; i < num; i++) {
18792 if (alc662_mix_to_dac(srcs[i]) != dac)
18793 continue;
18794 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18795 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018796 }
18797}
18798
18799static void alc662_auto_init_multi_out(struct hda_codec *codec)
18800{
18801 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018802 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018803 int i;
18804
18805 for (i = 0; i <= HDA_SIDE; i++) {
18806 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18807 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018808 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018809 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018810 }
18811}
18812
18813static void alc662_auto_init_hp_out(struct hda_codec *codec)
18814{
18815 struct alc_spec *spec = codec->spec;
18816 hda_nid_t pin;
18817
18818 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018819 if (pin)
18820 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18821 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018822 pin = spec->autocfg.speaker_pins[0];
18823 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018824 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18825 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018826}
18827
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018828#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18829
18830static void alc662_auto_init_analog_input(struct hda_codec *codec)
18831{
18832 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020018833 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018834 int i;
18835
Takashi Iwai66ceeb62010-08-30 13:05:52 +020018836 for (i = 0; i < cfg->num_inputs; i++) {
18837 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018838 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018839 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018840 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018841 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018842 snd_hda_codec_write(codec, nid, 0,
18843 AC_VERB_SET_AMP_GAIN_MUTE,
18844 AMP_OUT_MUTE);
18845 }
18846 }
18847}
18848
Takashi Iwaif511b012008-08-15 16:46:42 +020018849#define alc662_auto_init_input_src alc882_auto_init_input_src
18850
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018851static int alc662_parse_auto_config(struct hda_codec *codec)
18852{
18853 struct alc_spec *spec = codec->spec;
18854 int err;
18855 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18856
18857 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18858 alc662_ignore);
18859 if (err < 0)
18860 return err;
18861 if (!spec->autocfg.line_outs)
18862 return 0; /* can't find valid BIOS pin config */
18863
Takashi Iwai7085ec12009-10-02 09:03:58 +020018864 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018865 if (err < 0)
18866 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018867 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018868 if (err < 0)
18869 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018870 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018871 spec->autocfg.speaker_pins[0],
18872 "Speaker");
18873 if (err < 0)
18874 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018875 if (err)
18876 spec->multiout.extra_out_nid[0] = err;
18877 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018878 "Headphone");
18879 if (err < 0)
18880 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018881 if (err)
18882 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018883 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018884 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018885 return err;
18886
18887 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18888
Takashi Iwai757899a2010-07-30 10:48:14 +020018889 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018890
Takashi Iwai603c4012008-07-30 15:01:44 +020018891 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018892 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018893
18894 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018895 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018896
Kailang Yangcec27c82010-02-04 14:18:18 +010018897 add_verb(spec, alc662_init_verbs);
18898 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020018899 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010018900 add_verb(spec, alc663_init_verbs);
18901
18902 if (codec->vendor_id == 0x10ec0272)
18903 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018904
18905 err = alc_auto_add_mic_boost(codec);
18906 if (err < 0)
18907 return err;
18908
Kailang Yang6227cdc2010-02-25 08:36:52 +010018909 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18910 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18911 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18912 else
18913 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018914
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018915 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018916}
18917
18918/* additional initialization for auto-configuration model */
18919static void alc662_auto_init(struct hda_codec *codec)
18920{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018921 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018922 alc662_auto_init_multi_out(codec);
18923 alc662_auto_init_hp_out(codec);
18924 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018925 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020018926 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018927 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018928 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018929}
18930
18931static int patch_alc662(struct hda_codec *codec)
18932{
18933 struct alc_spec *spec;
18934 int err, board_config;
18935
18936 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18937 if (!spec)
18938 return -ENOMEM;
18939
18940 codec->spec = spec;
18941
Kailang Yangda00c242010-03-19 11:23:45 +010018942 alc_auto_parse_customize_define(codec);
18943
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018944 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18945
Kailang Yangc027ddc2010-03-19 11:33:06 +010018946 if (alc_read_coef_idx(codec, 0) == 0x8020)
18947 alc_codec_rename(codec, "ALC661");
18948 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18949 codec->bus->pci->subsystem_vendor == 0x1025 &&
18950 spec->cdefine.platform_type == 1)
18951 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018952
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018953 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18954 alc662_models,
18955 alc662_cfg_tbl);
18956 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018957 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18958 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018959 board_config = ALC662_AUTO;
18960 }
18961
18962 if (board_config == ALC662_AUTO) {
18963 /* automatic parse from the BIOS config */
18964 err = alc662_parse_auto_config(codec);
18965 if (err < 0) {
18966 alc_free(codec);
18967 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018968 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018969 printk(KERN_INFO
18970 "hda_codec: Cannot set up configuration "
18971 "from BIOS. Using base mode...\n");
18972 board_config = ALC662_3ST_2ch_DIG;
18973 }
18974 }
18975
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018976 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020018977 err = snd_hda_attach_beep_device(codec, 0x1);
18978 if (err < 0) {
18979 alc_free(codec);
18980 return err;
18981 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018982 }
18983
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018984 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018985 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018986
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018987 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18988 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18989
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018990 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18991 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18992
Takashi Iwaidd704692009-08-11 08:45:11 +020018993 if (!spec->adc_nids) {
18994 spec->adc_nids = alc662_adc_nids;
18995 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18996 }
18997 if (!spec->capsrc_nids)
18998 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018999
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019000 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019001 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019002
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019003 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019004 switch (codec->vendor_id) {
19005 case 0x10ec0662:
19006 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19007 break;
19008 case 0x10ec0272:
19009 case 0x10ec0663:
19010 case 0x10ec0665:
19011 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19012 break;
19013 case 0x10ec0273:
19014 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19015 break;
19016 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019017 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019018 spec->vmaster_nid = 0x02;
19019
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019020 codec->patch_ops = alc_patch_ops;
19021 if (board_config == ALC662_AUTO)
19022 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020019023#ifdef CONFIG_SND_HDA_POWER_SAVE
19024 if (!spec->loopback.amplist)
19025 spec->loopback.amplist = alc662_loopbacks;
19026#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019027
19028 return 0;
19029}
19030
Kailang Yang274693f2009-12-03 10:07:50 +010019031static int patch_alc888(struct hda_codec *codec)
19032{
19033 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19034 kfree(codec->chip_name);
19035 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019036 if (!codec->chip_name) {
19037 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019038 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019039 }
19040 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019041 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019042 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019043}
19044
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019045/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019046 * ALC680 support
19047 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019048#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019049#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19050#define alc680_modes alc260_modes
19051
19052static hda_nid_t alc680_dac_nids[3] = {
19053 /* Lout1, Lout2, hp */
19054 0x02, 0x03, 0x04
19055};
19056
19057static hda_nid_t alc680_adc_nids[3] = {
19058 /* ADC0-2 */
19059 /* DMIC, MIC, Line-in*/
19060 0x07, 0x08, 0x09
19061};
19062
Kailang Yangc69aefa2010-08-17 10:39:22 +020019063/*
19064 * Analog capture ADC cgange
19065 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019066static void alc680_rec_autoswitch(struct hda_codec *codec)
19067{
19068 struct alc_spec *spec = codec->spec;
19069 struct auto_pin_cfg *cfg = &spec->autocfg;
19070 int pin_found = 0;
19071 int type_found = AUTO_PIN_LAST;
19072 hda_nid_t nid;
19073 int i;
19074
19075 for (i = 0; i < cfg->num_inputs; i++) {
19076 nid = cfg->inputs[i].pin;
19077 if (!(snd_hda_query_pin_caps(codec, nid) &
19078 AC_PINCAP_PRES_DETECT))
19079 continue;
19080 if (snd_hda_jack_detect(codec, nid)) {
19081 if (cfg->inputs[i].type < type_found) {
19082 type_found = cfg->inputs[i].type;
19083 pin_found = nid;
19084 }
19085 }
19086 }
19087
19088 nid = 0x07;
19089 if (pin_found)
19090 snd_hda_get_connections(codec, pin_found, &nid, 1);
19091
19092 if (nid != spec->cur_adc)
19093 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19094 spec->cur_adc = nid;
19095 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19096 spec->cur_adc_format);
19097}
19098
Kailang Yangc69aefa2010-08-17 10:39:22 +020019099static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19100 struct hda_codec *codec,
19101 unsigned int stream_tag,
19102 unsigned int format,
19103 struct snd_pcm_substream *substream)
19104{
19105 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019106
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019107 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019108 spec->cur_adc_stream_tag = stream_tag;
19109 spec->cur_adc_format = format;
19110
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019111 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019112 return 0;
19113}
19114
19115static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19116 struct hda_codec *codec,
19117 struct snd_pcm_substream *substream)
19118{
19119 snd_hda_codec_cleanup_stream(codec, 0x07);
19120 snd_hda_codec_cleanup_stream(codec, 0x08);
19121 snd_hda_codec_cleanup_stream(codec, 0x09);
19122 return 0;
19123}
19124
19125static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19126 .substreams = 1, /* can be overridden */
19127 .channels_min = 2,
19128 .channels_max = 2,
19129 /* NID is set in alc_build_pcms */
19130 .ops = {
19131 .prepare = alc680_capture_pcm_prepare,
19132 .cleanup = alc680_capture_pcm_cleanup
19133 },
19134};
19135
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019136static struct snd_kcontrol_new alc680_base_mixer[] = {
19137 /* output mixer control */
19138 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19139 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19140 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019142 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019144 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019145 { }
19146};
19147
Kailang Yangc69aefa2010-08-17 10:39:22 +020019148static struct hda_bind_ctls alc680_bind_cap_vol = {
19149 .ops = &snd_hda_bind_vol,
19150 .values = {
19151 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19152 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19153 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19154 0
19155 },
19156};
19157
19158static struct hda_bind_ctls alc680_bind_cap_switch = {
19159 .ops = &snd_hda_bind_sw,
19160 .values = {
19161 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19162 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19163 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19164 0
19165 },
19166};
19167
19168static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19169 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19170 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019171 { } /* end */
19172};
19173
19174/*
19175 * generic initialization of ADC, input mixers and output mixers
19176 */
19177static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019178 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19179 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19180 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019181
Kailang Yangc69aefa2010-08-17 10:39:22 +020019182 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019188
19189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19191 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19192 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19193 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019194
19195 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19196 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019197 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019198
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019199 { }
19200};
19201
Kailang Yangc69aefa2010-08-17 10:39:22 +020019202/* toggle speaker-output according to the hp-jack state */
19203static void alc680_base_setup(struct hda_codec *codec)
19204{
19205 struct alc_spec *spec = codec->spec;
19206
19207 spec->autocfg.hp_pins[0] = 0x16;
19208 spec->autocfg.speaker_pins[0] = 0x14;
19209 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019210 spec->autocfg.num_inputs = 2;
19211 spec->autocfg.inputs[0].pin = 0x18;
19212 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19213 spec->autocfg.inputs[1].pin = 0x19;
19214 spec->autocfg.inputs[1].type = AUTO_PIN_LINE;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019215}
19216
19217static void alc680_unsol_event(struct hda_codec *codec,
19218 unsigned int res)
19219{
19220 if ((res >> 26) == ALC880_HP_EVENT)
19221 alc_automute_amp(codec);
19222 if ((res >> 26) == ALC880_MIC_EVENT)
19223 alc680_rec_autoswitch(codec);
19224}
19225
19226static void alc680_inithook(struct hda_codec *codec)
19227{
19228 alc_automute_amp(codec);
19229 alc680_rec_autoswitch(codec);
19230}
19231
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019232/* create input playback/capture controls for the given pin */
19233static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19234 const char *ctlname, int idx)
19235{
19236 hda_nid_t dac;
19237 int err;
19238
19239 switch (nid) {
19240 case 0x14:
19241 dac = 0x02;
19242 break;
19243 case 0x15:
19244 dac = 0x03;
19245 break;
19246 case 0x16:
19247 dac = 0x04;
19248 break;
19249 default:
19250 return 0;
19251 }
19252 if (spec->multiout.dac_nids[0] != dac &&
19253 spec->multiout.dac_nids[1] != dac) {
19254 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19255 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19256 HDA_OUTPUT));
19257 if (err < 0)
19258 return err;
19259
19260 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19261 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19262
19263 if (err < 0)
19264 return err;
19265 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19266 }
19267
19268 return 0;
19269}
19270
19271/* add playback controls from the parsed DAC table */
19272static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19273 const struct auto_pin_cfg *cfg)
19274{
19275 hda_nid_t nid;
19276 int err;
19277
19278 spec->multiout.dac_nids = spec->private_dac_nids;
19279
19280 nid = cfg->line_out_pins[0];
19281 if (nid) {
19282 const char *name;
19283 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19284 name = "Speaker";
19285 else
19286 name = "Front";
19287 err = alc680_new_analog_output(spec, nid, name, 0);
19288 if (err < 0)
19289 return err;
19290 }
19291
19292 nid = cfg->speaker_pins[0];
19293 if (nid) {
19294 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19295 if (err < 0)
19296 return err;
19297 }
19298 nid = cfg->hp_pins[0];
19299 if (nid) {
19300 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19301 if (err < 0)
19302 return err;
19303 }
19304
19305 return 0;
19306}
19307
19308static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19309 hda_nid_t nid, int pin_type)
19310{
19311 alc_set_pin_output(codec, nid, pin_type);
19312}
19313
19314static void alc680_auto_init_multi_out(struct hda_codec *codec)
19315{
19316 struct alc_spec *spec = codec->spec;
19317 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19318 if (nid) {
19319 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19320 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19321 }
19322}
19323
19324static void alc680_auto_init_hp_out(struct hda_codec *codec)
19325{
19326 struct alc_spec *spec = codec->spec;
19327 hda_nid_t pin;
19328
19329 pin = spec->autocfg.hp_pins[0];
19330 if (pin)
19331 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19332 pin = spec->autocfg.speaker_pins[0];
19333 if (pin)
19334 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19335}
19336
19337/* pcm configuration: identical with ALC880 */
19338#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19339#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19340#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19341#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019342#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019343
19344/*
19345 * BIOS auto configuration
19346 */
19347static int alc680_parse_auto_config(struct hda_codec *codec)
19348{
19349 struct alc_spec *spec = codec->spec;
19350 int err;
19351 static hda_nid_t alc680_ignore[] = { 0 };
19352
19353 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19354 alc680_ignore);
19355 if (err < 0)
19356 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019357
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019358 if (!spec->autocfg.line_outs) {
19359 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19360 spec->multiout.max_channels = 2;
19361 spec->no_analog = 1;
19362 goto dig_only;
19363 }
19364 return 0; /* can't find valid BIOS pin config */
19365 }
19366 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19367 if (err < 0)
19368 return err;
19369
19370 spec->multiout.max_channels = 2;
19371
19372 dig_only:
19373 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019374 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019375 if (spec->kctls.list)
19376 add_mixer(spec, spec->kctls.list);
19377
19378 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019379
19380 err = alc_auto_add_mic_boost(codec);
19381 if (err < 0)
19382 return err;
19383
19384 return 1;
19385}
19386
19387#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19388
19389/* init callback for auto-configuration model -- overriding the default init */
19390static void alc680_auto_init(struct hda_codec *codec)
19391{
19392 struct alc_spec *spec = codec->spec;
19393 alc680_auto_init_multi_out(codec);
19394 alc680_auto_init_hp_out(codec);
19395 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019396 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019397 if (spec->unsol_event)
19398 alc_inithook(codec);
19399}
19400
19401/*
19402 * configuration and preset
19403 */
19404static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019405 [ALC680_BASE] = "base",
19406 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019407};
19408
19409static struct snd_pci_quirk alc680_cfg_tbl[] = {
19410 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19411 {}
19412};
19413
19414static struct alc_config_preset alc680_presets[] = {
19415 [ALC680_BASE] = {
19416 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019417 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019418 .init_verbs = { alc680_init_verbs },
19419 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19420 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019421 .dig_out_nid = ALC680_DIGOUT_NID,
19422 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19423 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019424 .unsol_event = alc680_unsol_event,
19425 .setup = alc680_base_setup,
19426 .init_hook = alc680_inithook,
19427
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019428 },
19429};
19430
19431static int patch_alc680(struct hda_codec *codec)
19432{
19433 struct alc_spec *spec;
19434 int board_config;
19435 int err;
19436
19437 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19438 if (spec == NULL)
19439 return -ENOMEM;
19440
19441 codec->spec = spec;
19442
19443 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19444 alc680_models,
19445 alc680_cfg_tbl);
19446
19447 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19448 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19449 codec->chip_name);
19450 board_config = ALC680_AUTO;
19451 }
19452
19453 if (board_config == ALC680_AUTO) {
19454 /* automatic parse from the BIOS config */
19455 err = alc680_parse_auto_config(codec);
19456 if (err < 0) {
19457 alc_free(codec);
19458 return err;
19459 } else if (!err) {
19460 printk(KERN_INFO
19461 "hda_codec: Cannot set up configuration "
19462 "from BIOS. Using base mode...\n");
19463 board_config = ALC680_BASE;
19464 }
19465 }
19466
19467 if (board_config != ALC680_AUTO)
19468 setup_preset(codec, &alc680_presets[board_config]);
19469
19470 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019471 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019472 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019473 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019474
19475 if (!spec->adc_nids) {
19476 spec->adc_nids = alc680_adc_nids;
19477 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19478 }
19479
19480 if (!spec->cap_mixer)
19481 set_capture_mixer(codec);
19482
19483 spec->vmaster_nid = 0x02;
19484
19485 codec->patch_ops = alc_patch_ops;
19486 if (board_config == ALC680_AUTO)
19487 spec->init_hook = alc680_auto_init;
19488
19489 return 0;
19490}
19491
19492/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019493 * patch entries
19494 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019495static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019496 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019497 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019498 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019499 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019500 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019501 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019502 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019503 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019504 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019505 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019506 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19507 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19508 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019509 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019510 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019511 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19512 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019513 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019514 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019515 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019516 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019517 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019518 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019519 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019520 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019521 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019522 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019523 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019524 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019525 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019526 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019527 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019528 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019529 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019530 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019531 {} /* terminator */
19532};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019533
19534MODULE_ALIAS("snd-hda-codec-id:10ec*");
19535
19536MODULE_LICENSE("GPL");
19537MODULE_DESCRIPTION("Realtek HD-audio codec");
19538
19539static struct hda_codec_preset_list realtek_list = {
19540 .preset = snd_hda_preset_realtek,
19541 .owner = THIS_MODULE,
19542};
19543
19544static int __init patch_realtek_init(void)
19545{
19546 return snd_hda_add_codec_preset(&realtek_list);
19547}
19548
19549static void __exit patch_realtek_exit(void)
19550{
19551 snd_hda_delete_codec_preset(&realtek_list);
19552}
19553
19554module_init(patch_realtek_init)
19555module_exit(patch_realtek_exit)