blob: 8ae30ccf537a7c56f9cc35b595864f74d8e5534e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e42006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e42006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang 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 Avdoninbab282b2006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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
Takashi Iwai86e29592010-09-09 14:50:17 +0200849 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100850 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++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001301 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
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 Iwaib5786e82010-09-09 14:21:17 +02004977 snd_hda_get_input_pin_label(cfg, i,
4978 imux->items[imux->num_items].label);
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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-02-09 12:01:26 +01006841#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006842 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Iwaia3f730a2009-08-31 08:15:26 +02007395 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007396 */
Takashi Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Avdoninbab282b2006-08-22 13:31:58 +020010052 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010053 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-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 Avdoninbab282b2006-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++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010625 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010626 break;
10627 nid = cfg->inputs[i].pin;
10628 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwaib5786e82010-09-09 14:21:17 +020010629 char pinname[32], label[32];
10630 snd_hda_get_input_pin_label(cfg, i, pinname);
10631 snprintf(label, sizeof(label), "%s Boost", pinname);
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010632 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
Takashi Iwai18675e42010-09-08 15:55:44 +020012208/*
12209 * Pin config fixes
12210 */
12211enum {
12212 PINFIX_FSC_H270,
12213};
12214
12215static const struct alc_fixup alc262_fixups[] = {
12216 [PINFIX_FSC_H270] = {
12217 .pins = (const struct alc_pincfg[]) {
12218 { 0x14, 0x99130110 }, /* speaker */
12219 { 0x15, 0x0221142f }, /* front HP */
12220 { 0x1b, 0x0121141f }, /* rear HP */
12221 { }
12222 }
12223 },
12224 [PINFIX_PB_M5210] = {
12225 .verbs = (const struct hda_verb[]) {
12226 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12227 {}
12228 }
12229 },
12230};
12231
12232static struct snd_pci_quirk alc262_fixup_tbl[] = {
12233 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12234 {}
12235};
12236
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012237
Takashi Iwaicb53c622007-08-10 17:21:45 +020012238#ifdef CONFIG_SND_HDA_POWER_SAVE
12239#define alc262_loopbacks alc880_loopbacks
12240#endif
12241
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012242/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012243#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12244#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12245#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12246#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12247
12248/*
12249 * BIOS auto configuration
12250 */
12251static int alc262_parse_auto_config(struct hda_codec *codec)
12252{
12253 struct alc_spec *spec = codec->spec;
12254 int err;
12255 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12256
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012257 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12258 alc262_ignore);
12259 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012260 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012261 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012262 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012263 spec->multiout.max_channels = 2;
12264 spec->no_analog = 1;
12265 goto dig_only;
12266 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012267 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012268 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012269 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12270 if (err < 0)
12271 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012272 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012273 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012274 return err;
12275
12276 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12277
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012278 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012279 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012280
Takashi Iwai603c4012008-07-30 15:01:44 +020012281 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012282 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012283
Takashi Iwaid88897e2008-10-31 15:01:37 +010012284 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012285 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012286 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012287
Takashi Iwai776e1842007-08-29 15:07:11 +020012288 err = alc_auto_add_mic_boost(codec);
12289 if (err < 0)
12290 return err;
12291
Kailang Yang6227cdc2010-02-25 08:36:52 +010012292 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012293
Kailang Yangdf694da2005-12-05 19:42:22 +010012294 return 1;
12295}
12296
12297#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12298#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12299#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012300#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012301
12302
12303/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012304static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012305{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012306 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012307 alc262_auto_init_multi_out(codec);
12308 alc262_auto_init_hp_out(codec);
12309 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012310 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012311 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012312 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012313 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012314}
12315
12316/*
12317 * configuration and preset
12318 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012319static const char *alc262_models[ALC262_MODEL_LAST] = {
12320 [ALC262_BASIC] = "basic",
12321 [ALC262_HIPPO] = "hippo",
12322 [ALC262_HIPPO_1] = "hippo_1",
12323 [ALC262_FUJITSU] = "fujitsu",
12324 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012325 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012326 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012327 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012328 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012329 [ALC262_BENQ_T31] = "benq-t31",
12330 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012331 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012332 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012333 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012334 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012335 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012336 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012337 [ALC262_AUTO] = "auto",
12338};
12339
12340static struct snd_pci_quirk alc262_cfg_tbl[] = {
12341 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012342 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012343 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12344 ALC262_HP_BPC),
12345 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12346 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012347 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12348 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012349 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012350 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012351 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012352 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012353 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012354 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012355 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012356 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012357 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12358 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12359 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012360 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12361 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012362 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012363 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012364 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012365 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012366 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012367 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012368 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012369 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012370#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012371 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12372 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012373#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012374 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012375 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012376 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012377 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012378 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012379 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012380 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12381 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012382 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012383 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012384 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012385 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012386 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012387 {}
12388};
12389
12390static struct alc_config_preset alc262_presets[] = {
12391 [ALC262_BASIC] = {
12392 .mixers = { alc262_base_mixer },
12393 .init_verbs = { alc262_init_verbs },
12394 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12395 .dac_nids = alc262_dac_nids,
12396 .hp_nid = 0x03,
12397 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12398 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012399 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012400 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012401 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012402 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012403 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012404 .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_capture_source,
12411 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012412 .setup = alc262_hippo_setup,
12413 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012414 },
12415 [ALC262_HIPPO_1] = {
12416 .mixers = { alc262_hippo1_mixer },
12417 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12418 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12419 .dac_nids = alc262_dac_nids,
12420 .hp_nid = 0x02,
12421 .dig_out_nid = ALC262_DIGOUT_NID,
12422 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12423 .channel_mode = alc262_modes,
12424 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012425 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012426 .setup = alc262_hippo1_setup,
12427 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012428 },
Takashi Iwai834be882006-03-01 14:16:17 +010012429 [ALC262_FUJITSU] = {
12430 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012431 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12432 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012433 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12434 .dac_nids = alc262_dac_nids,
12435 .hp_nid = 0x03,
12436 .dig_out_nid = ALC262_DIGOUT_NID,
12437 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12438 .channel_mode = alc262_modes,
12439 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012440 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012441 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012442 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012443 [ALC262_HP_BPC] = {
12444 .mixers = { alc262_HP_BPC_mixer },
12445 .init_verbs = { alc262_HP_BPC_init_verbs },
12446 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12447 .dac_nids = alc262_dac_nids,
12448 .hp_nid = 0x03,
12449 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12450 .channel_mode = alc262_modes,
12451 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012452 .unsol_event = alc262_hp_bpc_unsol_event,
12453 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012454 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012455 [ALC262_HP_BPC_D7000_WF] = {
12456 .mixers = { alc262_HP_BPC_WildWest_mixer },
12457 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12458 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12459 .dac_nids = alc262_dac_nids,
12460 .hp_nid = 0x03,
12461 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12462 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012463 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012464 .unsol_event = alc262_hp_wildwest_unsol_event,
12465 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012466 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012467 [ALC262_HP_BPC_D7000_WL] = {
12468 .mixers = { alc262_HP_BPC_WildWest_mixer,
12469 alc262_HP_BPC_WildWest_option_mixer },
12470 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12471 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12472 .dac_nids = alc262_dac_nids,
12473 .hp_nid = 0x03,
12474 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12475 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012476 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012477 .unsol_event = alc262_hp_wildwest_unsol_event,
12478 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012479 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012480 [ALC262_HP_TC_T5735] = {
12481 .mixers = { alc262_hp_t5735_mixer },
12482 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12483 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12484 .dac_nids = alc262_dac_nids,
12485 .hp_nid = 0x03,
12486 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12487 .channel_mode = alc262_modes,
12488 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012489 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012490 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012491 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012492 },
12493 [ALC262_HP_RP5700] = {
12494 .mixers = { alc262_hp_rp5700_mixer },
12495 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12496 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12497 .dac_nids = alc262_dac_nids,
12498 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12499 .channel_mode = alc262_modes,
12500 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012501 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012502 [ALC262_BENQ_ED8] = {
12503 .mixers = { alc262_base_mixer },
12504 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12505 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12506 .dac_nids = alc262_dac_nids,
12507 .hp_nid = 0x03,
12508 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12509 .channel_mode = alc262_modes,
12510 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012511 },
Kailang Yang272a5272007-05-14 11:00:38 +020012512 [ALC262_SONY_ASSAMD] = {
12513 .mixers = { alc262_sony_mixer },
12514 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12515 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12516 .dac_nids = alc262_dac_nids,
12517 .hp_nid = 0x02,
12518 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12519 .channel_mode = alc262_modes,
12520 .input_mux = &alc262_capture_source,
12521 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012522 .setup = alc262_hippo_setup,
12523 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012524 },
12525 [ALC262_BENQ_T31] = {
12526 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012527 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12528 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012529 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12530 .dac_nids = alc262_dac_nids,
12531 .hp_nid = 0x03,
12532 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12533 .channel_mode = alc262_modes,
12534 .input_mux = &alc262_capture_source,
12535 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012536 .setup = alc262_hippo_setup,
12537 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012538 },
Tobin Davisf651b502007-10-26 12:40:47 +020012539 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012540 .mixers = { alc262_ultra_mixer },
12541 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012542 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012543 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12544 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012545 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12546 .channel_mode = alc262_modes,
12547 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012548 .adc_nids = alc262_adc_nids, /* ADC0 */
12549 .capsrc_nids = alc262_capsrc_nids,
12550 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012551 .unsol_event = alc262_ultra_unsol_event,
12552 .init_hook = alc262_ultra_automute,
12553 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012554 [ALC262_LENOVO_3000] = {
12555 .mixers = { alc262_lenovo_3000_mixer },
12556 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012557 alc262_lenovo_3000_unsol_verbs,
12558 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012559 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12560 .dac_nids = alc262_dac_nids,
12561 .hp_nid = 0x03,
12562 .dig_out_nid = ALC262_DIGOUT_NID,
12563 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12564 .channel_mode = alc262_modes,
12565 .input_mux = &alc262_fujitsu_capture_source,
12566 .unsol_event = alc262_lenovo_3000_unsol_event,
12567 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012568 [ALC262_NEC] = {
12569 .mixers = { alc262_nec_mixer },
12570 .init_verbs = { alc262_nec_verbs },
12571 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12572 .dac_nids = alc262_dac_nids,
12573 .hp_nid = 0x03,
12574 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12575 .channel_mode = alc262_modes,
12576 .input_mux = &alc262_capture_source,
12577 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012578 [ALC262_TOSHIBA_S06] = {
12579 .mixers = { alc262_toshiba_s06_mixer },
12580 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12581 alc262_eapd_verbs },
12582 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12583 .capsrc_nids = alc262_dmic_capsrc_nids,
12584 .dac_nids = alc262_dac_nids,
12585 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012586 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012587 .dig_out_nid = ALC262_DIGOUT_NID,
12588 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12589 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012590 .unsol_event = alc_sku_unsol_event,
12591 .setup = alc262_toshiba_s06_setup,
12592 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012593 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012594 [ALC262_TOSHIBA_RX1] = {
12595 .mixers = { alc262_toshiba_rx1_mixer },
12596 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12597 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12598 .dac_nids = alc262_dac_nids,
12599 .hp_nid = 0x03,
12600 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12601 .channel_mode = alc262_modes,
12602 .input_mux = &alc262_capture_source,
12603 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012604 .setup = alc262_hippo_setup,
12605 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012606 },
Tony Vroonba340e82009-02-02 19:01:30 +000012607 [ALC262_TYAN] = {
12608 .mixers = { alc262_tyan_mixer },
12609 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12610 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12611 .dac_nids = alc262_dac_nids,
12612 .hp_nid = 0x02,
12613 .dig_out_nid = ALC262_DIGOUT_NID,
12614 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12615 .channel_mode = alc262_modes,
12616 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012617 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012618 .setup = alc262_tyan_setup,
12619 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012620 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012621};
12622
12623static int patch_alc262(struct hda_codec *codec)
12624{
12625 struct alc_spec *spec;
12626 int board_config;
12627 int err;
12628
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012629 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012630 if (spec == NULL)
12631 return -ENOMEM;
12632
12633 codec->spec = spec;
12634#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012635 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12636 * under-run
12637 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012638 {
12639 int tmp;
12640 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12641 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12642 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12643 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12644 }
12645#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012646 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012647
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012648 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12649
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012650 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12651 alc262_models,
12652 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012653
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012654 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012655 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12656 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012657 board_config = ALC262_AUTO;
12658 }
12659
Takashi Iwai18675e42010-09-08 15:55:44 +020012660 if (board_config == ALC262_AUTO)
12661 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12662
Kailang Yangdf694da2005-12-05 19:42:22 +010012663 if (board_config == ALC262_AUTO) {
12664 /* automatic parse from the BIOS config */
12665 err = alc262_parse_auto_config(codec);
12666 if (err < 0) {
12667 alc_free(codec);
12668 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012669 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012670 printk(KERN_INFO
12671 "hda_codec: Cannot set up configuration "
12672 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012673 board_config = ALC262_BASIC;
12674 }
12675 }
12676
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012677 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012678 err = snd_hda_attach_beep_device(codec, 0x1);
12679 if (err < 0) {
12680 alc_free(codec);
12681 return err;
12682 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012683 }
12684
Kailang Yangdf694da2005-12-05 19:42:22 +010012685 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012686 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012687
Kailang Yangdf694da2005-12-05 19:42:22 +010012688 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12689 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012690
Kailang Yangdf694da2005-12-05 19:42:22 +010012691 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12692 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12693
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012694 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012695 int i;
12696 /* check whether the digital-mic has to be supported */
12697 for (i = 0; i < spec->input_mux->num_items; i++) {
12698 if (spec->input_mux->items[i].index >= 9)
12699 break;
12700 }
12701 if (i < spec->input_mux->num_items) {
12702 /* use only ADC0 */
12703 spec->adc_nids = alc262_dmic_adc_nids;
12704 spec->num_adc_nids = 1;
12705 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012706 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012707 /* all analog inputs */
12708 /* check whether NID 0x07 is valid */
12709 unsigned int wcap = get_wcaps(codec, 0x07);
12710
12711 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012712 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012713 if (wcap != AC_WID_AUD_IN) {
12714 spec->adc_nids = alc262_adc_nids_alt;
12715 spec->num_adc_nids =
12716 ARRAY_SIZE(alc262_adc_nids_alt);
12717 spec->capsrc_nids = alc262_capsrc_nids_alt;
12718 } else {
12719 spec->adc_nids = alc262_adc_nids;
12720 spec->num_adc_nids =
12721 ARRAY_SIZE(alc262_adc_nids);
12722 spec->capsrc_nids = alc262_capsrc_nids;
12723 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012724 }
12725 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012726 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012727 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012728 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012729 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012730
Takashi Iwai18675e42010-09-08 15:55:44 +020012731 if (board_config == ALC262_AUTO)
12732 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12733
Takashi Iwai2134ea42008-01-10 16:53:55 +010012734 spec->vmaster_nid = 0x0c;
12735
Kailang Yangdf694da2005-12-05 19:42:22 +010012736 codec->patch_ops = alc_patch_ops;
12737 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012738 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012739#ifdef CONFIG_SND_HDA_POWER_SAVE
12740 if (!spec->loopback.amplist)
12741 spec->loopback.amplist = alc262_loopbacks;
12742#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012743
Kailang Yangdf694da2005-12-05 19:42:22 +010012744 return 0;
12745}
12746
Kailang Yangdf694da2005-12-05 19:42:22 +010012747/*
Kailang Yanga361d842007-06-05 12:30:55 +020012748 * ALC268 channel source setting (2 channel)
12749 */
12750#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12751#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012752
Kailang Yanga361d842007-06-05 12:30:55 +020012753static hda_nid_t alc268_dac_nids[2] = {
12754 /* front, hp */
12755 0x02, 0x03
12756};
12757
12758static hda_nid_t alc268_adc_nids[2] = {
12759 /* ADC0-1 */
12760 0x08, 0x07
12761};
12762
12763static hda_nid_t alc268_adc_nids_alt[1] = {
12764 /* ADC0 */
12765 0x08
12766};
12767
Takashi Iwaie1406342008-02-11 18:32:32 +010012768static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12769
Kailang Yanga361d842007-06-05 12:30:55 +020012770static struct snd_kcontrol_new alc268_base_mixer[] = {
12771 /* output mixer control */
12772 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12773 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12774 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12775 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12777 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12778 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012779 { }
12780};
12781
Takashi Iwai42171c12009-05-08 14:11:43 +020012782static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12783 /* output mixer control */
12784 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12785 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12786 ALC262_HIPPO_MASTER_SWITCH,
12787 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12788 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12789 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12790 { }
12791};
12792
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012793/* bind Beep switches of both NID 0x0f and 0x10 */
12794static struct hda_bind_ctls alc268_bind_beep_sw = {
12795 .ops = &snd_hda_bind_sw,
12796 .values = {
12797 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12798 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12799 0
12800 },
12801};
12802
12803static struct snd_kcontrol_new alc268_beep_mixer[] = {
12804 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12805 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12806 { }
12807};
12808
Kailang Yangd1a991a2007-08-15 16:21:59 +020012809static struct hda_verb alc268_eapd_verbs[] = {
12810 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12811 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12812 { }
12813};
12814
Takashi Iwaid2738092007-08-16 14:59:45 +020012815/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012816static struct hda_verb alc268_toshiba_verbs[] = {
12817 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12818 { } /* end */
12819};
12820
12821/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012822/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012823static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12824 .ops = &snd_hda_bind_vol,
12825 .values = {
12826 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12827 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12828 0
12829 },
12830};
12831
Takashi Iwai889c4392007-08-23 18:56:52 +020012832/* mute/unmute internal speaker according to the hp jack and mute state */
12833static void alc268_acer_automute(struct hda_codec *codec, int force)
12834{
12835 struct alc_spec *spec = codec->spec;
12836 unsigned int mute;
12837
12838 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012839 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012840 spec->sense_updated = 1;
12841 }
12842 if (spec->jack_present)
12843 mute = HDA_AMP_MUTE; /* mute internal speaker */
12844 else /* unmute internal speaker if necessary */
12845 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12846 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12847 HDA_AMP_MUTE, mute);
12848}
12849
12850
12851/* bind hp and internal speaker mute (with plug check) */
12852static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12853 struct snd_ctl_elem_value *ucontrol)
12854{
12855 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12856 long *valp = ucontrol->value.integer.value;
12857 int change;
12858
Takashi Iwai8de56b72009-07-24 16:51:47 +020012859 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012860 if (change)
12861 alc268_acer_automute(codec, 0);
12862 return change;
12863}
Takashi Iwaid2738092007-08-16 14:59:45 +020012864
Kailang Yang8ef355d2008-08-26 13:10:22 +020012865static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12866 /* output mixer control */
12867 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12868 {
12869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12870 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012871 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012872 .info = snd_hda_mixer_amp_switch_info,
12873 .get = snd_hda_mixer_amp_switch_get,
12874 .put = alc268_acer_master_sw_put,
12875 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12876 },
12877 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12878 { }
12879};
12880
Takashi Iwaid2738092007-08-16 14:59:45 +020012881static struct snd_kcontrol_new alc268_acer_mixer[] = {
12882 /* output mixer control */
12883 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12884 {
12885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12886 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012887 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012888 .info = snd_hda_mixer_amp_switch_info,
12889 .get = snd_hda_mixer_amp_switch_get,
12890 .put = alc268_acer_master_sw_put,
12891 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12892 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012893 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12894 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12895 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012896 { }
12897};
12898
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012899static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12900 /* output mixer control */
12901 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12902 {
12903 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12904 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012905 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012906 .info = snd_hda_mixer_amp_switch_info,
12907 .get = snd_hda_mixer_amp_switch_get,
12908 .put = alc268_acer_master_sw_put,
12909 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12910 },
12911 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12912 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12913 { }
12914};
12915
Kailang Yang8ef355d2008-08-26 13:10:22 +020012916static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12917 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12919 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12920 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12921 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12922 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12923 { }
12924};
12925
Takashi Iwaid2738092007-08-16 14:59:45 +020012926static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012927 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12928 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012929 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12930 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012931 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012933 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12934 { }
12935};
12936
12937/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012938#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012939#define alc268_toshiba_setup alc262_hippo_setup
12940#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012941
12942static void alc268_acer_unsol_event(struct hda_codec *codec,
12943 unsigned int res)
12944{
Takashi Iwai889c4392007-08-23 18:56:52 +020012945 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012946 return;
12947 alc268_acer_automute(codec, 1);
12948}
12949
Takashi Iwai889c4392007-08-23 18:56:52 +020012950static void alc268_acer_init_hook(struct hda_codec *codec)
12951{
12952 alc268_acer_automute(codec, 1);
12953}
12954
Kailang Yang8ef355d2008-08-26 13:10:22 +020012955/* toggle speaker-output according to the hp-jack state */
12956static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12957{
12958 unsigned int present;
12959 unsigned char bits;
12960
Wu Fengguang864f92b2009-11-18 12:38:02 +080012961 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012962 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012963 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012964 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012965 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012966 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012967}
12968
Kailang Yang8ef355d2008-08-26 13:10:22 +020012969static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12970 unsigned int res)
12971{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012972 switch (res >> 26) {
12973 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012974 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012975 break;
12976 case ALC880_MIC_EVENT:
12977 alc_mic_automute(codec);
12978 break;
12979 }
12980}
12981
12982static void alc268_acer_lc_setup(struct hda_codec *codec)
12983{
12984 struct alc_spec *spec = codec->spec;
12985 spec->ext_mic.pin = 0x18;
12986 spec->ext_mic.mux_idx = 0;
12987 spec->int_mic.pin = 0x12;
12988 spec->int_mic.mux_idx = 6;
12989 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012990}
12991
12992static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12993{
12994 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012995 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012996}
12997
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012998static struct snd_kcontrol_new alc268_dell_mixer[] = {
12999 /* output mixer control */
13000 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13001 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13002 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13003 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13004 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13005 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13006 { }
13007};
13008
13009static struct hda_verb alc268_dell_verbs[] = {
13010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13012 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013013 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013014 { }
13015};
13016
13017/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013018static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013019{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013020 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013021
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013022 spec->autocfg.hp_pins[0] = 0x15;
13023 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013024 spec->ext_mic.pin = 0x18;
13025 spec->ext_mic.mux_idx = 0;
13026 spec->int_mic.pin = 0x19;
13027 spec->int_mic.mux_idx = 1;
13028 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013029}
13030
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013031static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13032 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13033 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13034 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13035 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13036 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13037 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13038 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13039 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13040 { }
13041};
13042
13043static struct hda_verb alc267_quanta_il1_verbs[] = {
13044 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13045 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13046 { }
13047};
13048
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013049static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013050{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013051 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013052 spec->autocfg.hp_pins[0] = 0x15;
13053 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013054 spec->ext_mic.pin = 0x18;
13055 spec->ext_mic.mux_idx = 0;
13056 spec->int_mic.pin = 0x19;
13057 spec->int_mic.mux_idx = 1;
13058 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013059}
13060
Kailang Yanga361d842007-06-05 12:30:55 +020013061/*
13062 * generic initialization of ADC, input mixers and output mixers
13063 */
13064static struct hda_verb alc268_base_init_verbs[] = {
13065 /* Unmute DAC0-1 and set vol = 0 */
13066 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013067 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013068
13069 /*
13070 * Set up output mixers (0x0c - 0x0e)
13071 */
13072 /* set vol=0 to output mixers */
13073 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013074 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13075
13076 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13077 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13078
13079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13081 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
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
13088 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13089 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13090 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013092 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013093
13094 /* set PCBEEP vol = 0, mute connections */
13095 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13096 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13097 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013098
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013099 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013100
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013101 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13102 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13103 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013105
Kailang Yanga361d842007-06-05 12:30:55 +020013106 { }
13107};
13108
13109/*
13110 * generic initialization of ADC, input mixers and output mixers
13111 */
13112static struct hda_verb alc268_volume_init_verbs[] = {
13113 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013114 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13115 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013116
13117 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13118 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13119 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13120 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13121 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13122
Kailang Yanga361d842007-06-05 12:30:55 +020013123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013124 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13125 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13126
13127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013128 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013129
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013130 /* set PCBEEP vol = 0, mute connections */
13131 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13132 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13133 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013134
13135 { }
13136};
13137
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013138static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13139 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13140 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13141 { } /* end */
13142};
13143
Kailang Yanga361d842007-06-05 12:30:55 +020013144static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13145 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13146 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013147 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013148 { } /* end */
13149};
13150
13151static struct snd_kcontrol_new alc268_capture_mixer[] = {
13152 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13153 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13154 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13155 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013156 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013157 { } /* end */
13158};
13159
13160static struct hda_input_mux alc268_capture_source = {
13161 .num_items = 4,
13162 .items = {
13163 { "Mic", 0x0 },
13164 { "Front Mic", 0x1 },
13165 { "Line", 0x2 },
13166 { "CD", 0x3 },
13167 },
13168};
13169
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013170static struct hda_input_mux alc268_acer_capture_source = {
13171 .num_items = 3,
13172 .items = {
13173 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013174 { "Internal Mic", 0x1 },
13175 { "Line", 0x2 },
13176 },
13177};
13178
13179static struct hda_input_mux alc268_acer_dmic_capture_source = {
13180 .num_items = 3,
13181 .items = {
13182 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013183 { "Internal Mic", 0x6 },
13184 { "Line", 0x2 },
13185 },
13186};
13187
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013188#ifdef CONFIG_SND_DEBUG
13189static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013190 /* Volume widgets */
13191 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13192 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13193 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13194 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13195 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13196 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13197 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13198 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13199 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13200 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13201 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13202 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13203 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013204 /* The below appears problematic on some hardwares */
13205 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013206 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13207 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13208 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13209 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13210
13211 /* Modes for retasking pin widgets */
13212 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13213 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13214 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13215 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13216
13217 /* Controls for GPIO pins, assuming they are configured as outputs */
13218 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13219 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13220 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13221 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13222
13223 /* Switches to allow the digital SPDIF output pin to be enabled.
13224 * The ALC268 does not have an SPDIF input.
13225 */
13226 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13227
13228 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13229 * this output to turn on an external amplifier.
13230 */
13231 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13232 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13233
13234 { } /* end */
13235};
13236#endif
13237
Kailang Yanga361d842007-06-05 12:30:55 +020013238/* create input playback/capture controls for the given pin */
13239static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13240 const char *ctlname, int idx)
13241{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013242 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013243 int err;
13244
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013245 switch (nid) {
13246 case 0x14:
13247 case 0x16:
13248 dac = 0x02;
13249 break;
13250 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013251 case 0x1a: /* ALC259/269 only */
13252 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013253 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013254 dac = 0x03;
13255 break;
13256 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013257 snd_printd(KERN_WARNING "hda_codec: "
13258 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013259 return 0;
13260 }
13261 if (spec->multiout.dac_nids[0] != dac &&
13262 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013263 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013264 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013265 HDA_OUTPUT));
13266 if (err < 0)
13267 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013268 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13269 }
13270
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013271 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013272 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013273 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013274 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013275 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013276 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013277 if (err < 0)
13278 return err;
13279 return 0;
13280}
13281
13282/* add playback controls from the parsed DAC table */
13283static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13284 const struct auto_pin_cfg *cfg)
13285{
13286 hda_nid_t nid;
13287 int err;
13288
Kailang Yanga361d842007-06-05 12:30:55 +020013289 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013290
13291 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013292 if (nid) {
13293 const char *name;
13294 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13295 name = "Speaker";
13296 else
13297 name = "Front";
13298 err = alc268_new_analog_output(spec, nid, name, 0);
13299 if (err < 0)
13300 return err;
13301 }
Kailang Yanga361d842007-06-05 12:30:55 +020013302
13303 nid = cfg->speaker_pins[0];
13304 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013305 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013306 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13307 if (err < 0)
13308 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013309 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013310 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13311 if (err < 0)
13312 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013313 }
13314 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013315 if (nid) {
13316 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13317 if (err < 0)
13318 return err;
13319 }
Kailang Yanga361d842007-06-05 12:30:55 +020013320
13321 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13322 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013323 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013324 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013325 if (err < 0)
13326 return err;
13327 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013328 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013329}
13330
13331/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013332static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013333 const struct auto_pin_cfg *cfg)
13334{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013335 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013336}
13337
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013338static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13339 hda_nid_t nid, int pin_type)
13340{
13341 int idx;
13342
13343 alc_set_pin_output(codec, nid, pin_type);
13344 if (nid == 0x14 || nid == 0x16)
13345 idx = 0;
13346 else
13347 idx = 1;
13348 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13349}
13350
13351static void alc268_auto_init_multi_out(struct hda_codec *codec)
13352{
13353 struct alc_spec *spec = codec->spec;
13354 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13355 if (nid) {
13356 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13357 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13358 }
13359}
13360
13361static void alc268_auto_init_hp_out(struct hda_codec *codec)
13362{
13363 struct alc_spec *spec = codec->spec;
13364 hda_nid_t pin;
13365
13366 pin = spec->autocfg.hp_pins[0];
13367 if (pin)
13368 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13369 pin = spec->autocfg.speaker_pins[0];
13370 if (pin)
13371 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13372}
13373
Kailang Yanga361d842007-06-05 12:30:55 +020013374static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13375{
13376 struct alc_spec *spec = codec->spec;
13377 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13378 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13379 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13380 unsigned int dac_vol1, dac_vol2;
13381
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013382 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013383 snd_hda_codec_write(codec, speaker_nid, 0,
13384 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013385 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013386 snd_hda_codec_write(codec, 0x0f, 0,
13387 AC_VERB_SET_AMP_GAIN_MUTE,
13388 AMP_IN_UNMUTE(1));
13389 snd_hda_codec_write(codec, 0x10, 0,
13390 AC_VERB_SET_AMP_GAIN_MUTE,
13391 AMP_IN_UNMUTE(1));
13392 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013393 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013394 snd_hda_codec_write(codec, 0x0f, 0,
13395 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13396 snd_hda_codec_write(codec, 0x10, 0,
13397 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13398 }
13399
13400 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013401 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013402 dac_vol2 = AMP_OUT_ZERO;
13403 else if (line_nid == 0x15)
13404 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013405 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013406 dac_vol2 = AMP_OUT_ZERO;
13407 else if (hp_nid == 0x15)
13408 dac_vol1 = AMP_OUT_ZERO;
13409 if (line_nid != 0x16 || hp_nid != 0x16 ||
13410 spec->autocfg.line_out_pins[1] != 0x16 ||
13411 spec->autocfg.line_out_pins[2] != 0x16)
13412 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13413
13414 snd_hda_codec_write(codec, 0x02, 0,
13415 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13416 snd_hda_codec_write(codec, 0x03, 0,
13417 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13418}
13419
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013420/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013421#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13422#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013423#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013424#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13425
13426/*
13427 * BIOS auto configuration
13428 */
13429static int alc268_parse_auto_config(struct hda_codec *codec)
13430{
13431 struct alc_spec *spec = codec->spec;
13432 int err;
13433 static hda_nid_t alc268_ignore[] = { 0 };
13434
13435 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13436 alc268_ignore);
13437 if (err < 0)
13438 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013439 if (!spec->autocfg.line_outs) {
13440 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13441 spec->multiout.max_channels = 2;
13442 spec->no_analog = 1;
13443 goto dig_only;
13444 }
Kailang Yanga361d842007-06-05 12:30:55 +020013445 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013446 }
Kailang Yanga361d842007-06-05 12:30:55 +020013447 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13448 if (err < 0)
13449 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013450 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013451 if (err < 0)
13452 return err;
13453
13454 spec->multiout.max_channels = 2;
13455
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013456 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013457 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013458 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013459 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013460 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013461
Takashi Iwai892981f2009-03-02 08:04:35 +010013462 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013463 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013464
Takashi Iwaid88897e2008-10-31 15:01:37 +010013465 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013466 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013467 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013468
Takashi Iwai776e1842007-08-29 15:07:11 +020013469 err = alc_auto_add_mic_boost(codec);
13470 if (err < 0)
13471 return err;
13472
Kailang Yang6227cdc2010-02-25 08:36:52 +010013473 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013474
Kailang Yanga361d842007-06-05 12:30:55 +020013475 return 1;
13476}
13477
Kailang Yanga361d842007-06-05 12:30:55 +020013478#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13479
13480/* init callback for auto-configuration model -- overriding the default init */
13481static void alc268_auto_init(struct hda_codec *codec)
13482{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013483 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013484 alc268_auto_init_multi_out(codec);
13485 alc268_auto_init_hp_out(codec);
13486 alc268_auto_init_mono_speaker_out(codec);
13487 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013488 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013489 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013490 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013491}
13492
13493/*
13494 * configuration and preset
13495 */
13496static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013497 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013498 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013499 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013500 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013501 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013502 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013503 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013504 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013505#ifdef CONFIG_SND_DEBUG
13506 [ALC268_TEST] = "test",
13507#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013508 [ALC268_AUTO] = "auto",
13509};
13510
13511static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013512 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013513 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013514 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013515 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013516 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013517 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13518 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013519 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013520 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13521 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013522 /* almost compatible with toshiba but with optional digital outs;
13523 * auto-probing seems working fine
13524 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013525 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013526 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013527 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013528 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013529 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013530 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013531 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013532 {}
13533};
13534
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013535/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13536static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13537 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13538 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13539 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13540 ALC268_TOSHIBA),
13541 {}
13542};
13543
Kailang Yanga361d842007-06-05 12:30:55 +020013544static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013545 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013546 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13547 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013548 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13549 alc267_quanta_il1_verbs },
13550 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13551 .dac_nids = alc268_dac_nids,
13552 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13553 .adc_nids = alc268_adc_nids_alt,
13554 .hp_nid = 0x03,
13555 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13556 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013557 .unsol_event = alc_sku_unsol_event,
13558 .setup = alc267_quanta_il1_setup,
13559 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013560 },
Kailang Yanga361d842007-06-05 12:30:55 +020013561 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013562 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13563 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013564 .init_verbs = { alc268_base_init_verbs },
13565 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13566 .dac_nids = alc268_dac_nids,
13567 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13568 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013569 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013570 .hp_nid = 0x03,
13571 .dig_out_nid = ALC268_DIGOUT_NID,
13572 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13573 .channel_mode = alc268_modes,
13574 .input_mux = &alc268_capture_source,
13575 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013576 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013577 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013578 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013579 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13580 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013581 .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,
Takashi Iwaie1406342008-02-11 18:32:32 +010013585 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013586 .hp_nid = 0x03,
13587 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13588 .channel_mode = alc268_modes,
13589 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013590 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013591 .setup = alc268_toshiba_setup,
13592 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013593 },
13594 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013595 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013596 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013597 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13598 alc268_acer_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,
Takashi Iwaie1406342008-02-11 18:32:32 +010013603 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013604 .hp_nid = 0x02,
13605 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13606 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013607 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013608 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013609 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013610 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013611 [ALC268_ACER_DMIC] = {
13612 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13613 alc268_beep_mixer },
13614 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13615 alc268_acer_verbs },
13616 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13617 .dac_nids = alc268_dac_nids,
13618 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13619 .adc_nids = alc268_adc_nids_alt,
13620 .capsrc_nids = alc268_capsrc_nids,
13621 .hp_nid = 0x02,
13622 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13623 .channel_mode = alc268_modes,
13624 .input_mux = &alc268_acer_dmic_capture_source,
13625 .unsol_event = alc268_acer_unsol_event,
13626 .init_hook = alc268_acer_init_hook,
13627 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013628 [ALC268_ACER_ASPIRE_ONE] = {
13629 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013630 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013631 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013632 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13633 alc268_acer_aspire_one_verbs },
13634 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13635 .dac_nids = alc268_dac_nids,
13636 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13637 .adc_nids = alc268_adc_nids_alt,
13638 .capsrc_nids = alc268_capsrc_nids,
13639 .hp_nid = 0x03,
13640 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13641 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013642 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013643 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013644 .init_hook = alc268_acer_lc_init_hook,
13645 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013646 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013647 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13648 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013649 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13650 alc268_dell_verbs },
13651 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13652 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013653 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13654 .adc_nids = alc268_adc_nids_alt,
13655 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013656 .hp_nid = 0x02,
13657 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13658 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013659 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013660 .setup = alc268_dell_setup,
13661 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013662 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013663 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013664 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13665 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013666 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13667 alc268_toshiba_verbs },
13668 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13669 .dac_nids = alc268_dac_nids,
13670 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13671 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013672 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013673 .hp_nid = 0x03,
13674 .dig_out_nid = ALC268_DIGOUT_NID,
13675 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13676 .channel_mode = alc268_modes,
13677 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013678 .setup = alc268_toshiba_setup,
13679 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013680 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013681#ifdef CONFIG_SND_DEBUG
13682 [ALC268_TEST] = {
13683 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13684 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13685 alc268_volume_init_verbs },
13686 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13687 .dac_nids = alc268_dac_nids,
13688 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13689 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013690 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013691 .hp_nid = 0x03,
13692 .dig_out_nid = ALC268_DIGOUT_NID,
13693 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13694 .channel_mode = alc268_modes,
13695 .input_mux = &alc268_capture_source,
13696 },
13697#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013698};
13699
13700static int patch_alc268(struct hda_codec *codec)
13701{
13702 struct alc_spec *spec;
13703 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013704 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013705
Julia Lawallef86f582009-12-19 08:18:03 +010013706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013707 if (spec == NULL)
13708 return -ENOMEM;
13709
13710 codec->spec = spec;
13711
13712 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13713 alc268_models,
13714 alc268_cfg_tbl);
13715
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013716 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13717 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013718 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013719
Kailang Yanga361d842007-06-05 12:30:55 +020013720 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013721 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13722 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013723 board_config = ALC268_AUTO;
13724 }
13725
13726 if (board_config == ALC268_AUTO) {
13727 /* automatic parse from the BIOS config */
13728 err = alc268_parse_auto_config(codec);
13729 if (err < 0) {
13730 alc_free(codec);
13731 return err;
13732 } else if (!err) {
13733 printk(KERN_INFO
13734 "hda_codec: Cannot set up configuration "
13735 "from BIOS. Using base mode...\n");
13736 board_config = ALC268_3ST;
13737 }
13738 }
13739
13740 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013741 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013742
Kailang Yanga361d842007-06-05 12:30:55 +020013743 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13744 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013745 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013746
Kailang Yanga361d842007-06-05 12:30:55 +020013747 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13748
Takashi Iwai22971e32009-02-10 11:56:44 +010013749 has_beep = 0;
13750 for (i = 0; i < spec->num_mixers; i++) {
13751 if (spec->mixers[i] == alc268_beep_mixer) {
13752 has_beep = 1;
13753 break;
13754 }
13755 }
13756
13757 if (has_beep) {
13758 err = snd_hda_attach_beep_device(codec, 0x1);
13759 if (err < 0) {
13760 alc_free(codec);
13761 return err;
13762 }
13763 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13764 /* override the amp caps for beep generator */
13765 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013766 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13767 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13768 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13769 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013770 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013771
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013772 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013773 /* check whether NID 0x07 is valid */
13774 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013775 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013776
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013777 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013778 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013779 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013780 if (spec->auto_mic ||
13781 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013782 spec->adc_nids = alc268_adc_nids_alt;
13783 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013784 if (spec->auto_mic)
13785 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013786 if (spec->auto_mic || spec->input_mux->num_items == 1)
13787 add_mixer(spec, alc268_capture_nosrc_mixer);
13788 else
13789 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013790 } else {
13791 spec->adc_nids = alc268_adc_nids;
13792 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013793 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013794 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013795 /* set default input source */
13796 for (i = 0; i < spec->num_adc_nids; i++)
13797 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13798 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013799 i < spec->num_mux_defs ?
13800 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013801 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013802 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013803
13804 spec->vmaster_nid = 0x02;
13805
Kailang Yanga361d842007-06-05 12:30:55 +020013806 codec->patch_ops = alc_patch_ops;
13807 if (board_config == ALC268_AUTO)
13808 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013809
Kailang Yanga361d842007-06-05 12:30:55 +020013810 return 0;
13811}
13812
13813/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013814 * ALC269 channel source setting (2 channel)
13815 */
13816#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13817
13818#define alc269_dac_nids alc260_dac_nids
13819
13820static hda_nid_t alc269_adc_nids[1] = {
13821 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013822 0x08,
13823};
13824
Takashi Iwaie01bf502008-08-21 16:25:07 +020013825static hda_nid_t alc269_capsrc_nids[1] = {
13826 0x23,
13827};
13828
Kailang Yang84898e82010-02-04 14:16:14 +010013829static hda_nid_t alc269vb_adc_nids[1] = {
13830 /* ADC1 */
13831 0x09,
13832};
13833
13834static hda_nid_t alc269vb_capsrc_nids[1] = {
13835 0x22,
13836};
13837
Takashi Iwai66946352010-03-29 17:21:45 +020013838static hda_nid_t alc269_adc_candidates[] = {
13839 0x08, 0x09, 0x07,
13840};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013841
Kailang Yangf6a92242007-12-13 16:52:54 +010013842#define alc269_modes alc260_modes
13843#define alc269_capture_source alc880_lg_lw_capture_source
13844
13845static struct snd_kcontrol_new alc269_base_mixer[] = {
13846 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13847 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13848 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13849 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13853 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13854 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13855 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13857 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13858 { } /* end */
13859};
13860
Kailang Yang60db6b52008-08-26 13:13:00 +020013861static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13862 /* output mixer control */
13863 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13864 {
13865 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13866 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013867 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013868 .info = snd_hda_mixer_amp_switch_info,
13869 .get = snd_hda_mixer_amp_switch_get,
13870 .put = alc268_acer_master_sw_put,
13871 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13872 },
13873 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13874 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13875 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13876 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13877 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13878 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013879 { }
13880};
13881
Tony Vroon64154832008-11-06 15:08:49 +000013882static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13883 /* output mixer control */
13884 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13885 {
13886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13887 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013888 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013889 .info = snd_hda_mixer_amp_switch_info,
13890 .get = snd_hda_mixer_amp_switch_get,
13891 .put = alc268_acer_master_sw_put,
13892 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13893 },
13894 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13895 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13897 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13898 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13899 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13900 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13901 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13902 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013903 { }
13904};
13905
Kailang Yang84898e82010-02-04 14:16:14 +010013906static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013907 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013908 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013909 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013910 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013911 { } /* end */
13912};
13913
Kailang Yang84898e82010-02-04 14:16:14 +010013914static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13915 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13916 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13917 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13919 { } /* end */
13920};
13921
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020013922static struct snd_kcontrol_new alc269_asus_mixer[] = {
13923 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13924 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
13925 { } /* end */
13926};
13927
Kailang Yangf6a92242007-12-13 16:52:54 +010013928/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013929static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13930 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13931 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13932 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13933 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13934 { } /* end */
13935};
13936
13937static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013938 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13939 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013940 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13941 { } /* end */
13942};
13943
Kailang Yang84898e82010-02-04 14:16:14 +010013944static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13945 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13946 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13948 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13949 { } /* end */
13950};
13951
13952static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13953 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13954 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13956 { } /* end */
13957};
13958
Takashi Iwai26f5df22008-11-03 17:39:46 +010013959/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013960#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013961
Kailang Yang60db6b52008-08-26 13:13:00 +020013962static struct hda_verb alc269_quanta_fl1_verbs[] = {
13963 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13964 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13965 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13966 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13967 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13968 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13969 { }
13970};
13971
Tony Vroon64154832008-11-06 15:08:49 +000013972static struct hda_verb alc269_lifebook_verbs[] = {
13973 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13974 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13975 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13977 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13978 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13979 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13980 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13981 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13982 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13983 { }
13984};
13985
Kailang Yang60db6b52008-08-26 13:13:00 +020013986/* toggle speaker-output according to the hp-jack state */
13987static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13988{
13989 unsigned int present;
13990 unsigned char bits;
13991
Wu Fengguang864f92b2009-11-18 12:38:02 +080013992 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013993 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013994 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013995 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013996 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013997 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013998
13999 snd_hda_codec_write(codec, 0x20, 0,
14000 AC_VERB_SET_COEF_INDEX, 0x0c);
14001 snd_hda_codec_write(codec, 0x20, 0,
14002 AC_VERB_SET_PROC_COEF, 0x680);
14003
14004 snd_hda_codec_write(codec, 0x20, 0,
14005 AC_VERB_SET_COEF_INDEX, 0x0c);
14006 snd_hda_codec_write(codec, 0x20, 0,
14007 AC_VERB_SET_PROC_COEF, 0x480);
14008}
14009
Tony Vroon64154832008-11-06 15:08:49 +000014010/* toggle speaker-output according to the hp-jacks state */
14011static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14012{
14013 unsigned int present;
14014 unsigned char bits;
14015
14016 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014017 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014018
14019 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014020 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014021
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014022 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014023 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014024 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014025 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014026 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014027
14028 snd_hda_codec_write(codec, 0x20, 0,
14029 AC_VERB_SET_COEF_INDEX, 0x0c);
14030 snd_hda_codec_write(codec, 0x20, 0,
14031 AC_VERB_SET_PROC_COEF, 0x680);
14032
14033 snd_hda_codec_write(codec, 0x20, 0,
14034 AC_VERB_SET_COEF_INDEX, 0x0c);
14035 snd_hda_codec_write(codec, 0x20, 0,
14036 AC_VERB_SET_PROC_COEF, 0x480);
14037}
14038
Tony Vroon64154832008-11-06 15:08:49 +000014039static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14040{
14041 unsigned int present_laptop;
14042 unsigned int present_dock;
14043
Wu Fengguang864f92b2009-11-18 12:38:02 +080014044 present_laptop = snd_hda_jack_detect(codec, 0x18);
14045 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014046
14047 /* Laptop mic port overrides dock mic port, design decision */
14048 if (present_dock)
14049 snd_hda_codec_write(codec, 0x23, 0,
14050 AC_VERB_SET_CONNECT_SEL, 0x3);
14051 if (present_laptop)
14052 snd_hda_codec_write(codec, 0x23, 0,
14053 AC_VERB_SET_CONNECT_SEL, 0x0);
14054 if (!present_dock && !present_laptop)
14055 snd_hda_codec_write(codec, 0x23, 0,
14056 AC_VERB_SET_CONNECT_SEL, 0x1);
14057}
14058
Kailang Yang60db6b52008-08-26 13:13:00 +020014059static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14060 unsigned int res)
14061{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014062 switch (res >> 26) {
14063 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014064 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014065 break;
14066 case ALC880_MIC_EVENT:
14067 alc_mic_automute(codec);
14068 break;
14069 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014070}
14071
Tony Vroon64154832008-11-06 15:08:49 +000014072static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14073 unsigned int res)
14074{
14075 if ((res >> 26) == ALC880_HP_EVENT)
14076 alc269_lifebook_speaker_automute(codec);
14077 if ((res >> 26) == ALC880_MIC_EVENT)
14078 alc269_lifebook_mic_autoswitch(codec);
14079}
14080
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014081static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14082{
14083 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014084 spec->autocfg.hp_pins[0] = 0x15;
14085 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014086 spec->ext_mic.pin = 0x18;
14087 spec->ext_mic.mux_idx = 0;
14088 spec->int_mic.pin = 0x19;
14089 spec->int_mic.mux_idx = 1;
14090 spec->auto_mic = 1;
14091}
14092
Kailang Yang60db6b52008-08-26 13:13:00 +020014093static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14094{
14095 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014096 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014097}
14098
Tony Vroon64154832008-11-06 15:08:49 +000014099static void alc269_lifebook_init_hook(struct hda_codec *codec)
14100{
14101 alc269_lifebook_speaker_automute(codec);
14102 alc269_lifebook_mic_autoswitch(codec);
14103}
14104
Kailang Yang84898e82010-02-04 14:16:14 +010014105static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14107 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14108 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14111 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14112 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14113 {}
14114};
14115
Kailang Yang84898e82010-02-04 14:16:14 +010014116static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014117 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14118 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14119 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14120 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14121 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14123 {}
14124};
14125
Kailang Yang84898e82010-02-04 14:16:14 +010014126static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14127 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14128 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14129 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14130 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14131 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14132 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14133 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14134 {}
14135};
14136
14137static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14138 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14139 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14140 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14142 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14143 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14144 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14145 {}
14146};
14147
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014148static struct hda_verb alc271_acer_dmic_verbs[] = {
14149 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14150 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14151 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14153 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14154 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14155 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14156 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14157 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14158 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14159 { }
14160};
14161
Kailang Yang60db6b52008-08-26 13:13:00 +020014162/* toggle speaker-output according to the hp-jack state */
14163static void alc269_speaker_automute(struct hda_codec *codec)
14164{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014165 struct alc_spec *spec = codec->spec;
14166 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014167 unsigned int present;
14168 unsigned char bits;
14169
Kailang Yangebb83ee2009-12-17 12:23:00 +010014170 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014171 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014172 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014173 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014174 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014175 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014176}
14177
Kailang Yang60db6b52008-08-26 13:13:00 +020014178/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014179static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014180 unsigned int res)
14181{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014182 switch (res >> 26) {
14183 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014184 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014185 break;
14186 case ALC880_MIC_EVENT:
14187 alc_mic_automute(codec);
14188 break;
14189 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014190}
14191
Kailang Yang226b1ec2010-04-09 11:01:20 +020014192static void alc269_laptop_amic_setup(struct hda_codec *codec)
14193{
14194 struct alc_spec *spec = codec->spec;
14195 spec->autocfg.hp_pins[0] = 0x15;
14196 spec->autocfg.speaker_pins[0] = 0x14;
14197 spec->ext_mic.pin = 0x18;
14198 spec->ext_mic.mux_idx = 0;
14199 spec->int_mic.pin = 0x19;
14200 spec->int_mic.mux_idx = 1;
14201 spec->auto_mic = 1;
14202}
14203
Kailang Yang84898e82010-02-04 14:16:14 +010014204static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014205{
14206 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014207 spec->autocfg.hp_pins[0] = 0x15;
14208 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014209 spec->ext_mic.pin = 0x18;
14210 spec->ext_mic.mux_idx = 0;
14211 spec->int_mic.pin = 0x12;
14212 spec->int_mic.mux_idx = 5;
14213 spec->auto_mic = 1;
14214}
14215
Kailang Yang226b1ec2010-04-09 11:01:20 +020014216static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014217{
14218 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014219 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014220 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014221 spec->ext_mic.pin = 0x18;
14222 spec->ext_mic.mux_idx = 0;
14223 spec->int_mic.pin = 0x19;
14224 spec->int_mic.mux_idx = 1;
14225 spec->auto_mic = 1;
14226}
14227
Kailang Yang226b1ec2010-04-09 11:01:20 +020014228static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14229{
14230 struct alc_spec *spec = codec->spec;
14231 spec->autocfg.hp_pins[0] = 0x21;
14232 spec->autocfg.speaker_pins[0] = 0x14;
14233 spec->ext_mic.pin = 0x18;
14234 spec->ext_mic.mux_idx = 0;
14235 spec->int_mic.pin = 0x12;
14236 spec->int_mic.mux_idx = 6;
14237 spec->auto_mic = 1;
14238}
14239
Kailang Yang84898e82010-02-04 14:16:14 +010014240static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014241{
14242 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014243 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014244}
14245
Kailang Yangf6a92242007-12-13 16:52:54 +010014246/*
14247 * generic initialization of ADC, input mixers and output mixers
14248 */
14249static struct hda_verb alc269_init_verbs[] = {
14250 /*
14251 * Unmute ADC0 and set the default input to mic-in
14252 */
Kailang Yang84898e82010-02-04 14:16:14 +010014253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014254
14255 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014256 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014257 */
14258 /* set vol=0 to output mixers */
14259 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14260 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14261
14262 /* set up input amps for analog loopback */
14263 /* Amp Indices: DAC = 0, mixer = 1 */
14264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14267 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14269 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14270
14271 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14272 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14273 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14275 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14276 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14278
14279 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014281
Kailang Yang84898e82010-02-04 14:16:14 +010014282 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014283 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14284 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014285 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014286
14287 /* set EAPD */
14288 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014289 { }
14290};
14291
14292static struct hda_verb alc269vb_init_verbs[] = {
14293 /*
14294 * Unmute ADC0 and set the default input to mic-in
14295 */
14296 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14297
14298 /*
14299 * Set up output mixers (0x02 - 0x03)
14300 */
14301 /* set vol=0 to output mixers */
14302 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14303 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14304
14305 /* set up input amps for analog loopback */
14306 /* Amp Indices: DAC = 0, mixer = 1 */
14307 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14308 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14309 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14310 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14312 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14313
14314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14315 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14316 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14317 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14320 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14321
14322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14323 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14324
14325 /* FIXME: use Mux-type input source selection */
14326 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14327 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14328 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14329
14330 /* set EAPD */
14331 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014332 { }
14333};
14334
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014335#define alc269_auto_create_multi_out_ctls \
14336 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014337#define alc269_auto_create_input_ctls \
14338 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014339
14340#ifdef CONFIG_SND_HDA_POWER_SAVE
14341#define alc269_loopbacks alc880_loopbacks
14342#endif
14343
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014344/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014345#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14346#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14347#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14348#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14349
Takashi Iwaif03d3112009-03-05 14:18:16 +010014350static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14351 .substreams = 1,
14352 .channels_min = 2,
14353 .channels_max = 8,
14354 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14355 /* NID is set in alc_build_pcms */
14356 .ops = {
14357 .open = alc880_playback_pcm_open,
14358 .prepare = alc880_playback_pcm_prepare,
14359 .cleanup = alc880_playback_pcm_cleanup
14360 },
14361};
14362
14363static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14364 .substreams = 1,
14365 .channels_min = 2,
14366 .channels_max = 2,
14367 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14368 /* NID is set in alc_build_pcms */
14369};
14370
Takashi Iwaiad358792010-03-30 18:00:59 +020014371#ifdef CONFIG_SND_HDA_POWER_SAVE
14372static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14373{
14374 switch (codec->subsystem_id) {
14375 case 0x103c1586:
14376 return 1;
14377 }
14378 return 0;
14379}
14380
14381static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14382{
14383 /* update mute-LED according to the speaker mute state */
14384 if (nid == 0x01 || nid == 0x14) {
14385 int pinval;
14386 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14387 HDA_AMP_MUTE)
14388 pinval = 0x24;
14389 else
14390 pinval = 0x20;
14391 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014392 snd_hda_codec_update_cache(codec, 0x19, 0,
14393 AC_VERB_SET_PIN_WIDGET_CONTROL,
14394 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014395 }
14396 return alc_check_power_status(codec, nid);
14397}
14398#endif /* CONFIG_SND_HDA_POWER_SAVE */
14399
Takashi Iwai840b64c2010-07-13 22:49:01 +020014400static int alc275_setup_dual_adc(struct hda_codec *codec)
14401{
14402 struct alc_spec *spec = codec->spec;
14403
14404 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14405 return 0;
14406 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14407 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14408 if (spec->ext_mic.pin <= 0x12) {
14409 spec->private_adc_nids[0] = 0x08;
14410 spec->private_adc_nids[1] = 0x11;
14411 spec->private_capsrc_nids[0] = 0x23;
14412 spec->private_capsrc_nids[1] = 0x22;
14413 } else {
14414 spec->private_adc_nids[0] = 0x11;
14415 spec->private_adc_nids[1] = 0x08;
14416 spec->private_capsrc_nids[0] = 0x22;
14417 spec->private_capsrc_nids[1] = 0x23;
14418 }
14419 spec->adc_nids = spec->private_adc_nids;
14420 spec->capsrc_nids = spec->private_capsrc_nids;
14421 spec->num_adc_nids = 2;
14422 spec->dual_adc_switch = 1;
14423 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14424 spec->adc_nids[0], spec->adc_nids[1]);
14425 return 1;
14426 }
14427 return 0;
14428}
14429
Kailang Yangf6a92242007-12-13 16:52:54 +010014430/*
14431 * BIOS auto configuration
14432 */
14433static int alc269_parse_auto_config(struct hda_codec *codec)
14434{
14435 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014436 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014437 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14438
14439 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14440 alc269_ignore);
14441 if (err < 0)
14442 return err;
14443
14444 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14445 if (err < 0)
14446 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014447 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014448 if (err < 0)
14449 return err;
14450
14451 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14452
Takashi Iwai757899a2010-07-30 10:48:14 +020014453 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014454
Takashi Iwai603c4012008-07-30 15:01:44 +020014455 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014456 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014457
Kailang Yang84898e82010-02-04 14:16:14 +010014458 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14459 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014460 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014461 } else {
14462 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014463 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014464 }
14465
Kailang Yangf6a92242007-12-13 16:52:54 +010014466 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014467 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014468
14469 if (!alc275_setup_dual_adc(codec))
14470 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14471 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014472
Takashi Iwaie01bf502008-08-21 16:25:07 +020014473 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014474 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014475 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14476 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014477
14478 err = alc_auto_add_mic_boost(codec);
14479 if (err < 0)
14480 return err;
14481
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014482 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014483 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014484
Kailang Yangf6a92242007-12-13 16:52:54 +010014485 return 1;
14486}
14487
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014488#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14489#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014490#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14491
14492
14493/* init callback for auto-configuration model -- overriding the default init */
14494static void alc269_auto_init(struct hda_codec *codec)
14495{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014496 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014497 alc269_auto_init_multi_out(codec);
14498 alc269_auto_init_hp_out(codec);
14499 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014500 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014501 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014502 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014503}
14504
Takashi Iwaiff818c22010-04-12 08:59:25 +020014505enum {
14506 ALC269_FIXUP_SONY_VAIO,
14507};
14508
Takashi Iwaiff818c22010-04-12 08:59:25 +020014509static const struct alc_fixup alc269_fixups[] = {
14510 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014511 .verbs = (const struct hda_verb[]) {
14512 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14513 {}
14514 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014515 },
14516};
14517
14518static struct snd_pci_quirk alc269_fixup_tbl[] = {
14519 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014520 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014521 {}
14522};
14523
14524
Kailang Yangf6a92242007-12-13 16:52:54 +010014525/*
14526 * configuration and preset
14527 */
14528static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014529 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014530 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014531 [ALC269_AMIC] = "laptop-amic",
14532 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014533 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014534 [ALC269_LIFEBOOK] = "lifebook",
14535 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014536};
14537
14538static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014539 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014540 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014541 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014542 ALC269_AMIC),
14543 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14544 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14545 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14546 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14547 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14548 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14549 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14550 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14551 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14552 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14553 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14554 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14555 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14556 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14557 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14558 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14559 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14560 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14561 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14562 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14563 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14564 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14565 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14566 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14567 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14568 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14569 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14570 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14571 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14572 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14573 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14574 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14575 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14576 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14577 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14578 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014579 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014580 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014581 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014582 ALC269_DMIC),
14583 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14584 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014585 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014586 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014587 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14588 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14589 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14590 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14591 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14592 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014593 {}
14594};
14595
14596static struct alc_config_preset alc269_presets[] = {
14597 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014598 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014599 .init_verbs = { alc269_init_verbs },
14600 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14601 .dac_nids = alc269_dac_nids,
14602 .hp_nid = 0x03,
14603 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14604 .channel_mode = alc269_modes,
14605 .input_mux = &alc269_capture_source,
14606 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014607 [ALC269_QUANTA_FL1] = {
14608 .mixers = { alc269_quanta_fl1_mixer },
14609 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14610 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14611 .dac_nids = alc269_dac_nids,
14612 .hp_nid = 0x03,
14613 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14614 .channel_mode = alc269_modes,
14615 .input_mux = &alc269_capture_source,
14616 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014617 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014618 .init_hook = alc269_quanta_fl1_init_hook,
14619 },
Kailang Yang84898e82010-02-04 14:16:14 +010014620 [ALC269_AMIC] = {
14621 .mixers = { alc269_laptop_mixer },
14622 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014623 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014624 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014625 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14626 .dac_nids = alc269_dac_nids,
14627 .hp_nid = 0x03,
14628 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14629 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014630 .unsol_event = alc269_laptop_unsol_event,
14631 .setup = alc269_laptop_amic_setup,
14632 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014633 },
Kailang Yang84898e82010-02-04 14:16:14 +010014634 [ALC269_DMIC] = {
14635 .mixers = { alc269_laptop_mixer },
14636 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014637 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014638 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014639 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14640 .dac_nids = alc269_dac_nids,
14641 .hp_nid = 0x03,
14642 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14643 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014644 .unsol_event = alc269_laptop_unsol_event,
14645 .setup = alc269_laptop_dmic_setup,
14646 .init_hook = alc269_laptop_inithook,
14647 },
14648 [ALC269VB_AMIC] = {
14649 .mixers = { alc269vb_laptop_mixer },
14650 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14651 .init_verbs = { alc269vb_init_verbs,
14652 alc269vb_laptop_amic_init_verbs },
14653 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14654 .dac_nids = alc269_dac_nids,
14655 .hp_nid = 0x03,
14656 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14657 .channel_mode = alc269_modes,
14658 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014659 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014660 .init_hook = alc269_laptop_inithook,
14661 },
14662 [ALC269VB_DMIC] = {
14663 .mixers = { alc269vb_laptop_mixer },
14664 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14665 .init_verbs = { alc269vb_init_verbs,
14666 alc269vb_laptop_dmic_init_verbs },
14667 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14668 .dac_nids = alc269_dac_nids,
14669 .hp_nid = 0x03,
14670 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14671 .channel_mode = alc269_modes,
14672 .unsol_event = alc269_laptop_unsol_event,
14673 .setup = alc269vb_laptop_dmic_setup,
14674 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014675 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014676 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014677 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014678 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014679 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014680 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014681 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14682 .dac_nids = alc269_dac_nids,
14683 .hp_nid = 0x03,
14684 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14685 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014686 .unsol_event = alc269_laptop_unsol_event,
14687 .setup = alc269_laptop_dmic_setup,
14688 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014689 },
Tony Vroon64154832008-11-06 15:08:49 +000014690 [ALC269_LIFEBOOK] = {
14691 .mixers = { alc269_lifebook_mixer },
14692 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14693 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14694 .dac_nids = alc269_dac_nids,
14695 .hp_nid = 0x03,
14696 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14697 .channel_mode = alc269_modes,
14698 .input_mux = &alc269_capture_source,
14699 .unsol_event = alc269_lifebook_unsol_event,
14700 .init_hook = alc269_lifebook_init_hook,
14701 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014702 [ALC271_ACER] = {
14703 .mixers = { alc269_asus_mixer },
14704 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14705 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14706 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14707 .dac_nids = alc269_dac_nids,
14708 .adc_nids = alc262_dmic_adc_nids,
14709 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14710 .capsrc_nids = alc262_dmic_capsrc_nids,
14711 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14712 .channel_mode = alc269_modes,
14713 .input_mux = &alc269_capture_source,
14714 .dig_out_nid = ALC880_DIGOUT_NID,
14715 .unsol_event = alc_sku_unsol_event,
14716 .setup = alc269vb_laptop_dmic_setup,
14717 .init_hook = alc_inithook,
14718 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014719};
14720
14721static int patch_alc269(struct hda_codec *codec)
14722{
14723 struct alc_spec *spec;
14724 int board_config;
14725 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014726 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014727
14728 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14729 if (spec == NULL)
14730 return -ENOMEM;
14731
14732 codec->spec = spec;
14733
Kailang Yangda00c242010-03-19 11:23:45 +010014734 alc_auto_parse_customize_define(codec);
14735
Kailang Yang274693f2009-12-03 10:07:50 +010014736 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014737 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14738 spec->cdefine.platform_type == 1)
14739 alc_codec_rename(codec, "ALC271X");
14740 else
14741 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014742 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014743 } else
14744 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014745
Kailang Yangf6a92242007-12-13 16:52:54 +010014746 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14747 alc269_models,
14748 alc269_cfg_tbl);
14749
14750 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014751 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14752 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014753 board_config = ALC269_AUTO;
14754 }
14755
Takashi Iwaiff818c22010-04-12 08:59:25 +020014756 if (board_config == ALC269_AUTO)
14757 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14758
Kailang Yangf6a92242007-12-13 16:52:54 +010014759 if (board_config == ALC269_AUTO) {
14760 /* automatic parse from the BIOS config */
14761 err = alc269_parse_auto_config(codec);
14762 if (err < 0) {
14763 alc_free(codec);
14764 return err;
14765 } else if (!err) {
14766 printk(KERN_INFO
14767 "hda_codec: Cannot set up configuration "
14768 "from BIOS. Using base mode...\n");
14769 board_config = ALC269_BASIC;
14770 }
14771 }
14772
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014773 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014774 err = snd_hda_attach_beep_device(codec, 0x1);
14775 if (err < 0) {
14776 alc_free(codec);
14777 return err;
14778 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014779 }
14780
Kailang Yangf6a92242007-12-13 16:52:54 +010014781 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014782 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014783
Kailang Yang84898e82010-02-04 14:16:14 +010014784 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014785 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14786 * fix the sample rate of analog I/O to 44.1kHz
14787 */
14788 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14789 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014790 } else if (spec->dual_adc_switch) {
14791 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14792 /* switch ADC dynamically */
14793 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014794 } else {
14795 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14796 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14797 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014798 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14799 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14800
Takashi Iwai66946352010-03-29 17:21:45 +020014801 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14802 if (!is_alc269vb) {
14803 spec->adc_nids = alc269_adc_nids;
14804 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14805 spec->capsrc_nids = alc269_capsrc_nids;
14806 } else {
14807 spec->adc_nids = alc269vb_adc_nids;
14808 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14809 spec->capsrc_nids = alc269vb_capsrc_nids;
14810 }
Kailang Yang84898e82010-02-04 14:16:14 +010014811 }
14812
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014813 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014814 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014815 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014816 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014817
Takashi Iwaiff818c22010-04-12 08:59:25 +020014818 if (board_config == ALC269_AUTO)
14819 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14820
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014821 spec->vmaster_nid = 0x02;
14822
Kailang Yangf6a92242007-12-13 16:52:54 +010014823 codec->patch_ops = alc_patch_ops;
14824 if (board_config == ALC269_AUTO)
14825 spec->init_hook = alc269_auto_init;
14826#ifdef CONFIG_SND_HDA_POWER_SAVE
14827 if (!spec->loopback.amplist)
14828 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014829 if (alc269_mic2_for_mute_led(codec))
14830 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014831#endif
14832
14833 return 0;
14834}
14835
14836/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014837 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14838 */
14839
14840/*
14841 * set the path ways for 2 channel output
14842 * need to set the codec line out and mic 1 pin widgets to inputs
14843 */
14844static struct hda_verb alc861_threestack_ch2_init[] = {
14845 /* set pin widget 1Ah (line in) for input */
14846 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014847 /* set pin widget 18h (mic1/2) for input, for mic also enable
14848 * the vref
14849 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014850 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14851
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014852 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14853#if 0
14854 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14855 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14856#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014857 { } /* end */
14858};
14859/*
14860 * 6ch mode
14861 * need to set the codec line out and mic 1 pin widgets to outputs
14862 */
14863static struct hda_verb alc861_threestack_ch6_init[] = {
14864 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14865 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14866 /* set pin widget 18h (mic1) for output (CLFE)*/
14867 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14868
14869 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014870 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014871
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014872 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14873#if 0
14874 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14875 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14876#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014877 { } /* end */
14878};
14879
14880static struct hda_channel_mode alc861_threestack_modes[2] = {
14881 { 2, alc861_threestack_ch2_init },
14882 { 6, alc861_threestack_ch6_init },
14883};
Takashi Iwai22309c32006-08-09 16:57:28 +020014884/* Set mic1 as input and unmute the mixer */
14885static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14886 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14887 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14888 { } /* end */
14889};
14890/* Set mic1 as output and mute mixer */
14891static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14892 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14893 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14894 { } /* end */
14895};
14896
14897static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14898 { 2, alc861_uniwill_m31_ch2_init },
14899 { 4, alc861_uniwill_m31_ch4_init },
14900};
Kailang Yangdf694da2005-12-05 19:42:22 +010014901
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014902/* Set mic1 and line-in as input and unmute the mixer */
14903static struct hda_verb alc861_asus_ch2_init[] = {
14904 /* set pin widget 1Ah (line in) for input */
14905 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014906 /* set pin widget 18h (mic1/2) for input, for mic also enable
14907 * the vref
14908 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014909 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14910
14911 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14912#if 0
14913 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14914 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14915#endif
14916 { } /* end */
14917};
14918/* Set mic1 nad line-in as output and mute mixer */
14919static struct hda_verb alc861_asus_ch6_init[] = {
14920 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14921 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14922 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14923 /* set pin widget 18h (mic1) for output (CLFE)*/
14924 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14925 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14926 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14927 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14928
14929 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14930#if 0
14931 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14932 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14933#endif
14934 { } /* end */
14935};
14936
14937static struct hda_channel_mode alc861_asus_modes[2] = {
14938 { 2, alc861_asus_ch2_init },
14939 { 6, alc861_asus_ch6_init },
14940};
14941
Kailang Yangdf694da2005-12-05 19:42:22 +010014942/* patch-ALC861 */
14943
14944static struct snd_kcontrol_new alc861_base_mixer[] = {
14945 /* output mixer control */
14946 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14947 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14948 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14949 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14950 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14951
14952 /*Input mixer control */
14953 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14954 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14955 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14956 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14957 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14958 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14960 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14961 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014963
Kailang Yangdf694da2005-12-05 19:42:22 +010014964 { } /* end */
14965};
14966
14967static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14968 /* output mixer control */
14969 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14970 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14971 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14972 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14973 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14974
14975 /* Input mixer control */
14976 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14977 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14978 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14979 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14980 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14981 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14983 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14984 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14985 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014986
Kailang Yangdf694da2005-12-05 19:42:22 +010014987 {
14988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14989 .name = "Channel Mode",
14990 .info = alc_ch_mode_info,
14991 .get = alc_ch_mode_get,
14992 .put = alc_ch_mode_put,
14993 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14994 },
14995 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014996};
14997
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014998static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014999 /* output mixer control */
15000 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15001 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15002 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015003
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015004 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015005};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015006
Takashi Iwai22309c32006-08-09 16:57:28 +020015007static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15008 /* output mixer control */
15009 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15010 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15011 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15012 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15013 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15014
15015 /* Input mixer control */
15016 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15017 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15018 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15019 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15020 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15021 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15023 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15024 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15025 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015026
Takashi Iwai22309c32006-08-09 16:57:28 +020015027 {
15028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15029 .name = "Channel Mode",
15030 .info = alc_ch_mode_info,
15031 .get = alc_ch_mode_get,
15032 .put = alc_ch_mode_put,
15033 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15034 },
15035 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015036};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015037
15038static struct snd_kcontrol_new alc861_asus_mixer[] = {
15039 /* output mixer control */
15040 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15041 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15042 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15043 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15044 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15045
15046 /* Input mixer control */
15047 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15048 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15049 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15050 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15051 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15052 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15053 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15054 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15055 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15057
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015058 {
15059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15060 .name = "Channel Mode",
15061 .info = alc_ch_mode_info,
15062 .get = alc_ch_mode_get,
15063 .put = alc_ch_mode_put,
15064 .private_value = ARRAY_SIZE(alc861_asus_modes),
15065 },
15066 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015067};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015068
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015069/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015070static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015071 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15072 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015073 { }
15074};
15075
Kailang Yangdf694da2005-12-05 19:42:22 +010015076/*
15077 * generic initialization of ADC, input mixers and output mixers
15078 */
15079static struct hda_verb alc861_base_init_verbs[] = {
15080 /*
15081 * Unmute ADC0 and set the default input to mic-in
15082 */
15083 /* port-A for surround (rear panel) */
15084 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15085 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15086 /* port-B for mic-in (rear panel) with vref */
15087 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15088 /* port-C for line-in (rear panel) */
15089 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15090 /* port-D for Front */
15091 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15092 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15093 /* port-E for HP out (front panel) */
15094 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15095 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015096 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015097 /* port-F for mic-in (front panel) with vref */
15098 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15099 /* port-G for CLFE (rear panel) */
15100 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15101 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15102 /* port-H for side (rear panel) */
15103 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15104 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15105 /* CD-in */
15106 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15107 /* route front mic to ADC1*/
15108 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15109 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015110
Kailang Yangdf694da2005-12-05 19:42:22 +010015111 /* Unmute DAC0~3 & spdif out*/
15112 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15113 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15114 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15115 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15116 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015117
Kailang Yangdf694da2005-12-05 19:42:22 +010015118 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15119 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15120 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15121 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15122 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015123
Kailang Yangdf694da2005-12-05 19:42:22 +010015124 /* Unmute Stereo Mixer 15 */
15125 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15127 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015128 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015129
15130 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15131 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15132 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15133 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15134 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15135 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15136 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15137 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015138 /* hp used DAC 3 (Front) */
15139 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015140 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15141
15142 { }
15143};
15144
15145static struct hda_verb alc861_threestack_init_verbs[] = {
15146 /*
15147 * Unmute ADC0 and set the default input to mic-in
15148 */
15149 /* port-A for surround (rear panel) */
15150 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15151 /* port-B for mic-in (rear panel) with vref */
15152 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15153 /* port-C for line-in (rear panel) */
15154 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15155 /* port-D for Front */
15156 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15157 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15158 /* port-E for HP out (front panel) */
15159 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15160 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015161 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015162 /* port-F for mic-in (front panel) with vref */
15163 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15164 /* port-G for CLFE (rear panel) */
15165 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15166 /* port-H for side (rear panel) */
15167 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15168 /* CD-in */
15169 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15170 /* route front mic to ADC1*/
15171 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15172 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15173 /* Unmute DAC0~3 & spdif out*/
15174 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15175 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15176 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15177 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15178 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015179
Kailang Yangdf694da2005-12-05 19:42:22 +010015180 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15181 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15182 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15183 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15184 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015185
Kailang Yangdf694da2005-12-05 19:42:22 +010015186 /* Unmute Stereo Mixer 15 */
15187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15188 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015191
15192 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15193 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15194 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15195 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15196 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15197 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15199 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015200 /* hp used DAC 3 (Front) */
15201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015202 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15203 { }
15204};
Takashi Iwai22309c32006-08-09 16:57:28 +020015205
15206static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15207 /*
15208 * Unmute ADC0 and set the default input to mic-in
15209 */
15210 /* port-A for surround (rear panel) */
15211 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15212 /* port-B for mic-in (rear panel) with vref */
15213 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15214 /* port-C for line-in (rear panel) */
15215 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15216 /* port-D for Front */
15217 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15218 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15219 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015220 /* this has to be set to VREF80 */
15221 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015222 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015223 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015224 /* port-F for mic-in (front panel) with vref */
15225 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15226 /* port-G for CLFE (rear panel) */
15227 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15228 /* port-H for side (rear panel) */
15229 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15230 /* CD-in */
15231 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15232 /* route front mic to ADC1*/
15233 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15234 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15235 /* Unmute DAC0~3 & spdif out*/
15236 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15237 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15238 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15239 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15240 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015241
Takashi Iwai22309c32006-08-09 16:57:28 +020015242 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15243 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15244 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15245 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15246 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015247
Takashi Iwai22309c32006-08-09 16:57:28 +020015248 /* Unmute Stereo Mixer 15 */
15249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15250 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015252 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015253
15254 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15255 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15256 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15257 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15259 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15260 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015262 /* hp used DAC 3 (Front) */
15263 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15265 { }
15266};
15267
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015268static struct hda_verb alc861_asus_init_verbs[] = {
15269 /*
15270 * Unmute ADC0 and set the default input to mic-in
15271 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015272 /* port-A for surround (rear panel)
15273 * according to codec#0 this is the HP jack
15274 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015275 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15276 /* route front PCM to HP */
15277 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15278 /* port-B for mic-in (rear panel) with vref */
15279 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15280 /* port-C for line-in (rear panel) */
15281 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15282 /* port-D for Front */
15283 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15284 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15285 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015286 /* this has to be set to VREF80 */
15287 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015288 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015289 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015290 /* port-F for mic-in (front panel) with vref */
15291 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15292 /* port-G for CLFE (rear panel) */
15293 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15294 /* port-H for side (rear panel) */
15295 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15296 /* CD-in */
15297 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15298 /* route front mic to ADC1*/
15299 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15300 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15301 /* Unmute DAC0~3 & spdif out*/
15302 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15303 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15304 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15305 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15306 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15307 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15308 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15309 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15310 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15311 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015312
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015313 /* Unmute Stereo Mixer 15 */
15314 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15315 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15316 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015317 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015318
15319 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15320 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15321 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15322 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15323 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15324 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15325 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15326 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015327 /* hp used DAC 3 (Front) */
15328 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015329 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15330 { }
15331};
15332
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015333/* additional init verbs for ASUS laptops */
15334static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15335 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15336 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15337 { }
15338};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015339
Kailang Yangdf694da2005-12-05 19:42:22 +010015340/*
15341 * generic initialization of ADC, input mixers and output mixers
15342 */
15343static struct hda_verb alc861_auto_init_verbs[] = {
15344 /*
15345 * Unmute ADC0 and set the default input to mic-in
15346 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015347 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015349
Kailang Yangdf694da2005-12-05 19:42:22 +010015350 /* Unmute DAC0~3 & spdif out*/
15351 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15352 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15354 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015356
Kailang Yangdf694da2005-12-05 19:42:22 +010015357 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15358 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15359 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15360 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15361 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015362
Kailang Yangdf694da2005-12-05 19:42:22 +010015363 /* Unmute Stereo Mixer 15 */
15364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15366 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15368
Takashi Iwai1c209302009-07-22 15:17:45 +020015369 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15370 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15371 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015377
15378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015380 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15381 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015382 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15383 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15385 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015386
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015387 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015388
15389 { }
15390};
15391
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015392static struct hda_verb alc861_toshiba_init_verbs[] = {
15393 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015394
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015395 { }
15396};
15397
15398/* toggle speaker-output according to the hp-jack state */
15399static void alc861_toshiba_automute(struct hda_codec *codec)
15400{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015401 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015402
Takashi Iwai47fd8302007-08-10 17:11:07 +020015403 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15404 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15405 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15406 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015407}
15408
15409static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15410 unsigned int res)
15411{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015412 if ((res >> 26) == ALC880_HP_EVENT)
15413 alc861_toshiba_automute(codec);
15414}
15415
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015416/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015417#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15418#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15419#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15420#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15421
15422
15423#define ALC861_DIGOUT_NID 0x07
15424
15425static struct hda_channel_mode alc861_8ch_modes[1] = {
15426 { 8, NULL }
15427};
15428
15429static hda_nid_t alc861_dac_nids[4] = {
15430 /* front, surround, clfe, side */
15431 0x03, 0x06, 0x05, 0x04
15432};
15433
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015434static hda_nid_t alc660_dac_nids[3] = {
15435 /* front, clfe, surround */
15436 0x03, 0x05, 0x06
15437};
15438
Kailang Yangdf694da2005-12-05 19:42:22 +010015439static hda_nid_t alc861_adc_nids[1] = {
15440 /* ADC0-2 */
15441 0x08,
15442};
15443
15444static struct hda_input_mux alc861_capture_source = {
15445 .num_items = 5,
15446 .items = {
15447 { "Mic", 0x0 },
15448 { "Front Mic", 0x3 },
15449 { "Line", 0x1 },
15450 { "CD", 0x4 },
15451 { "Mixer", 0x5 },
15452 },
15453};
15454
Takashi Iwai1c209302009-07-22 15:17:45 +020015455static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15456{
15457 struct alc_spec *spec = codec->spec;
15458 hda_nid_t mix, srcs[5];
15459 int i, j, num;
15460
15461 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15462 return 0;
15463 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15464 if (num < 0)
15465 return 0;
15466 for (i = 0; i < num; i++) {
15467 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015468 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015469 if (type != AC_WID_AUD_OUT)
15470 continue;
15471 for (j = 0; j < spec->multiout.num_dacs; j++)
15472 if (spec->multiout.dac_nids[j] == srcs[i])
15473 break;
15474 if (j >= spec->multiout.num_dacs)
15475 return srcs[i];
15476 }
15477 return 0;
15478}
15479
Kailang Yangdf694da2005-12-05 19:42:22 +010015480/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015481static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015482 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015483{
Takashi Iwai1c209302009-07-22 15:17:45 +020015484 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015485 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015486 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015487
15488 spec->multiout.dac_nids = spec->private_dac_nids;
15489 for (i = 0; i < cfg->line_outs; i++) {
15490 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015491 dac = alc861_look_for_dac(codec, nid);
15492 if (!dac)
15493 continue;
15494 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015495 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015496 return 0;
15497}
15498
Takashi Iwai1c209302009-07-22 15:17:45 +020015499static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15500 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015501{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015502 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015503 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15504}
15505
15506/* add playback controls from the parsed DAC table */
15507static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15508 const struct auto_pin_cfg *cfg)
15509{
15510 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015511 static const char *chname[4] = {
15512 "Front", "Surround", NULL /*CLFE*/, "Side"
15513 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015514 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015515 int i, err;
15516
15517 if (cfg->line_outs == 1) {
15518 const char *pfx = NULL;
15519 if (!cfg->hp_outs)
15520 pfx = "Master";
15521 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15522 pfx = "Speaker";
15523 if (pfx) {
15524 nid = spec->multiout.dac_nids[0];
15525 return alc861_create_out_sw(codec, pfx, nid, 3);
15526 }
15527 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015528
15529 for (i = 0; i < cfg->line_outs; i++) {
15530 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015531 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015532 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015533 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015534 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015535 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015536 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015537 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015538 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015539 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015540 return err;
15541 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015542 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015543 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015544 return err;
15545 }
15546 }
15547 return 0;
15548}
15549
Takashi Iwai1c209302009-07-22 15:17:45 +020015550static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015551{
Takashi Iwai1c209302009-07-22 15:17:45 +020015552 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015553 int err;
15554 hda_nid_t nid;
15555
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015556 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015557 return 0;
15558
15559 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015560 nid = alc861_look_for_dac(codec, pin);
15561 if (nid) {
15562 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15563 if (err < 0)
15564 return err;
15565 spec->multiout.hp_nid = nid;
15566 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015567 }
15568 return 0;
15569}
15570
15571/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015572static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015573 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015574{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015575 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015576}
15577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015578static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15579 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015580 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015581{
Takashi Iwai1c209302009-07-22 15:17:45 +020015582 hda_nid_t mix, srcs[5];
15583 int i, num;
15584
Jacek Luczak564c5be2008-05-03 18:41:23 +020015585 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15586 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015587 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015588 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015589 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15590 return;
15591 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15592 if (num < 0)
15593 return;
15594 for (i = 0; i < num; i++) {
15595 unsigned int mute;
15596 if (srcs[i] == dac || srcs[i] == 0x15)
15597 mute = AMP_IN_UNMUTE(i);
15598 else
15599 mute = AMP_IN_MUTE(i);
15600 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15601 mute);
15602 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015603}
15604
15605static void alc861_auto_init_multi_out(struct hda_codec *codec)
15606{
15607 struct alc_spec *spec = codec->spec;
15608 int i;
15609
15610 for (i = 0; i < spec->autocfg.line_outs; i++) {
15611 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015612 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015613 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015614 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015615 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015616 }
15617}
15618
15619static void alc861_auto_init_hp_out(struct hda_codec *codec)
15620{
15621 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015622
Takashi Iwai15870f02009-10-05 08:25:13 +020015623 if (spec->autocfg.hp_outs)
15624 alc861_auto_set_output_and_unmute(codec,
15625 spec->autocfg.hp_pins[0],
15626 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015627 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015628 if (spec->autocfg.speaker_outs)
15629 alc861_auto_set_output_and_unmute(codec,
15630 spec->autocfg.speaker_pins[0],
15631 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015632 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015633}
15634
15635static void alc861_auto_init_analog_input(struct hda_codec *codec)
15636{
15637 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015638 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015639 int i;
15640
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015641 for (i = 0; i < cfg->num_inputs; i++) {
15642 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015643 if (nid >= 0x0c && nid <= 0x11)
15644 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015645 }
15646}
15647
15648/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015649/* return 1 if successful, 0 if the proper config is not found,
15650 * or a negative error code
15651 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015652static int alc861_parse_auto_config(struct hda_codec *codec)
15653{
15654 struct alc_spec *spec = codec->spec;
15655 int err;
15656 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15657
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015658 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15659 alc861_ignore);
15660 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015661 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015662 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015663 return 0; /* can't find valid BIOS pin config */
15664
Takashi Iwai1c209302009-07-22 15:17:45 +020015665 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015666 if (err < 0)
15667 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015668 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015669 if (err < 0)
15670 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015671 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015672 if (err < 0)
15673 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015674 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015675 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015676 return err;
15677
15678 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15679
Takashi Iwai757899a2010-07-30 10:48:14 +020015680 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015681
Takashi Iwai603c4012008-07-30 15:01:44 +020015682 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015683 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015684
Takashi Iwaid88897e2008-10-31 15:01:37 +010015685 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015686
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015687 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015688 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015689
15690 spec->adc_nids = alc861_adc_nids;
15691 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015692 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015693
Kailang Yang6227cdc2010-02-25 08:36:52 +010015694 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015695
Kailang Yangdf694da2005-12-05 19:42:22 +010015696 return 1;
15697}
15698
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015699/* additional initialization for auto-configuration model */
15700static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015701{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015702 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015703 alc861_auto_init_multi_out(codec);
15704 alc861_auto_init_hp_out(codec);
15705 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015706 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015707 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015708 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015709}
15710
Takashi Iwaicb53c622007-08-10 17:21:45 +020015711#ifdef CONFIG_SND_HDA_POWER_SAVE
15712static struct hda_amp_list alc861_loopbacks[] = {
15713 { 0x15, HDA_INPUT, 0 },
15714 { 0x15, HDA_INPUT, 1 },
15715 { 0x15, HDA_INPUT, 2 },
15716 { 0x15, HDA_INPUT, 3 },
15717 { } /* end */
15718};
15719#endif
15720
Kailang Yangdf694da2005-12-05 19:42:22 +010015721
15722/*
15723 * configuration and preset
15724 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015725static const char *alc861_models[ALC861_MODEL_LAST] = {
15726 [ALC861_3ST] = "3stack",
15727 [ALC660_3ST] = "3stack-660",
15728 [ALC861_3ST_DIG] = "3stack-dig",
15729 [ALC861_6ST_DIG] = "6stack-dig",
15730 [ALC861_UNIWILL_M31] = "uniwill-m31",
15731 [ALC861_TOSHIBA] = "toshiba",
15732 [ALC861_ASUS] = "asus",
15733 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15734 [ALC861_AUTO] = "auto",
15735};
15736
15737static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015738 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015739 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15740 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15741 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015742 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015743 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015744 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015745 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15746 * Any other models that need this preset?
15747 */
15748 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015749 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15750 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015751 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15752 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15753 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15754 /* FIXME: the below seems conflict */
15755 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15756 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15757 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015758 {}
15759};
15760
15761static struct alc_config_preset alc861_presets[] = {
15762 [ALC861_3ST] = {
15763 .mixers = { alc861_3ST_mixer },
15764 .init_verbs = { alc861_threestack_init_verbs },
15765 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15766 .dac_nids = alc861_dac_nids,
15767 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15768 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015769 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015770 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15771 .adc_nids = alc861_adc_nids,
15772 .input_mux = &alc861_capture_source,
15773 },
15774 [ALC861_3ST_DIG] = {
15775 .mixers = { alc861_base_mixer },
15776 .init_verbs = { alc861_threestack_init_verbs },
15777 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15778 .dac_nids = alc861_dac_nids,
15779 .dig_out_nid = ALC861_DIGOUT_NID,
15780 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15781 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015782 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015783 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15784 .adc_nids = alc861_adc_nids,
15785 .input_mux = &alc861_capture_source,
15786 },
15787 [ALC861_6ST_DIG] = {
15788 .mixers = { alc861_base_mixer },
15789 .init_verbs = { alc861_base_init_verbs },
15790 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15791 .dac_nids = alc861_dac_nids,
15792 .dig_out_nid = ALC861_DIGOUT_NID,
15793 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15794 .channel_mode = alc861_8ch_modes,
15795 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15796 .adc_nids = alc861_adc_nids,
15797 .input_mux = &alc861_capture_source,
15798 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015799 [ALC660_3ST] = {
15800 .mixers = { alc861_3ST_mixer },
15801 .init_verbs = { alc861_threestack_init_verbs },
15802 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15803 .dac_nids = alc660_dac_nids,
15804 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15805 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015806 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015807 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15808 .adc_nids = alc861_adc_nids,
15809 .input_mux = &alc861_capture_source,
15810 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015811 [ALC861_UNIWILL_M31] = {
15812 .mixers = { alc861_uniwill_m31_mixer },
15813 .init_verbs = { alc861_uniwill_m31_init_verbs },
15814 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15815 .dac_nids = alc861_dac_nids,
15816 .dig_out_nid = ALC861_DIGOUT_NID,
15817 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15818 .channel_mode = alc861_uniwill_m31_modes,
15819 .need_dac_fix = 1,
15820 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15821 .adc_nids = alc861_adc_nids,
15822 .input_mux = &alc861_capture_source,
15823 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015824 [ALC861_TOSHIBA] = {
15825 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015826 .init_verbs = { alc861_base_init_verbs,
15827 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015828 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15829 .dac_nids = alc861_dac_nids,
15830 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15831 .channel_mode = alc883_3ST_2ch_modes,
15832 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15833 .adc_nids = alc861_adc_nids,
15834 .input_mux = &alc861_capture_source,
15835 .unsol_event = alc861_toshiba_unsol_event,
15836 .init_hook = alc861_toshiba_automute,
15837 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015838 [ALC861_ASUS] = {
15839 .mixers = { alc861_asus_mixer },
15840 .init_verbs = { alc861_asus_init_verbs },
15841 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15842 .dac_nids = alc861_dac_nids,
15843 .dig_out_nid = ALC861_DIGOUT_NID,
15844 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15845 .channel_mode = alc861_asus_modes,
15846 .need_dac_fix = 1,
15847 .hp_nid = 0x06,
15848 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15849 .adc_nids = alc861_adc_nids,
15850 .input_mux = &alc861_capture_source,
15851 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015852 [ALC861_ASUS_LAPTOP] = {
15853 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15854 .init_verbs = { alc861_asus_init_verbs,
15855 alc861_asus_laptop_init_verbs },
15856 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15857 .dac_nids = alc861_dac_nids,
15858 .dig_out_nid = ALC861_DIGOUT_NID,
15859 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15860 .channel_mode = alc883_3ST_2ch_modes,
15861 .need_dac_fix = 1,
15862 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15863 .adc_nids = alc861_adc_nids,
15864 .input_mux = &alc861_capture_source,
15865 },
15866};
Kailang Yangdf694da2005-12-05 19:42:22 +010015867
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015868/* Pin config fixes */
15869enum {
15870 PINFIX_FSC_AMILO_PI1505,
15871};
15872
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015873static const struct alc_fixup alc861_fixups[] = {
15874 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020015875 .pins = (const struct alc_pincfg[]) {
15876 { 0x0b, 0x0221101f }, /* HP */
15877 { 0x0f, 0x90170310 }, /* speaker */
15878 { }
15879 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015880 },
15881};
15882
15883static struct snd_pci_quirk alc861_fixup_tbl[] = {
15884 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15885 {}
15886};
Kailang Yangdf694da2005-12-05 19:42:22 +010015887
15888static int patch_alc861(struct hda_codec *codec)
15889{
15890 struct alc_spec *spec;
15891 int board_config;
15892 int err;
15893
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015894 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015895 if (spec == NULL)
15896 return -ENOMEM;
15897
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015898 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015899
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015900 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15901 alc861_models,
15902 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015903
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015904 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015905 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15906 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015907 board_config = ALC861_AUTO;
15908 }
15909
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015910 if (board_config == ALC861_AUTO)
15911 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015912
Kailang Yangdf694da2005-12-05 19:42:22 +010015913 if (board_config == ALC861_AUTO) {
15914 /* automatic parse from the BIOS config */
15915 err = alc861_parse_auto_config(codec);
15916 if (err < 0) {
15917 alc_free(codec);
15918 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015919 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015920 printk(KERN_INFO
15921 "hda_codec: Cannot set up configuration "
15922 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015923 board_config = ALC861_3ST_DIG;
15924 }
15925 }
15926
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015927 err = snd_hda_attach_beep_device(codec, 0x23);
15928 if (err < 0) {
15929 alc_free(codec);
15930 return err;
15931 }
15932
Kailang Yangdf694da2005-12-05 19:42:22 +010015933 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015934 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015935
Kailang Yangdf694da2005-12-05 19:42:22 +010015936 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15937 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15938
Kailang Yangdf694da2005-12-05 19:42:22 +010015939 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15940 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15941
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015942 if (!spec->cap_mixer)
15943 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015944 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15945
Takashi Iwai2134ea42008-01-10 16:53:55 +010015946 spec->vmaster_nid = 0x03;
15947
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015948 if (board_config == ALC861_AUTO)
15949 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15950
Kailang Yangdf694da2005-12-05 19:42:22 +010015951 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015952 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015953 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015954#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015955 spec->power_hook = alc_power_eapd;
15956#endif
15957 }
15958#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015959 if (!spec->loopback.amplist)
15960 spec->loopback.amplist = alc861_loopbacks;
15961#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015962
Kailang Yangdf694da2005-12-05 19:42:22 +010015963 return 0;
15964}
15965
15966/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015967 * ALC861-VD support
15968 *
15969 * Based on ALC882
15970 *
15971 * In addition, an independent DAC
15972 */
15973#define ALC861VD_DIGOUT_NID 0x06
15974
15975static hda_nid_t alc861vd_dac_nids[4] = {
15976 /* front, surr, clfe, side surr */
15977 0x02, 0x03, 0x04, 0x05
15978};
15979
15980/* dac_nids for ALC660vd are in a different order - according to
15981 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015982 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015983 * of ALC660vd codecs, but for now there is only 3stack mixer
15984 * - and it is the same as in 861vd.
15985 * adc_nids in ALC660vd are (is) the same as in 861vd
15986 */
15987static hda_nid_t alc660vd_dac_nids[3] = {
15988 /* front, rear, clfe, rear_surr */
15989 0x02, 0x04, 0x03
15990};
15991
15992static hda_nid_t alc861vd_adc_nids[1] = {
15993 /* ADC0 */
15994 0x09,
15995};
15996
Takashi Iwaie1406342008-02-11 18:32:32 +010015997static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15998
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015999/* input MUX */
16000/* FIXME: should be a matrix-type input source selection */
16001static struct hda_input_mux alc861vd_capture_source = {
16002 .num_items = 4,
16003 .items = {
16004 { "Mic", 0x0 },
16005 { "Front Mic", 0x1 },
16006 { "Line", 0x2 },
16007 { "CD", 0x4 },
16008 },
16009};
16010
Kailang Yang272a5272007-05-14 11:00:38 +020016011static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016012 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016013 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016014 { "Ext Mic", 0x0 },
16015 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016016 },
16017};
16018
Kailang Yangd1a991a2007-08-15 16:21:59 +020016019static struct hda_input_mux alc861vd_hp_capture_source = {
16020 .num_items = 2,
16021 .items = {
16022 { "Front Mic", 0x0 },
16023 { "ATAPI Mic", 0x1 },
16024 },
16025};
16026
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016027/*
16028 * 2ch mode
16029 */
16030static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16031 { 2, NULL }
16032};
16033
16034/*
16035 * 6ch mode
16036 */
16037static struct hda_verb alc861vd_6stack_ch6_init[] = {
16038 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16039 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16040 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16041 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16042 { } /* end */
16043};
16044
16045/*
16046 * 8ch mode
16047 */
16048static struct hda_verb alc861vd_6stack_ch8_init[] = {
16049 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16050 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16051 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16052 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16053 { } /* end */
16054};
16055
16056static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16057 { 6, alc861vd_6stack_ch6_init },
16058 { 8, alc861vd_6stack_ch8_init },
16059};
16060
16061static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16062 {
16063 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16064 .name = "Channel Mode",
16065 .info = alc_ch_mode_info,
16066 .get = alc_ch_mode_get,
16067 .put = alc_ch_mode_put,
16068 },
16069 { } /* end */
16070};
16071
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016072/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16073 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16074 */
16075static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16076 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16077 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16078
16079 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16080 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16081
16082 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16083 HDA_OUTPUT),
16084 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16085 HDA_OUTPUT),
16086 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16087 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16088
16089 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16090 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16091
16092 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16093
16094 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16095 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16096 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16097
16098 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16099 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16101
16102 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16103 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16104
16105 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16106 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16107
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016108 { } /* end */
16109};
16110
16111static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16112 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16113 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16114
16115 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16116
16117 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16118 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16119 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16120
16121 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16122 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16123 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16124
16125 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16126 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16127
16128 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16129 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16130
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016131 { } /* end */
16132};
16133
Kailang Yangbdd148a2007-05-08 15:19:08 +020016134static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16135 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16136 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16137 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16138
16139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16140
16141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16142 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16143 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16144
16145 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16146 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16147 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16148
16149 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16150 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16151
16152 { } /* end */
16153};
16154
Tobin Davisb419f342008-03-07 11:57:51 +010016155/* Pin assignment: Speaker=0x14, HP = 0x15,
16156 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016157 */
16158static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16160 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16162 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016163 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16164 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16165 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16166 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16167 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16168 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016169 { } /* end */
16170};
16171
Kailang Yangd1a991a2007-08-15 16:21:59 +020016172/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16173 * Front Mic=0x18, ATAPI Mic = 0x19,
16174 */
16175static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16176 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16177 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16179 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16180 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16181 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16182 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16183 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016184
Kailang Yangd1a991a2007-08-15 16:21:59 +020016185 { } /* end */
16186};
16187
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016188/*
16189 * generic initialization of ADC, input mixers and output mixers
16190 */
16191static struct hda_verb alc861vd_volume_init_verbs[] = {
16192 /*
16193 * Unmute ADC0 and set the default input to mic-in
16194 */
16195 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16196 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16197
16198 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16199 * the analog-loopback mixer widget
16200 */
16201 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016202 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016207
16208 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016209 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016212 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016213
16214 /*
16215 * Set up output mixers (0x02 - 0x05)
16216 */
16217 /* set vol=0 to output mixers */
16218 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16219 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16220 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16221 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16222
16223 /* set up input amps for analog loopback */
16224 /* Amp Indices: DAC = 0, mixer = 1 */
16225 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16226 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16227 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16228 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16229 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16231 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16232 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16233
16234 { }
16235};
16236
16237/*
16238 * 3-stack pin configuration:
16239 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16240 */
16241static struct hda_verb alc861vd_3stack_init_verbs[] = {
16242 /*
16243 * Set pin mode and muting
16244 */
16245 /* set front pin widgets 0x14 for output */
16246 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16247 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16248 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16249
16250 /* Mic (rear) pin: input vref at 80% */
16251 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16252 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16253 /* Front Mic pin: input vref at 80% */
16254 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16255 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16256 /* Line In pin: input */
16257 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16258 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16259 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16260 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16261 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16262 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16263 /* CD pin widget for input */
16264 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16265
16266 { }
16267};
16268
16269/*
16270 * 6-stack pin configuration:
16271 */
16272static struct hda_verb alc861vd_6stack_init_verbs[] = {
16273 /*
16274 * Set pin mode and muting
16275 */
16276 /* set front pin widgets 0x14 for output */
16277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16278 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16279 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16280
16281 /* Rear Pin: output 1 (0x0d) */
16282 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16283 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16284 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16285 /* CLFE Pin: output 2 (0x0e) */
16286 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16287 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16288 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16289 /* Side Pin: output 3 (0x0f) */
16290 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16291 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16292 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16293
16294 /* Mic (rear) pin: input vref at 80% */
16295 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16296 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16297 /* Front Mic pin: input vref at 80% */
16298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16299 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16300 /* Line In pin: input */
16301 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16302 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16303 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16304 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16305 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16306 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16307 /* CD pin widget for input */
16308 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16309
16310 { }
16311};
16312
Kailang Yangbdd148a2007-05-08 15:19:08 +020016313static struct hda_verb alc861vd_eapd_verbs[] = {
16314 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16315 { }
16316};
16317
Kailang Yangf9423e72008-05-27 12:32:25 +020016318static struct hda_verb alc660vd_eapd_verbs[] = {
16319 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16320 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16321 { }
16322};
16323
Kailang Yangbdd148a2007-05-08 15:19:08 +020016324static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16325 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16326 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16328 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016329 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016330 {}
16331};
16332
Kailang Yangbdd148a2007-05-08 15:19:08 +020016333static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16334{
16335 unsigned int present;
16336 unsigned char bits;
16337
Wu Fengguang864f92b2009-11-18 12:38:02 +080016338 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016339 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016340
Takashi Iwai47fd8302007-08-10 17:11:07 +020016341 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16342 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016343}
16344
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016345static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016346{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016347 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016348 spec->autocfg.hp_pins[0] = 0x1b;
16349 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016350}
16351
16352static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16353{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016354 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016355 alc861vd_lenovo_mic_automute(codec);
16356}
16357
16358static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16359 unsigned int res)
16360{
16361 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016362 case ALC880_MIC_EVENT:
16363 alc861vd_lenovo_mic_automute(codec);
16364 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016365 default:
16366 alc_automute_amp_unsol_event(codec, res);
16367 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016368 }
16369}
16370
Kailang Yang272a5272007-05-14 11:00:38 +020016371static struct hda_verb alc861vd_dallas_verbs[] = {
16372 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16373 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16374 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16375 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16376
16377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16378 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16379 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16380 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16381 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16383 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016385
Kailang Yang272a5272007-05-14 11:00:38 +020016386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16388 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16392 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16393 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16394
16395 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16396 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16398 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16399 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16400 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16401 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16402 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16403
16404 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16405 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16406 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16407 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16408
16409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016410 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016411 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16412
16413 { } /* end */
16414};
16415
16416/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016417static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016418{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016419 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016420
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016421 spec->autocfg.hp_pins[0] = 0x15;
16422 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016423}
16424
Takashi Iwaicb53c622007-08-10 17:21:45 +020016425#ifdef CONFIG_SND_HDA_POWER_SAVE
16426#define alc861vd_loopbacks alc880_loopbacks
16427#endif
16428
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016429/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016430#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16431#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16432#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16433#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16434
16435/*
16436 * configuration and preset
16437 */
16438static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16439 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016440 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016441 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016442 [ALC861VD_3ST] = "3stack",
16443 [ALC861VD_3ST_DIG] = "3stack-digout",
16444 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016445 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016446 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016447 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016448 [ALC861VD_AUTO] = "auto",
16449};
16450
16451static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016452 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16453 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016454 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016455 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016456 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016457 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016458 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016459 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016460 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016461 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016462 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016463 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016464 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016465 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016466 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016467 {}
16468};
16469
16470static struct alc_config_preset alc861vd_presets[] = {
16471 [ALC660VD_3ST] = {
16472 .mixers = { alc861vd_3st_mixer },
16473 .init_verbs = { alc861vd_volume_init_verbs,
16474 alc861vd_3stack_init_verbs },
16475 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16476 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016477 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16478 .channel_mode = alc861vd_3stack_2ch_modes,
16479 .input_mux = &alc861vd_capture_source,
16480 },
Mike Crash6963f842007-06-25 12:12:51 +020016481 [ALC660VD_3ST_DIG] = {
16482 .mixers = { alc861vd_3st_mixer },
16483 .init_verbs = { alc861vd_volume_init_verbs,
16484 alc861vd_3stack_init_verbs },
16485 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16486 .dac_nids = alc660vd_dac_nids,
16487 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016488 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16489 .channel_mode = alc861vd_3stack_2ch_modes,
16490 .input_mux = &alc861vd_capture_source,
16491 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016492 [ALC861VD_3ST] = {
16493 .mixers = { alc861vd_3st_mixer },
16494 .init_verbs = { alc861vd_volume_init_verbs,
16495 alc861vd_3stack_init_verbs },
16496 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16497 .dac_nids = alc861vd_dac_nids,
16498 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16499 .channel_mode = alc861vd_3stack_2ch_modes,
16500 .input_mux = &alc861vd_capture_source,
16501 },
16502 [ALC861VD_3ST_DIG] = {
16503 .mixers = { alc861vd_3st_mixer },
16504 .init_verbs = { alc861vd_volume_init_verbs,
16505 alc861vd_3stack_init_verbs },
16506 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16507 .dac_nids = alc861vd_dac_nids,
16508 .dig_out_nid = ALC861VD_DIGOUT_NID,
16509 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16510 .channel_mode = alc861vd_3stack_2ch_modes,
16511 .input_mux = &alc861vd_capture_source,
16512 },
16513 [ALC861VD_6ST_DIG] = {
16514 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16515 .init_verbs = { alc861vd_volume_init_verbs,
16516 alc861vd_6stack_init_verbs },
16517 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16518 .dac_nids = alc861vd_dac_nids,
16519 .dig_out_nid = ALC861VD_DIGOUT_NID,
16520 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16521 .channel_mode = alc861vd_6stack_modes,
16522 .input_mux = &alc861vd_capture_source,
16523 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016524 [ALC861VD_LENOVO] = {
16525 .mixers = { alc861vd_lenovo_mixer },
16526 .init_verbs = { alc861vd_volume_init_verbs,
16527 alc861vd_3stack_init_verbs,
16528 alc861vd_eapd_verbs,
16529 alc861vd_lenovo_unsol_verbs },
16530 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16531 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016532 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16533 .channel_mode = alc861vd_3stack_2ch_modes,
16534 .input_mux = &alc861vd_capture_source,
16535 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016536 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016537 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016538 },
Kailang Yang272a5272007-05-14 11:00:38 +020016539 [ALC861VD_DALLAS] = {
16540 .mixers = { alc861vd_dallas_mixer },
16541 .init_verbs = { alc861vd_dallas_verbs },
16542 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16543 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016544 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16545 .channel_mode = alc861vd_3stack_2ch_modes,
16546 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016547 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016548 .setup = alc861vd_dallas_setup,
16549 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016550 },
16551 [ALC861VD_HP] = {
16552 .mixers = { alc861vd_hp_mixer },
16553 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16554 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16555 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016556 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016557 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16558 .channel_mode = alc861vd_3stack_2ch_modes,
16559 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016560 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016561 .setup = alc861vd_dallas_setup,
16562 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016563 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016564 [ALC660VD_ASUS_V1S] = {
16565 .mixers = { alc861vd_lenovo_mixer },
16566 .init_verbs = { alc861vd_volume_init_verbs,
16567 alc861vd_3stack_init_verbs,
16568 alc861vd_eapd_verbs,
16569 alc861vd_lenovo_unsol_verbs },
16570 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16571 .dac_nids = alc660vd_dac_nids,
16572 .dig_out_nid = ALC861VD_DIGOUT_NID,
16573 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16574 .channel_mode = alc861vd_3stack_2ch_modes,
16575 .input_mux = &alc861vd_capture_source,
16576 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016577 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016578 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016579 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016580};
16581
16582/*
16583 * BIOS auto configuration
16584 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016585static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16586 const struct auto_pin_cfg *cfg)
16587{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016588 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016589}
16590
16591
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016592static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16593 hda_nid_t nid, int pin_type, int dac_idx)
16594{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016595 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016596}
16597
16598static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16599{
16600 struct alc_spec *spec = codec->spec;
16601 int i;
16602
16603 for (i = 0; i <= HDA_SIDE; i++) {
16604 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016605 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016606 if (nid)
16607 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016608 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016609 }
16610}
16611
16612
16613static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16614{
16615 struct alc_spec *spec = codec->spec;
16616 hda_nid_t pin;
16617
16618 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016619 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016620 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016621 pin = spec->autocfg.speaker_pins[0];
16622 if (pin)
16623 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016624}
16625
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016626#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16627
16628static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16629{
16630 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016631 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016632 int i;
16633
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016634 for (i = 0; i < cfg->num_inputs; i++) {
16635 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016636 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016637 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016638 if (nid != ALC861VD_PIN_CD_NID &&
16639 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016640 snd_hda_codec_write(codec, nid, 0,
16641 AC_VERB_SET_AMP_GAIN_MUTE,
16642 AMP_OUT_MUTE);
16643 }
16644 }
16645}
16646
Takashi Iwaif511b012008-08-15 16:46:42 +020016647#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16648
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016649#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16650#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16651
16652/* add playback controls from the parsed DAC table */
16653/* Based on ALC880 version. But ALC861VD has separate,
16654 * different NIDs for mute/unmute switch and volume control */
16655static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16656 const struct auto_pin_cfg *cfg)
16657{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016658 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16659 hda_nid_t nid_v, nid_s;
16660 int i, err;
16661
16662 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016663 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016664 continue;
16665 nid_v = alc861vd_idx_to_mixer_vol(
16666 alc880_dac_to_idx(
16667 spec->multiout.dac_nids[i]));
16668 nid_s = alc861vd_idx_to_mixer_switch(
16669 alc880_dac_to_idx(
16670 spec->multiout.dac_nids[i]));
16671
16672 if (i == 2) {
16673 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016674 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16675 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016676 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16677 HDA_OUTPUT));
16678 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016679 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016680 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16681 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016682 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16683 HDA_OUTPUT));
16684 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016685 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016686 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16687 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016688 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16689 HDA_INPUT));
16690 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016691 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016692 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16693 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016694 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16695 HDA_INPUT));
16696 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016697 return err;
16698 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016699 const char *pfx;
16700 if (cfg->line_outs == 1 &&
16701 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16702 if (!cfg->hp_pins)
16703 pfx = "Speaker";
16704 else
16705 pfx = "PCM";
16706 } else
16707 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016708 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016709 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16710 HDA_OUTPUT));
16711 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016712 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016713 if (cfg->line_outs == 1 &&
16714 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16715 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016716 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016717 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016718 HDA_INPUT));
16719 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016720 return err;
16721 }
16722 }
16723 return 0;
16724}
16725
16726/* add playback controls for speaker and HP outputs */
16727/* Based on ALC880 version. But ALC861VD has separate,
16728 * different NIDs for mute/unmute switch and volume control */
16729static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16730 hda_nid_t pin, const char *pfx)
16731{
16732 hda_nid_t nid_v, nid_s;
16733 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016734
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016735 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016736 return 0;
16737
16738 if (alc880_is_fixed_pin(pin)) {
16739 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16740 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016741 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016742 spec->multiout.hp_nid = nid_v;
16743 else
16744 spec->multiout.extra_out_nid[0] = nid_v;
16745 /* control HP volume/switch on the output mixer amp */
16746 nid_v = alc861vd_idx_to_mixer_vol(
16747 alc880_fixed_pin_idx(pin));
16748 nid_s = alc861vd_idx_to_mixer_switch(
16749 alc880_fixed_pin_idx(pin));
16750
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016751 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016752 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16753 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016754 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016755 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016756 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16757 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016758 return err;
16759 } else if (alc880_is_multi_pin(pin)) {
16760 /* set manual connection */
16761 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016762 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016763 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16764 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016765 return err;
16766 }
16767 return 0;
16768}
16769
16770/* parse the BIOS configuration and set up the alc_spec
16771 * return 1 if successful, 0 if the proper config is not found,
16772 * or a negative error code
16773 * Based on ALC880 version - had to change it to override
16774 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16775static int alc861vd_parse_auto_config(struct hda_codec *codec)
16776{
16777 struct alc_spec *spec = codec->spec;
16778 int err;
16779 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16780
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016781 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16782 alc861vd_ignore);
16783 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016784 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016785 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016786 return 0; /* can't find valid BIOS pin config */
16787
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016788 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16789 if (err < 0)
16790 return err;
16791 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16792 if (err < 0)
16793 return err;
16794 err = alc861vd_auto_create_extra_out(spec,
16795 spec->autocfg.speaker_pins[0],
16796 "Speaker");
16797 if (err < 0)
16798 return err;
16799 err = alc861vd_auto_create_extra_out(spec,
16800 spec->autocfg.hp_pins[0],
16801 "Headphone");
16802 if (err < 0)
16803 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016804 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016805 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016806 return err;
16807
16808 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16809
Takashi Iwai757899a2010-07-30 10:48:14 +020016810 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016811
Takashi Iwai603c4012008-07-30 15:01:44 +020016812 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016813 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016814
Takashi Iwaid88897e2008-10-31 15:01:37 +010016815 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016816
16817 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016818 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016819
Takashi Iwai776e1842007-08-29 15:07:11 +020016820 err = alc_auto_add_mic_boost(codec);
16821 if (err < 0)
16822 return err;
16823
Kailang Yang6227cdc2010-02-25 08:36:52 +010016824 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016825
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016826 return 1;
16827}
16828
16829/* additional initialization for auto-configuration model */
16830static void alc861vd_auto_init(struct hda_codec *codec)
16831{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016832 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016833 alc861vd_auto_init_multi_out(codec);
16834 alc861vd_auto_init_hp_out(codec);
16835 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016836 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016837 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016838 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016839 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016840}
16841
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016842enum {
16843 ALC660VD_FIX_ASUS_GPIO1
16844};
16845
16846/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016847static const struct alc_fixup alc861vd_fixups[] = {
16848 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016849 .verbs = (const struct hda_verb[]) {
16850 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16851 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16852 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16853 { }
16854 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016855 },
16856};
16857
16858static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16859 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16860 {}
16861};
16862
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016863static int patch_alc861vd(struct hda_codec *codec)
16864{
16865 struct alc_spec *spec;
16866 int err, board_config;
16867
16868 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16869 if (spec == NULL)
16870 return -ENOMEM;
16871
16872 codec->spec = spec;
16873
16874 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16875 alc861vd_models,
16876 alc861vd_cfg_tbl);
16877
16878 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016879 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16880 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016881 board_config = ALC861VD_AUTO;
16882 }
16883
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016884 if (board_config == ALC861VD_AUTO)
16885 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016886
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016887 if (board_config == ALC861VD_AUTO) {
16888 /* automatic parse from the BIOS config */
16889 err = alc861vd_parse_auto_config(codec);
16890 if (err < 0) {
16891 alc_free(codec);
16892 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016893 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016894 printk(KERN_INFO
16895 "hda_codec: Cannot set up configuration "
16896 "from BIOS. Using base mode...\n");
16897 board_config = ALC861VD_3ST;
16898 }
16899 }
16900
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016901 err = snd_hda_attach_beep_device(codec, 0x23);
16902 if (err < 0) {
16903 alc_free(codec);
16904 return err;
16905 }
16906
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016907 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016908 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016909
Kailang Yang2f893282008-05-27 12:14:47 +020016910 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016911 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016912 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016913 }
16914
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016915 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16916 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16917
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016918 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16919 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16920
Takashi Iwaidd704692009-08-11 08:45:11 +020016921 if (!spec->adc_nids) {
16922 spec->adc_nids = alc861vd_adc_nids;
16923 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16924 }
16925 if (!spec->capsrc_nids)
16926 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016927
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016928 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016929 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016930
Takashi Iwai2134ea42008-01-10 16:53:55 +010016931 spec->vmaster_nid = 0x02;
16932
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016933 if (board_config == ALC861VD_AUTO)
16934 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16935
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016936 codec->patch_ops = alc_patch_ops;
16937
16938 if (board_config == ALC861VD_AUTO)
16939 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016940#ifdef CONFIG_SND_HDA_POWER_SAVE
16941 if (!spec->loopback.amplist)
16942 spec->loopback.amplist = alc861vd_loopbacks;
16943#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016944
16945 return 0;
16946}
16947
16948/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016949 * ALC662 support
16950 *
16951 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16952 * configuration. Each pin widget can choose any input DACs and a mixer.
16953 * Each ADC is connected from a mixer of all inputs. This makes possible
16954 * 6-channel independent captures.
16955 *
16956 * In addition, an independent DAC for the multi-playback (not used in this
16957 * driver yet).
16958 */
16959#define ALC662_DIGOUT_NID 0x06
16960#define ALC662_DIGIN_NID 0x0a
16961
16962static hda_nid_t alc662_dac_nids[4] = {
16963 /* front, rear, clfe, rear_surr */
16964 0x02, 0x03, 0x04
16965};
16966
Kailang Yang622e84c2009-04-21 07:39:04 +020016967static hda_nid_t alc272_dac_nids[2] = {
16968 0x02, 0x03
16969};
16970
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016971static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016972 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016973 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016974};
Takashi Iwaie1406342008-02-11 18:32:32 +010016975
Kailang Yang622e84c2009-04-21 07:39:04 +020016976static hda_nid_t alc272_adc_nids[1] = {
16977 /* ADC1-2 */
16978 0x08,
16979};
16980
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016981static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016982static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16983
Takashi Iwaie1406342008-02-11 18:32:32 +010016984
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016985/* input MUX */
16986/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016987static struct hda_input_mux alc662_capture_source = {
16988 .num_items = 4,
16989 .items = {
16990 { "Mic", 0x0 },
16991 { "Front Mic", 0x1 },
16992 { "Line", 0x2 },
16993 { "CD", 0x4 },
16994 },
16995};
16996
16997static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16998 .num_items = 2,
16999 .items = {
17000 { "Mic", 0x1 },
17001 { "Line", 0x2 },
17002 },
17003};
Kailang Yang291702f2007-10-16 14:28:03 +020017004
Kailang Yang6dda9f42008-05-27 12:05:31 +020017005static struct hda_input_mux alc663_capture_source = {
17006 .num_items = 3,
17007 .items = {
17008 { "Mic", 0x0 },
17009 { "Front Mic", 0x1 },
17010 { "Line", 0x2 },
17011 },
17012};
17013
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017014#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017015static struct hda_input_mux alc272_nc10_capture_source = {
17016 .num_items = 16,
17017 .items = {
17018 { "Autoselect Mic", 0x0 },
17019 { "Internal Mic", 0x1 },
17020 { "In-0x02", 0x2 },
17021 { "In-0x03", 0x3 },
17022 { "In-0x04", 0x4 },
17023 { "In-0x05", 0x5 },
17024 { "In-0x06", 0x6 },
17025 { "In-0x07", 0x7 },
17026 { "In-0x08", 0x8 },
17027 { "In-0x09", 0x9 },
17028 { "In-0x0a", 0x0a },
17029 { "In-0x0b", 0x0b },
17030 { "In-0x0c", 0x0c },
17031 { "In-0x0d", 0x0d },
17032 { "In-0x0e", 0x0e },
17033 { "In-0x0f", 0x0f },
17034 },
17035};
17036#endif
17037
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017038/*
17039 * 2ch mode
17040 */
17041static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17042 { 2, NULL }
17043};
17044
17045/*
17046 * 2ch mode
17047 */
17048static struct hda_verb alc662_3ST_ch2_init[] = {
17049 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17050 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17051 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17052 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17053 { } /* end */
17054};
17055
17056/*
17057 * 6ch mode
17058 */
17059static struct hda_verb alc662_3ST_ch6_init[] = {
17060 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17061 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17062 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17063 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17064 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17065 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17066 { } /* end */
17067};
17068
17069static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17070 { 2, alc662_3ST_ch2_init },
17071 { 6, alc662_3ST_ch6_init },
17072};
17073
17074/*
17075 * 2ch mode
17076 */
17077static struct hda_verb alc662_sixstack_ch6_init[] = {
17078 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17079 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17080 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17081 { } /* end */
17082};
17083
17084/*
17085 * 6ch mode
17086 */
17087static struct hda_verb alc662_sixstack_ch8_init[] = {
17088 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17089 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17090 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17091 { } /* end */
17092};
17093
17094static struct hda_channel_mode alc662_5stack_modes[2] = {
17095 { 2, alc662_sixstack_ch6_init },
17096 { 6, alc662_sixstack_ch8_init },
17097};
17098
17099/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17100 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17101 */
17102
17103static struct snd_kcontrol_new alc662_base_mixer[] = {
17104 /* output mixer control */
17105 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017106 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017107 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017108 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017109 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17110 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017111 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17112 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017113 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17114
17115 /*Input mixer control */
17116 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17117 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17118 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17119 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17120 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17121 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17122 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17123 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017124 { } /* end */
17125};
17126
17127static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17128 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017129 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017130 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17131 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17132 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17133 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17134 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17135 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17136 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17137 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17138 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017139 { } /* end */
17140};
17141
17142static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17143 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017144 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017145 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017146 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017147 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17148 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017149 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17150 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017151 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17152 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17153 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17154 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17155 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17156 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17158 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017160 { } /* end */
17161};
17162
17163static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17164 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17165 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017166 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17167 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17169 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17170 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17171 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17172 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017173 { } /* end */
17174};
17175
Kailang Yang291702f2007-10-16 14:28:03 +020017176static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017177 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17178 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017179
17180 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17181 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17182 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17183
17184 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17185 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17186 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17187 { } /* end */
17188};
17189
Kailang Yang8c427222008-01-10 13:03:59 +010017190static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017191 ALC262_HIPPO_MASTER_SWITCH,
17192 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017193 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017194 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17195 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017196 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17201 { } /* end */
17202};
17203
Kailang Yangf1d4e282008-08-26 14:03:29 +020017204static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17205 .ops = &snd_hda_bind_vol,
17206 .values = {
17207 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17208 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17209 0
17210 },
17211};
17212
17213static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17214 .ops = &snd_hda_bind_sw,
17215 .values = {
17216 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17217 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17218 0
17219 },
17220};
17221
Kailang Yang6dda9f42008-05-27 12:05:31 +020017222static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017223 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17224 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17226 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17227 { } /* end */
17228};
17229
17230static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17231 .ops = &snd_hda_bind_sw,
17232 .values = {
17233 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17234 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17235 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17236 0
17237 },
17238};
17239
17240static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17241 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17242 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17245 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17246 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17247
17248 { } /* end */
17249};
17250
17251static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17252 .ops = &snd_hda_bind_sw,
17253 .values = {
17254 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17255 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17256 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17257 0
17258 },
17259};
17260
17261static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17262 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17263 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17264 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17265 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17266 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17267 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17268 { } /* end */
17269};
17270
17271static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017272 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17273 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17275 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17276 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17277 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17278 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17279 { } /* end */
17280};
17281
17282static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17283 .ops = &snd_hda_bind_vol,
17284 .values = {
17285 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17286 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17287 0
17288 },
17289};
17290
17291static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17292 .ops = &snd_hda_bind_sw,
17293 .values = {
17294 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17295 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17296 0
17297 },
17298};
17299
17300static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17301 HDA_BIND_VOL("Master Playback Volume",
17302 &alc663_asus_two_bind_master_vol),
17303 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17304 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17307 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017308 { } /* end */
17309};
17310
17311static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17312 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17313 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17314 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17315 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17317 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017318 { } /* end */
17319};
17320
17321static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17322 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17323 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17324 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17325 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17327
17328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17330 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17331 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17332 { } /* end */
17333};
17334
17335static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17336 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17337 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17338 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17339
17340 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17341 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17342 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17343 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17344 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17345 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17346 { } /* end */
17347};
17348
Kailang Yangebb83ee2009-12-17 12:23:00 +010017349static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17350 .ops = &snd_hda_bind_sw,
17351 .values = {
17352 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17353 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17354 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17355 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17356 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17357 0
17358 },
17359};
17360
17361static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17362 .ops = &snd_hda_bind_sw,
17363 .values = {
17364 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17365 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17366 0
17367 },
17368};
17369
17370static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17371 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17372 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17373 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17374 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17375 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17376 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17377 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17380 { } /* end */
17381};
17382
17383static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17384 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17385 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17386 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17387 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17388 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17391 { } /* end */
17392};
17393
17394
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017395static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17396 {
17397 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17398 .name = "Channel Mode",
17399 .info = alc_ch_mode_info,
17400 .get = alc_ch_mode_get,
17401 .put = alc_ch_mode_put,
17402 },
17403 { } /* end */
17404};
17405
17406static struct hda_verb alc662_init_verbs[] = {
17407 /* ADC: mute amp left and right */
17408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17409 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017410
Kailang Yangb60dd392007-09-20 12:50:29 +020017411 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17413 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17414 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17415 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17416 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017417
17418 /* Front Pin: output 0 (0x0c) */
17419 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17420 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17421
17422 /* Rear Pin: output 1 (0x0d) */
17423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17425
17426 /* CLFE Pin: output 2 (0x0e) */
17427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17429
17430 /* Mic (rear) pin: input vref at 80% */
17431 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17432 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17433 /* Front Mic pin: input vref at 80% */
17434 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17435 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17436 /* Line In pin: input */
17437 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17438 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17439 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17440 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17441 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17442 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17443 /* CD pin widget for input */
17444 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17445
17446 /* FIXME: use matrix-type input source selection */
17447 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17448 /* Input mixer */
17449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017450 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017451
17452 /* always trun on EAPD */
17453 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17454 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17455
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017456 { }
17457};
17458
Kailang Yangcec27c82010-02-04 14:18:18 +010017459static struct hda_verb alc663_init_verbs[] = {
17460 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17461 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17462 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17463 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17465 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17466 { }
17467};
17468
17469static struct hda_verb alc272_init_verbs[] = {
17470 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17471 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17472 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17473 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17474 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17475 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17476 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17477 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17478 { }
17479};
17480
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017481static struct hda_verb alc662_sue_init_verbs[] = {
17482 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17483 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017484 {}
17485};
17486
17487static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17488 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17489 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17490 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491};
17492
Kailang Yang8c427222008-01-10 13:03:59 +010017493/* Set Unsolicited Event*/
17494static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17495 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17496 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17497 {}
17498};
17499
Kailang Yang6dda9f42008-05-27 12:05:31 +020017500static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017501 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17502 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017503 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17504 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017505 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17507 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017508 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17509 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17510 {}
17511};
17512
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513static struct hda_verb alc663_21jd_amic_init_verbs[] = {
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, 0x01}, /* Headphone */
17517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17518 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17519 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17520 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17521 {}
17522};
17523
17524static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17526 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17527 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17528 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17531 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17533 {}
17534};
17535
17536static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17537 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17538 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17539 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17540 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17541 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17542 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17543 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17544 {}
17545};
17546
17547static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17548 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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, 0x0}, /* Headphone */
17552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17553 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17554 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17557 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17558 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17560 {}
17561};
17562
17563static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17564 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17565 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17566 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17567 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17569 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17570 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17571 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17572 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17573 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17574 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17576 {}
17577};
17578
Kailang Yang6dda9f42008-05-27 12:05:31 +020017579static struct hda_verb alc663_g71v_init_verbs[] = {
17580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17581 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17582 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17583
17584 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17585 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17586 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17587
17588 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17589 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17590 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17591 {}
17592};
17593
17594static struct hda_verb alc663_g50v_init_verbs[] = {
17595 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17596 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17597 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17598
17599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17600 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17601 {}
17602};
17603
Kailang Yangf1d4e282008-08-26 14:03:29 +020017604static struct hda_verb alc662_ecs_init_verbs[] = {
17605 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17607 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17608 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17609 {}
17610};
17611
Kailang Yang622e84c2009-04-21 07:39:04 +020017612static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17613 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17614 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17615 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17616 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17617 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17618 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17619 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17622 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17623 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17624 {}
17625};
17626
17627static struct hda_verb alc272_dell_init_verbs[] = {
17628 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17629 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17632 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17633 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17634 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17635 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17636 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17637 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17638 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17639 {}
17640};
17641
Kailang Yangebb83ee2009-12-17 12:23:00 +010017642static struct hda_verb alc663_mode7_init_verbs[] = {
17643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17645 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17646 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17648 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17649 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17650 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17651 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17652 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17655 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17656 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17657 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17658 {}
17659};
17660
17661static struct hda_verb alc663_mode8_init_verbs[] = {
17662 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17665 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17666 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17667 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17668 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17670 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17671 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17672 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17674 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17675 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17676 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17677 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17678 {}
17679};
17680
Kailang Yangf1d4e282008-08-26 14:03:29 +020017681static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17682 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17683 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17684 { } /* end */
17685};
17686
Kailang Yang622e84c2009-04-21 07:39:04 +020017687static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17688 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17689 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17690 { } /* end */
17691};
17692
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017693static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17694{
17695 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017696 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017697
Wu Fengguang864f92b2009-11-18 12:38:02 +080017698 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017699 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017700
Takashi Iwai47fd8302007-08-10 17:11:07 +020017701 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17702 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017703}
17704
17705static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17706{
17707 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017708 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017709
Wu Fengguang864f92b2009-11-18 12:38:02 +080017710 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017711 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017712
Takashi Iwai47fd8302007-08-10 17:11:07 +020017713 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17714 HDA_AMP_MUTE, bits);
17715 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17716 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017717}
17718
17719static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17720 unsigned int res)
17721{
17722 if ((res >> 26) == ALC880_HP_EVENT)
17723 alc662_lenovo_101e_all_automute(codec);
17724 if ((res >> 26) == ALC880_FRONT_EVENT)
17725 alc662_lenovo_101e_ispeaker_automute(codec);
17726}
17727
Kailang Yang291702f2007-10-16 14:28:03 +020017728/* unsolicited event for HP jack sensing */
17729static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17730 unsigned int res)
17731{
Kailang Yang291702f2007-10-16 14:28:03 +020017732 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017733 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017734 else
17735 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017736}
17737
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017738static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017739{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017740 struct alc_spec *spec = codec->spec;
17741
17742 alc262_hippo1_setup(codec);
17743 spec->ext_mic.pin = 0x18;
17744 spec->ext_mic.mux_idx = 0;
17745 spec->int_mic.pin = 0x19;
17746 spec->int_mic.mux_idx = 1;
17747 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017748}
17749
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017750static void alc662_eeepc_inithook(struct hda_codec *codec)
17751{
17752 alc262_hippo_automute(codec);
17753 alc_mic_automute(codec);
17754}
17755
17756static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017757{
Takashi Iwai42171c12009-05-08 14:11:43 +020017758 struct alc_spec *spec = codec->spec;
17759
17760 spec->autocfg.hp_pins[0] = 0x14;
17761 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017762}
17763
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017764#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17765
Kailang Yang6dda9f42008-05-27 12:05:31 +020017766static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17767{
17768 unsigned int present;
17769 unsigned char bits;
17770
Wu Fengguang864f92b2009-11-18 12:38:02 +080017771 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017772 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017773 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017774 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017775 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017776 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017777}
17778
17779static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17780{
17781 unsigned int present;
17782 unsigned char bits;
17783
Wu Fengguang864f92b2009-11-18 12:38:02 +080017784 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017785 bits = present ? HDA_AMP_MUTE : 0;
17786 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017787 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017788 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017789 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017790 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017791 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017792 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017793 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017794}
17795
17796static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17797{
17798 unsigned int present;
17799 unsigned char bits;
17800
Wu Fengguang864f92b2009-11-18 12:38:02 +080017801 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017802 bits = present ? HDA_AMP_MUTE : 0;
17803 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017804 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017805 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017806 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017807 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017808 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017809 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017810 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017811}
17812
17813static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17814{
17815 unsigned int present;
17816 unsigned char bits;
17817
Wu Fengguang864f92b2009-11-18 12:38:02 +080017818 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017819 bits = present ? 0 : PIN_OUT;
17820 snd_hda_codec_write(codec, 0x14, 0,
17821 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17822}
17823
17824static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17825{
17826 unsigned int present1, present2;
17827
Wu Fengguang864f92b2009-11-18 12:38:02 +080017828 present1 = snd_hda_jack_detect(codec, 0x21);
17829 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017830
17831 if (present1 || present2) {
17832 snd_hda_codec_write_cache(codec, 0x14, 0,
17833 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17834 } else {
17835 snd_hda_codec_write_cache(codec, 0x14, 0,
17836 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17837 }
17838}
17839
17840static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17841{
17842 unsigned int present1, present2;
17843
Wu Fengguang864f92b2009-11-18 12:38:02 +080017844 present1 = snd_hda_jack_detect(codec, 0x1b);
17845 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017846
17847 if (present1 || present2) {
17848 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017849 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017850 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017851 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017852 } else {
17853 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017854 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017855 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017856 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017857 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017858}
17859
Kailang Yangebb83ee2009-12-17 12:23:00 +010017860static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17861{
17862 unsigned int present1, present2;
17863
17864 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17865 AC_VERB_GET_PIN_SENSE, 0)
17866 & AC_PINSENSE_PRESENCE;
17867 present2 = snd_hda_codec_read(codec, 0x21, 0,
17868 AC_VERB_GET_PIN_SENSE, 0)
17869 & AC_PINSENSE_PRESENCE;
17870
17871 if (present1 || present2) {
17872 snd_hda_codec_write_cache(codec, 0x14, 0,
17873 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17874 snd_hda_codec_write_cache(codec, 0x17, 0,
17875 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17876 } else {
17877 snd_hda_codec_write_cache(codec, 0x14, 0,
17878 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17879 snd_hda_codec_write_cache(codec, 0x17, 0,
17880 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17881 }
17882}
17883
17884static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17885{
17886 unsigned int present1, present2;
17887
17888 present1 = snd_hda_codec_read(codec, 0x21, 0,
17889 AC_VERB_GET_PIN_SENSE, 0)
17890 & AC_PINSENSE_PRESENCE;
17891 present2 = snd_hda_codec_read(codec, 0x15, 0,
17892 AC_VERB_GET_PIN_SENSE, 0)
17893 & AC_PINSENSE_PRESENCE;
17894
17895 if (present1 || present2) {
17896 snd_hda_codec_write_cache(codec, 0x14, 0,
17897 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17898 snd_hda_codec_write_cache(codec, 0x17, 0,
17899 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17900 } else {
17901 snd_hda_codec_write_cache(codec, 0x14, 0,
17902 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17903 snd_hda_codec_write_cache(codec, 0x17, 0,
17904 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17905 }
17906}
17907
Kailang Yang6dda9f42008-05-27 12:05:31 +020017908static void alc663_m51va_unsol_event(struct hda_codec *codec,
17909 unsigned int res)
17910{
17911 switch (res >> 26) {
17912 case ALC880_HP_EVENT:
17913 alc663_m51va_speaker_automute(codec);
17914 break;
17915 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017916 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017917 break;
17918 }
17919}
17920
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017921static void alc663_m51va_setup(struct hda_codec *codec)
17922{
17923 struct alc_spec *spec = codec->spec;
17924 spec->ext_mic.pin = 0x18;
17925 spec->ext_mic.mux_idx = 0;
17926 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017927 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017928 spec->auto_mic = 1;
17929}
17930
Kailang Yang6dda9f42008-05-27 12:05:31 +020017931static void alc663_m51va_inithook(struct hda_codec *codec)
17932{
17933 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017934 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017935}
17936
Kailang Yangf1d4e282008-08-26 14:03:29 +020017937/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017938#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017939
17940static void alc663_mode1_setup(struct hda_codec *codec)
17941{
17942 struct alc_spec *spec = codec->spec;
17943 spec->ext_mic.pin = 0x18;
17944 spec->ext_mic.mux_idx = 0;
17945 spec->int_mic.pin = 0x19;
17946 spec->int_mic.mux_idx = 1;
17947 spec->auto_mic = 1;
17948}
17949
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017950#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017951
Kailang Yangf1d4e282008-08-26 14:03:29 +020017952/* ***************** Mode2 ******************************/
17953static void alc662_mode2_unsol_event(struct hda_codec *codec,
17954 unsigned int res)
17955{
17956 switch (res >> 26) {
17957 case ALC880_HP_EVENT:
17958 alc662_f5z_speaker_automute(codec);
17959 break;
17960 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017961 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017962 break;
17963 }
17964}
17965
Kailang Yangebb83ee2009-12-17 12:23:00 +010017966#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017967
Kailang Yangf1d4e282008-08-26 14:03:29 +020017968static void alc662_mode2_inithook(struct hda_codec *codec)
17969{
17970 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017971 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017972}
17973/* ***************** Mode3 ******************************/
17974static void alc663_mode3_unsol_event(struct hda_codec *codec,
17975 unsigned int res)
17976{
17977 switch (res >> 26) {
17978 case ALC880_HP_EVENT:
17979 alc663_two_hp_m1_speaker_automute(codec);
17980 break;
17981 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017982 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017983 break;
17984 }
17985}
17986
Kailang Yangebb83ee2009-12-17 12:23:00 +010017987#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017988
Kailang Yangf1d4e282008-08-26 14:03:29 +020017989static void alc663_mode3_inithook(struct hda_codec *codec)
17990{
17991 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017992 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017993}
17994/* ***************** Mode4 ******************************/
17995static void alc663_mode4_unsol_event(struct hda_codec *codec,
17996 unsigned int res)
17997{
17998 switch (res >> 26) {
17999 case ALC880_HP_EVENT:
18000 alc663_21jd_two_speaker_automute(codec);
18001 break;
18002 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018003 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018004 break;
18005 }
18006}
18007
Kailang Yangebb83ee2009-12-17 12:23:00 +010018008#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018009
Kailang Yangf1d4e282008-08-26 14:03:29 +020018010static void alc663_mode4_inithook(struct hda_codec *codec)
18011{
18012 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018013 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018014}
18015/* ***************** Mode5 ******************************/
18016static void alc663_mode5_unsol_event(struct hda_codec *codec,
18017 unsigned int res)
18018{
18019 switch (res >> 26) {
18020 case ALC880_HP_EVENT:
18021 alc663_15jd_two_speaker_automute(codec);
18022 break;
18023 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018024 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018025 break;
18026 }
18027}
18028
Kailang Yangebb83ee2009-12-17 12:23:00 +010018029#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018030
Kailang Yangf1d4e282008-08-26 14:03:29 +020018031static void alc663_mode5_inithook(struct hda_codec *codec)
18032{
18033 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018034 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018035}
18036/* ***************** Mode6 ******************************/
18037static void alc663_mode6_unsol_event(struct hda_codec *codec,
18038 unsigned int res)
18039{
18040 switch (res >> 26) {
18041 case ALC880_HP_EVENT:
18042 alc663_two_hp_m2_speaker_automute(codec);
18043 break;
18044 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018045 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018046 break;
18047 }
18048}
18049
Kailang Yangebb83ee2009-12-17 12:23:00 +010018050#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018051
Kailang Yangf1d4e282008-08-26 14:03:29 +020018052static void alc663_mode6_inithook(struct hda_codec *codec)
18053{
18054 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018055 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018056}
18057
Kailang Yangebb83ee2009-12-17 12:23:00 +010018058/* ***************** Mode7 ******************************/
18059static void alc663_mode7_unsol_event(struct hda_codec *codec,
18060 unsigned int res)
18061{
18062 switch (res >> 26) {
18063 case ALC880_HP_EVENT:
18064 alc663_two_hp_m7_speaker_automute(codec);
18065 break;
18066 case ALC880_MIC_EVENT:
18067 alc_mic_automute(codec);
18068 break;
18069 }
18070}
18071
18072#define alc663_mode7_setup alc663_mode1_setup
18073
18074static void alc663_mode7_inithook(struct hda_codec *codec)
18075{
18076 alc663_two_hp_m7_speaker_automute(codec);
18077 alc_mic_automute(codec);
18078}
18079
18080/* ***************** Mode8 ******************************/
18081static void alc663_mode8_unsol_event(struct hda_codec *codec,
18082 unsigned int res)
18083{
18084 switch (res >> 26) {
18085 case ALC880_HP_EVENT:
18086 alc663_two_hp_m8_speaker_automute(codec);
18087 break;
18088 case ALC880_MIC_EVENT:
18089 alc_mic_automute(codec);
18090 break;
18091 }
18092}
18093
18094#define alc663_mode8_setup alc663_m51va_setup
18095
18096static void alc663_mode8_inithook(struct hda_codec *codec)
18097{
18098 alc663_two_hp_m8_speaker_automute(codec);
18099 alc_mic_automute(codec);
18100}
18101
Kailang Yang6dda9f42008-05-27 12:05:31 +020018102static void alc663_g71v_hp_automute(struct hda_codec *codec)
18103{
18104 unsigned int present;
18105 unsigned char bits;
18106
Wu Fengguang864f92b2009-11-18 12:38:02 +080018107 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018108 bits = present ? HDA_AMP_MUTE : 0;
18109 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18110 HDA_AMP_MUTE, bits);
18111 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18112 HDA_AMP_MUTE, bits);
18113}
18114
18115static void alc663_g71v_front_automute(struct hda_codec *codec)
18116{
18117 unsigned int present;
18118 unsigned char bits;
18119
Wu Fengguang864f92b2009-11-18 12:38:02 +080018120 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018121 bits = present ? HDA_AMP_MUTE : 0;
18122 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18123 HDA_AMP_MUTE, bits);
18124}
18125
18126static void alc663_g71v_unsol_event(struct hda_codec *codec,
18127 unsigned int res)
18128{
18129 switch (res >> 26) {
18130 case ALC880_HP_EVENT:
18131 alc663_g71v_hp_automute(codec);
18132 break;
18133 case ALC880_FRONT_EVENT:
18134 alc663_g71v_front_automute(codec);
18135 break;
18136 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018137 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018138 break;
18139 }
18140}
18141
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018142#define alc663_g71v_setup alc663_m51va_setup
18143
Kailang Yang6dda9f42008-05-27 12:05:31 +020018144static void alc663_g71v_inithook(struct hda_codec *codec)
18145{
18146 alc663_g71v_front_automute(codec);
18147 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018148 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018149}
18150
18151static void alc663_g50v_unsol_event(struct hda_codec *codec,
18152 unsigned int res)
18153{
18154 switch (res >> 26) {
18155 case ALC880_HP_EVENT:
18156 alc663_m51va_speaker_automute(codec);
18157 break;
18158 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018159 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018160 break;
18161 }
18162}
18163
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018164#define alc663_g50v_setup alc663_m51va_setup
18165
Kailang Yang6dda9f42008-05-27 12:05:31 +020018166static void alc663_g50v_inithook(struct hda_codec *codec)
18167{
18168 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018169 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018170}
18171
Kailang Yangf1d4e282008-08-26 14:03:29 +020018172static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18173 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018174 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018175
18176 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18177 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18178 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18179
18180 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18181 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18182 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18183 { } /* end */
18184};
18185
Chris Pockelé9541ba12009-05-12 08:08:53 +020018186static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18187 /* Master Playback automatically created from Speaker and Headphone */
18188 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18189 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18190 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18191 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18192
18193 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18194 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18195 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18196
18197 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18198 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18199 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18200 { } /* end */
18201};
18202
Takashi Iwaicb53c622007-08-10 17:21:45 +020018203#ifdef CONFIG_SND_HDA_POWER_SAVE
18204#define alc662_loopbacks alc880_loopbacks
18205#endif
18206
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018207
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018208/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018209#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18210#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18211#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18212#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18213
18214/*
18215 * configuration and preset
18216 */
18217static const char *alc662_models[ALC662_MODEL_LAST] = {
18218 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18219 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18220 [ALC662_3ST_6ch] = "3stack-6ch",
18221 [ALC662_5ST_DIG] = "6stack-dig",
18222 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018223 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018224 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018225 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018226 [ALC663_ASUS_M51VA] = "m51va",
18227 [ALC663_ASUS_G71V] = "g71v",
18228 [ALC663_ASUS_H13] = "h13",
18229 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018230 [ALC663_ASUS_MODE1] = "asus-mode1",
18231 [ALC662_ASUS_MODE2] = "asus-mode2",
18232 [ALC663_ASUS_MODE3] = "asus-mode3",
18233 [ALC663_ASUS_MODE4] = "asus-mode4",
18234 [ALC663_ASUS_MODE5] = "asus-mode5",
18235 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018236 [ALC663_ASUS_MODE7] = "asus-mode7",
18237 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018238 [ALC272_DELL] = "dell",
18239 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018240 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018241 [ALC662_AUTO] = "auto",
18242};
18243
18244static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018245 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018246 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18247 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018248 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18249 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018250 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018251 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18252 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18253 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18254 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018255 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18256 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018257 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018258 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18259 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18260 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18261 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18262 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018263 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018264 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18265 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018266 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18267 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18268 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18269 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018270 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018271 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18272 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18273 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018274 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18275 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18276 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18277 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018278 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018279 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18280 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018281 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018282 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18283 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18284 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018285 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018286 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018287 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18288 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018289 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18290 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18291 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018292 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018293 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18294 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018295 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018296 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018297 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018298 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18299 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18300 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018301 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018302 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18303 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018304 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018305 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018306 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018307 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018308 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18309 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018310 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018311 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018312 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18313 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018314 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018315 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018316 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018317 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018318 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018319 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018320 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18321 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018322 {}
18323};
18324
18325static struct alc_config_preset alc662_presets[] = {
18326 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018327 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018328 .init_verbs = { alc662_init_verbs },
18329 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18330 .dac_nids = alc662_dac_nids,
18331 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018332 .dig_in_nid = ALC662_DIGIN_NID,
18333 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18334 .channel_mode = alc662_3ST_2ch_modes,
18335 .input_mux = &alc662_capture_source,
18336 },
18337 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018338 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018339 .init_verbs = { alc662_init_verbs },
18340 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18341 .dac_nids = alc662_dac_nids,
18342 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018343 .dig_in_nid = ALC662_DIGIN_NID,
18344 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18345 .channel_mode = alc662_3ST_6ch_modes,
18346 .need_dac_fix = 1,
18347 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018348 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018349 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018350 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018351 .init_verbs = { alc662_init_verbs },
18352 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18353 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018354 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18355 .channel_mode = alc662_3ST_6ch_modes,
18356 .need_dac_fix = 1,
18357 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018358 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018359 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018360 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018361 .init_verbs = { alc662_init_verbs },
18362 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18363 .dac_nids = alc662_dac_nids,
18364 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018365 .dig_in_nid = ALC662_DIGIN_NID,
18366 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18367 .channel_mode = alc662_5stack_modes,
18368 .input_mux = &alc662_capture_source,
18369 },
18370 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018371 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018372 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18373 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18374 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018375 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18376 .channel_mode = alc662_3ST_2ch_modes,
18377 .input_mux = &alc662_lenovo_101e_capture_source,
18378 .unsol_event = alc662_lenovo_101e_unsol_event,
18379 .init_hook = alc662_lenovo_101e_all_automute,
18380 },
Kailang Yang291702f2007-10-16 14:28:03 +020018381 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018382 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018383 .init_verbs = { alc662_init_verbs,
18384 alc662_eeepc_sue_init_verbs },
18385 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18386 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018387 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18388 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018389 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018390 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018391 .init_hook = alc662_eeepc_inithook,
18392 },
Kailang Yang8c427222008-01-10 13:03:59 +010018393 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018394 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018395 alc662_chmode_mixer },
18396 .init_verbs = { alc662_init_verbs,
18397 alc662_eeepc_ep20_sue_init_verbs },
18398 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18399 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018400 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18401 .channel_mode = alc662_3ST_6ch_modes,
18402 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018403 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018404 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018405 .init_hook = alc662_eeepc_ep20_inithook,
18406 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018407 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018408 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018409 .init_verbs = { alc662_init_verbs,
18410 alc662_ecs_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 Yangf1d4e282008-08-26 14:03:29 +020018415 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018416 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018417 .init_hook = alc662_eeepc_inithook,
18418 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018419 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018420 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018421 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18422 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18423 .dac_nids = alc662_dac_nids,
18424 .dig_out_nid = ALC662_DIGOUT_NID,
18425 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18426 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018427 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018428 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018429 .init_hook = alc663_m51va_inithook,
18430 },
18431 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018432 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018433 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18434 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18435 .dac_nids = alc662_dac_nids,
18436 .dig_out_nid = ALC662_DIGOUT_NID,
18437 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18438 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018439 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018440 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018441 .init_hook = alc663_g71v_inithook,
18442 },
18443 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018444 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018445 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18446 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18447 .dac_nids = alc662_dac_nids,
18448 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18449 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018450 .unsol_event = alc663_m51va_unsol_event,
18451 .init_hook = alc663_m51va_inithook,
18452 },
18453 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018454 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018455 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18456 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18457 .dac_nids = alc662_dac_nids,
18458 .dig_out_nid = ALC662_DIGOUT_NID,
18459 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18460 .channel_mode = alc662_3ST_6ch_modes,
18461 .input_mux = &alc663_capture_source,
18462 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018463 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018464 .init_hook = alc663_g50v_inithook,
18465 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018466 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018467 .mixers = { alc663_m51va_mixer },
18468 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018469 .init_verbs = { alc662_init_verbs,
18470 alc663_21jd_amic_init_verbs },
18471 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18472 .hp_nid = 0x03,
18473 .dac_nids = alc662_dac_nids,
18474 .dig_out_nid = ALC662_DIGOUT_NID,
18475 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18476 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018477 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018478 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018479 .init_hook = alc663_mode1_inithook,
18480 },
18481 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018482 .mixers = { alc662_1bjd_mixer },
18483 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018484 .init_verbs = { alc662_init_verbs,
18485 alc662_1bjd_amic_init_verbs },
18486 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18487 .dac_nids = alc662_dac_nids,
18488 .dig_out_nid = ALC662_DIGOUT_NID,
18489 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18490 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018491 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018492 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018493 .init_hook = alc662_mode2_inithook,
18494 },
18495 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018496 .mixers = { alc663_two_hp_m1_mixer },
18497 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018498 .init_verbs = { alc662_init_verbs,
18499 alc663_two_hp_amic_m1_init_verbs },
18500 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18501 .hp_nid = 0x03,
18502 .dac_nids = alc662_dac_nids,
18503 .dig_out_nid = ALC662_DIGOUT_NID,
18504 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18505 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018506 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018507 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018508 .init_hook = alc663_mode3_inithook,
18509 },
18510 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018511 .mixers = { alc663_asus_21jd_clfe_mixer },
18512 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018513 .init_verbs = { alc662_init_verbs,
18514 alc663_21jd_amic_init_verbs},
18515 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18516 .hp_nid = 0x03,
18517 .dac_nids = alc662_dac_nids,
18518 .dig_out_nid = ALC662_DIGOUT_NID,
18519 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18520 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018521 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018522 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018523 .init_hook = alc663_mode4_inithook,
18524 },
18525 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018526 .mixers = { alc663_asus_15jd_clfe_mixer },
18527 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018528 .init_verbs = { alc662_init_verbs,
18529 alc663_15jd_amic_init_verbs },
18530 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18531 .hp_nid = 0x03,
18532 .dac_nids = alc662_dac_nids,
18533 .dig_out_nid = ALC662_DIGOUT_NID,
18534 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18535 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018536 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018537 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018538 .init_hook = alc663_mode5_inithook,
18539 },
18540 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018541 .mixers = { alc663_two_hp_m2_mixer },
18542 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018543 .init_verbs = { alc662_init_verbs,
18544 alc663_two_hp_amic_m2_init_verbs },
18545 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18546 .hp_nid = 0x03,
18547 .dac_nids = alc662_dac_nids,
18548 .dig_out_nid = ALC662_DIGOUT_NID,
18549 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18550 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018551 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018552 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018553 .init_hook = alc663_mode6_inithook,
18554 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018555 [ALC663_ASUS_MODE7] = {
18556 .mixers = { alc663_mode7_mixer },
18557 .cap_mixer = alc662_auto_capture_mixer,
18558 .init_verbs = { alc662_init_verbs,
18559 alc663_mode7_init_verbs },
18560 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18561 .hp_nid = 0x03,
18562 .dac_nids = alc662_dac_nids,
18563 .dig_out_nid = ALC662_DIGOUT_NID,
18564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18565 .channel_mode = alc662_3ST_2ch_modes,
18566 .unsol_event = alc663_mode7_unsol_event,
18567 .setup = alc663_mode7_setup,
18568 .init_hook = alc663_mode7_inithook,
18569 },
18570 [ALC663_ASUS_MODE8] = {
18571 .mixers = { alc663_mode8_mixer },
18572 .cap_mixer = alc662_auto_capture_mixer,
18573 .init_verbs = { alc662_init_verbs,
18574 alc663_mode8_init_verbs },
18575 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18576 .hp_nid = 0x03,
18577 .dac_nids = alc662_dac_nids,
18578 .dig_out_nid = ALC662_DIGOUT_NID,
18579 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18580 .channel_mode = alc662_3ST_2ch_modes,
18581 .unsol_event = alc663_mode8_unsol_event,
18582 .setup = alc663_mode8_setup,
18583 .init_hook = alc663_mode8_inithook,
18584 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018585 [ALC272_DELL] = {
18586 .mixers = { alc663_m51va_mixer },
18587 .cap_mixer = alc272_auto_capture_mixer,
18588 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18589 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18590 .dac_nids = alc662_dac_nids,
18591 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18592 .adc_nids = alc272_adc_nids,
18593 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18594 .capsrc_nids = alc272_capsrc_nids,
18595 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018596 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018597 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018598 .init_hook = alc663_m51va_inithook,
18599 },
18600 [ALC272_DELL_ZM1] = {
18601 .mixers = { alc663_m51va_mixer },
18602 .cap_mixer = alc662_auto_capture_mixer,
18603 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18604 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18605 .dac_nids = alc662_dac_nids,
18606 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18607 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018608 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018609 .capsrc_nids = alc662_capsrc_nids,
18610 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018611 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018612 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018613 .init_hook = alc663_m51va_inithook,
18614 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018615 [ALC272_SAMSUNG_NC10] = {
18616 .mixers = { alc272_nc10_mixer },
18617 .init_verbs = { alc662_init_verbs,
18618 alc663_21jd_amic_init_verbs },
18619 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18620 .dac_nids = alc272_dac_nids,
18621 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18622 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018623 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018624 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018625 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018626 .init_hook = alc663_mode4_inithook,
18627 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018628};
18629
18630
18631/*
18632 * BIOS auto configuration
18633 */
18634
Takashi Iwai7085ec12009-10-02 09:03:58 +020018635/* convert from MIX nid to DAC */
18636static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18637{
18638 if (nid == 0x0f)
18639 return 0x02;
18640 else if (nid >= 0x0c && nid <= 0x0e)
18641 return nid - 0x0c + 0x02;
18642 else
18643 return 0;
18644}
18645
18646/* get MIX nid connected to the given pin targeted to DAC */
18647static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18648 hda_nid_t dac)
18649{
18650 hda_nid_t mix[4];
18651 int i, num;
18652
18653 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18654 for (i = 0; i < num; i++) {
18655 if (alc662_mix_to_dac(mix[i]) == dac)
18656 return mix[i];
18657 }
18658 return 0;
18659}
18660
18661/* look for an empty DAC slot */
18662static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18663{
18664 struct alc_spec *spec = codec->spec;
18665 hda_nid_t srcs[5];
18666 int i, j, num;
18667
18668 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18669 if (num < 0)
18670 return 0;
18671 for (i = 0; i < num; i++) {
18672 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18673 if (!nid)
18674 continue;
18675 for (j = 0; j < spec->multiout.num_dacs; j++)
18676 if (spec->multiout.dac_nids[j] == nid)
18677 break;
18678 if (j >= spec->multiout.num_dacs)
18679 return nid;
18680 }
18681 return 0;
18682}
18683
18684/* fill in the dac_nids table from the parsed pin configuration */
18685static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18686 const struct auto_pin_cfg *cfg)
18687{
18688 struct alc_spec *spec = codec->spec;
18689 int i;
18690 hda_nid_t dac;
18691
18692 spec->multiout.dac_nids = spec->private_dac_nids;
18693 for (i = 0; i < cfg->line_outs; i++) {
18694 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18695 if (!dac)
18696 continue;
18697 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18698 }
18699 return 0;
18700}
18701
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018702static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018703 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018704{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018705 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018706 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18707}
18708
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018709static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018710 hda_nid_t nid, unsigned int chs)
18711{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018712 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018713 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18714}
18715
18716#define alc662_add_stereo_vol(spec, pfx, nid) \
18717 alc662_add_vol_ctl(spec, pfx, nid, 3)
18718#define alc662_add_stereo_sw(spec, pfx, nid) \
18719 alc662_add_sw_ctl(spec, pfx, nid, 3)
18720
18721/* add playback controls from the parsed DAC table */
18722static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18723 const struct auto_pin_cfg *cfg)
18724{
18725 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018726 static const char *chname[4] = {
18727 "Front", "Surround", NULL /*CLFE*/, "Side"
18728 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018729 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018730 int i, err;
18731
18732 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018733 nid = spec->multiout.dac_nids[i];
18734 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018735 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018736 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18737 if (!mix)
18738 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018739 if (i == 2) {
18740 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018741 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018742 if (err < 0)
18743 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018744 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018745 if (err < 0)
18746 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018747 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018748 if (err < 0)
18749 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018750 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018751 if (err < 0)
18752 return err;
18753 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018754 const char *pfx;
18755 if (cfg->line_outs == 1 &&
18756 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018757 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018758 pfx = "Speaker";
18759 else
18760 pfx = "PCM";
18761 } else
18762 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018763 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018764 if (err < 0)
18765 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018766 if (cfg->line_outs == 1 &&
18767 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18768 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018769 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018770 if (err < 0)
18771 return err;
18772 }
18773 }
18774 return 0;
18775}
18776
18777/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018778/* return DAC nid if any new DAC is assigned */
18779static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018780 const char *pfx)
18781{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018782 struct alc_spec *spec = codec->spec;
18783 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018784 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018785
18786 if (!pin)
18787 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018788 nid = alc662_look_for_dac(codec, pin);
18789 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018790 /* the corresponding DAC is already occupied */
18791 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18792 return 0; /* no way */
18793 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018794 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018795 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18796 }
18797
18798 mix = alc662_dac_to_mix(codec, pin, nid);
18799 if (!mix)
18800 return 0;
18801 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18802 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018803 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018804 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18805 if (err < 0)
18806 return err;
18807 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018808}
18809
18810/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018811#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018812 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018813
18814static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18815 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018816 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018817{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018818 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020018819 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018820
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018821 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018822 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018823 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18824 if (num <= 1)
18825 return;
18826 for (i = 0; i < num; i++) {
18827 if (alc662_mix_to_dac(srcs[i]) != dac)
18828 continue;
18829 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18830 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018831 }
18832}
18833
18834static void alc662_auto_init_multi_out(struct hda_codec *codec)
18835{
18836 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018837 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018838 int i;
18839
18840 for (i = 0; i <= HDA_SIDE; i++) {
18841 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18842 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018843 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018844 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018845 }
18846}
18847
18848static void alc662_auto_init_hp_out(struct hda_codec *codec)
18849{
18850 struct alc_spec *spec = codec->spec;
18851 hda_nid_t pin;
18852
18853 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018854 if (pin)
18855 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18856 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018857 pin = spec->autocfg.speaker_pins[0];
18858 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018859 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18860 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018861}
18862
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018863#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18864
18865static void alc662_auto_init_analog_input(struct hda_codec *codec)
18866{
18867 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020018868 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018869 int i;
18870
Takashi Iwai66ceeb62010-08-30 13:05:52 +020018871 for (i = 0; i < cfg->num_inputs; i++) {
18872 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018873 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018874 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018875 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018876 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018877 snd_hda_codec_write(codec, nid, 0,
18878 AC_VERB_SET_AMP_GAIN_MUTE,
18879 AMP_OUT_MUTE);
18880 }
18881 }
18882}
18883
Takashi Iwaif511b012008-08-15 16:46:42 +020018884#define alc662_auto_init_input_src alc882_auto_init_input_src
18885
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018886static int alc662_parse_auto_config(struct hda_codec *codec)
18887{
18888 struct alc_spec *spec = codec->spec;
18889 int err;
18890 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18891
18892 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18893 alc662_ignore);
18894 if (err < 0)
18895 return err;
18896 if (!spec->autocfg.line_outs)
18897 return 0; /* can't find valid BIOS pin config */
18898
Takashi Iwai7085ec12009-10-02 09:03:58 +020018899 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018900 if (err < 0)
18901 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018902 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018903 if (err < 0)
18904 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018905 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018906 spec->autocfg.speaker_pins[0],
18907 "Speaker");
18908 if (err < 0)
18909 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018910 if (err)
18911 spec->multiout.extra_out_nid[0] = err;
18912 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018913 "Headphone");
18914 if (err < 0)
18915 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018916 if (err)
18917 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018918 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018919 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018920 return err;
18921
18922 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18923
Takashi Iwai757899a2010-07-30 10:48:14 +020018924 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018925
Takashi Iwai603c4012008-07-30 15:01:44 +020018926 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018927 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018928
18929 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018930 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018931
Kailang Yangcec27c82010-02-04 14:18:18 +010018932 add_verb(spec, alc662_init_verbs);
18933 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020018934 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010018935 add_verb(spec, alc663_init_verbs);
18936
18937 if (codec->vendor_id == 0x10ec0272)
18938 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018939
18940 err = alc_auto_add_mic_boost(codec);
18941 if (err < 0)
18942 return err;
18943
Kailang Yang6227cdc2010-02-25 08:36:52 +010018944 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18945 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18946 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18947 else
18948 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018949
Takashi Iwai8c872862007-06-19 12:11:16 +020018950 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018951}
18952
18953/* additional initialization for auto-configuration model */
18954static void alc662_auto_init(struct hda_codec *codec)
18955{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018956 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018957 alc662_auto_init_multi_out(codec);
18958 alc662_auto_init_hp_out(codec);
18959 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018960 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020018961 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018962 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018963 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018964}
18965
David Henningsson6cb3b702010-09-09 08:51:44 +020018966enum {
18967 ALC662_FIXUP_IDEAPAD,
18968};
18969
18970static const struct alc_fixup alc662_fixups[] = {
18971 [ALC662_FIXUP_IDEAPAD] = {
18972 .pins = (const struct alc_pincfg[]) {
18973 { 0x17, 0x99130112 }, /* subwoofer */
18974 { }
18975 }
18976 },
18977};
18978
18979static struct snd_pci_quirk alc662_fixup_tbl[] = {
18980 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
18981 {}
18982};
18983
18984
18985
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018986static int patch_alc662(struct hda_codec *codec)
18987{
18988 struct alc_spec *spec;
18989 int err, board_config;
18990
18991 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18992 if (!spec)
18993 return -ENOMEM;
18994
18995 codec->spec = spec;
18996
Kailang Yangda00c242010-03-19 11:23:45 +010018997 alc_auto_parse_customize_define(codec);
18998
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018999 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19000
Kailang Yangc027ddc2010-03-19 11:33:06 +010019001 if (alc_read_coef_idx(codec, 0) == 0x8020)
19002 alc_codec_rename(codec, "ALC661");
19003 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
19004 codec->bus->pci->subsystem_vendor == 0x1025 &&
19005 spec->cdefine.platform_type == 1)
19006 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010019007
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019008 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19009 alc662_models,
19010 alc662_cfg_tbl);
19011 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019012 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19013 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019014 board_config = ALC662_AUTO;
19015 }
19016
19017 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019018 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019019 /* automatic parse from the BIOS config */
19020 err = alc662_parse_auto_config(codec);
19021 if (err < 0) {
19022 alc_free(codec);
19023 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020019024 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019025 printk(KERN_INFO
19026 "hda_codec: Cannot set up configuration "
19027 "from BIOS. Using base mode...\n");
19028 board_config = ALC662_3ST_2ch_DIG;
19029 }
19030 }
19031
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019032 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019033 err = snd_hda_attach_beep_device(codec, 0x1);
19034 if (err < 0) {
19035 alc_free(codec);
19036 return err;
19037 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019038 }
19039
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019040 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019041 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019042
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019043 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19044 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19045
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019046 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19047 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19048
Takashi Iwaidd704692009-08-11 08:45:11 +020019049 if (!spec->adc_nids) {
19050 spec->adc_nids = alc662_adc_nids;
19051 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19052 }
19053 if (!spec->capsrc_nids)
19054 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019055
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019056 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019057 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019058
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019059 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019060 switch (codec->vendor_id) {
19061 case 0x10ec0662:
19062 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19063 break;
19064 case 0x10ec0272:
19065 case 0x10ec0663:
19066 case 0x10ec0665:
19067 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19068 break;
19069 case 0x10ec0273:
19070 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19071 break;
19072 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019073 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019074 spec->vmaster_nid = 0x02;
19075
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019077 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019079 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19080 }
19081
Takashi Iwaicb53c622007-08-10 17:21:45 +020019082#ifdef CONFIG_SND_HDA_POWER_SAVE
19083 if (!spec->loopback.amplist)
19084 spec->loopback.amplist = alc662_loopbacks;
19085#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019086
19087 return 0;
19088}
19089
Kailang Yang274693f2009-12-03 10:07:50 +010019090static int patch_alc888(struct hda_codec *codec)
19091{
19092 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19093 kfree(codec->chip_name);
19094 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019095 if (!codec->chip_name) {
19096 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019097 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019098 }
19099 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019100 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019101 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019102}
19103
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019104/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019105 * ALC680 support
19106 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019107#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019108#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19109#define alc680_modes alc260_modes
19110
19111static hda_nid_t alc680_dac_nids[3] = {
19112 /* Lout1, Lout2, hp */
19113 0x02, 0x03, 0x04
19114};
19115
19116static hda_nid_t alc680_adc_nids[3] = {
19117 /* ADC0-2 */
19118 /* DMIC, MIC, Line-in*/
19119 0x07, 0x08, 0x09
19120};
19121
Kailang Yangc69aefa2010-08-17 10:39:22 +020019122/*
19123 * Analog capture ADC cgange
19124 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019125static void alc680_rec_autoswitch(struct hda_codec *codec)
19126{
19127 struct alc_spec *spec = codec->spec;
19128 struct auto_pin_cfg *cfg = &spec->autocfg;
19129 int pin_found = 0;
19130 int type_found = AUTO_PIN_LAST;
19131 hda_nid_t nid;
19132 int i;
19133
19134 for (i = 0; i < cfg->num_inputs; i++) {
19135 nid = cfg->inputs[i].pin;
19136 if (!(snd_hda_query_pin_caps(codec, nid) &
19137 AC_PINCAP_PRES_DETECT))
19138 continue;
19139 if (snd_hda_jack_detect(codec, nid)) {
19140 if (cfg->inputs[i].type < type_found) {
19141 type_found = cfg->inputs[i].type;
19142 pin_found = nid;
19143 }
19144 }
19145 }
19146
19147 nid = 0x07;
19148 if (pin_found)
19149 snd_hda_get_connections(codec, pin_found, &nid, 1);
19150
19151 if (nid != spec->cur_adc)
19152 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19153 spec->cur_adc = nid;
19154 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19155 spec->cur_adc_format);
19156}
19157
Kailang Yangc69aefa2010-08-17 10:39:22 +020019158static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19159 struct hda_codec *codec,
19160 unsigned int stream_tag,
19161 unsigned int format,
19162 struct snd_pcm_substream *substream)
19163{
19164 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019165
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019166 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019167 spec->cur_adc_stream_tag = stream_tag;
19168 spec->cur_adc_format = format;
19169
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019170 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019171 return 0;
19172}
19173
19174static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19175 struct hda_codec *codec,
19176 struct snd_pcm_substream *substream)
19177{
19178 snd_hda_codec_cleanup_stream(codec, 0x07);
19179 snd_hda_codec_cleanup_stream(codec, 0x08);
19180 snd_hda_codec_cleanup_stream(codec, 0x09);
19181 return 0;
19182}
19183
19184static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19185 .substreams = 1, /* can be overridden */
19186 .channels_min = 2,
19187 .channels_max = 2,
19188 /* NID is set in alc_build_pcms */
19189 .ops = {
19190 .prepare = alc680_capture_pcm_prepare,
19191 .cleanup = alc680_capture_pcm_cleanup
19192 },
19193};
19194
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019195static struct snd_kcontrol_new alc680_base_mixer[] = {
19196 /* output mixer control */
19197 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19198 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19199 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019201 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019202 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019203 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019204 { }
19205};
19206
Kailang Yangc69aefa2010-08-17 10:39:22 +020019207static struct hda_bind_ctls alc680_bind_cap_vol = {
19208 .ops = &snd_hda_bind_vol,
19209 .values = {
19210 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19211 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19212 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19213 0
19214 },
19215};
19216
19217static struct hda_bind_ctls alc680_bind_cap_switch = {
19218 .ops = &snd_hda_bind_sw,
19219 .values = {
19220 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19221 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19222 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19223 0
19224 },
19225};
19226
19227static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19228 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19229 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019230 { } /* end */
19231};
19232
19233/*
19234 * generic initialization of ADC, input mixers and output mixers
19235 */
19236static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019237 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19238 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19239 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019240
Kailang Yangc69aefa2010-08-17 10:39:22 +020019241 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19243 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19244 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19245 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19246 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019247
19248 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19249 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19250 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19251 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19252 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019253
19254 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19255 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019256 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019257
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019258 { }
19259};
19260
Kailang Yangc69aefa2010-08-17 10:39:22 +020019261/* toggle speaker-output according to the hp-jack state */
19262static void alc680_base_setup(struct hda_codec *codec)
19263{
19264 struct alc_spec *spec = codec->spec;
19265
19266 spec->autocfg.hp_pins[0] = 0x16;
19267 spec->autocfg.speaker_pins[0] = 0x14;
19268 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019269 spec->autocfg.num_inputs = 2;
19270 spec->autocfg.inputs[0].pin = 0x18;
19271 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19272 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019273 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019274}
19275
19276static void alc680_unsol_event(struct hda_codec *codec,
19277 unsigned int res)
19278{
19279 if ((res >> 26) == ALC880_HP_EVENT)
19280 alc_automute_amp(codec);
19281 if ((res >> 26) == ALC880_MIC_EVENT)
19282 alc680_rec_autoswitch(codec);
19283}
19284
19285static void alc680_inithook(struct hda_codec *codec)
19286{
19287 alc_automute_amp(codec);
19288 alc680_rec_autoswitch(codec);
19289}
19290
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019291/* create input playback/capture controls for the given pin */
19292static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19293 const char *ctlname, int idx)
19294{
19295 hda_nid_t dac;
19296 int err;
19297
19298 switch (nid) {
19299 case 0x14:
19300 dac = 0x02;
19301 break;
19302 case 0x15:
19303 dac = 0x03;
19304 break;
19305 case 0x16:
19306 dac = 0x04;
19307 break;
19308 default:
19309 return 0;
19310 }
19311 if (spec->multiout.dac_nids[0] != dac &&
19312 spec->multiout.dac_nids[1] != dac) {
19313 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19314 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19315 HDA_OUTPUT));
19316 if (err < 0)
19317 return err;
19318
19319 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19320 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19321
19322 if (err < 0)
19323 return err;
19324 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19325 }
19326
19327 return 0;
19328}
19329
19330/* add playback controls from the parsed DAC table */
19331static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19332 const struct auto_pin_cfg *cfg)
19333{
19334 hda_nid_t nid;
19335 int err;
19336
19337 spec->multiout.dac_nids = spec->private_dac_nids;
19338
19339 nid = cfg->line_out_pins[0];
19340 if (nid) {
19341 const char *name;
19342 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19343 name = "Speaker";
19344 else
19345 name = "Front";
19346 err = alc680_new_analog_output(spec, nid, name, 0);
19347 if (err < 0)
19348 return err;
19349 }
19350
19351 nid = cfg->speaker_pins[0];
19352 if (nid) {
19353 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19354 if (err < 0)
19355 return err;
19356 }
19357 nid = cfg->hp_pins[0];
19358 if (nid) {
19359 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19360 if (err < 0)
19361 return err;
19362 }
19363
19364 return 0;
19365}
19366
19367static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19368 hda_nid_t nid, int pin_type)
19369{
19370 alc_set_pin_output(codec, nid, pin_type);
19371}
19372
19373static void alc680_auto_init_multi_out(struct hda_codec *codec)
19374{
19375 struct alc_spec *spec = codec->spec;
19376 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19377 if (nid) {
19378 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19379 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19380 }
19381}
19382
19383static void alc680_auto_init_hp_out(struct hda_codec *codec)
19384{
19385 struct alc_spec *spec = codec->spec;
19386 hda_nid_t pin;
19387
19388 pin = spec->autocfg.hp_pins[0];
19389 if (pin)
19390 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19391 pin = spec->autocfg.speaker_pins[0];
19392 if (pin)
19393 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19394}
19395
19396/* pcm configuration: identical with ALC880 */
19397#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19398#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19399#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19400#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019401#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019402
19403/*
19404 * BIOS auto configuration
19405 */
19406static int alc680_parse_auto_config(struct hda_codec *codec)
19407{
19408 struct alc_spec *spec = codec->spec;
19409 int err;
19410 static hda_nid_t alc680_ignore[] = { 0 };
19411
19412 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19413 alc680_ignore);
19414 if (err < 0)
19415 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019416
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019417 if (!spec->autocfg.line_outs) {
19418 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19419 spec->multiout.max_channels = 2;
19420 spec->no_analog = 1;
19421 goto dig_only;
19422 }
19423 return 0; /* can't find valid BIOS pin config */
19424 }
19425 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19426 if (err < 0)
19427 return err;
19428
19429 spec->multiout.max_channels = 2;
19430
19431 dig_only:
19432 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019433 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019434 if (spec->kctls.list)
19435 add_mixer(spec, spec->kctls.list);
19436
19437 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019438
19439 err = alc_auto_add_mic_boost(codec);
19440 if (err < 0)
19441 return err;
19442
19443 return 1;
19444}
19445
19446#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19447
19448/* init callback for auto-configuration model -- overriding the default init */
19449static void alc680_auto_init(struct hda_codec *codec)
19450{
19451 struct alc_spec *spec = codec->spec;
19452 alc680_auto_init_multi_out(codec);
19453 alc680_auto_init_hp_out(codec);
19454 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019455 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019456 if (spec->unsol_event)
19457 alc_inithook(codec);
19458}
19459
19460/*
19461 * configuration and preset
19462 */
19463static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019464 [ALC680_BASE] = "base",
19465 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019466};
19467
19468static struct snd_pci_quirk alc680_cfg_tbl[] = {
19469 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19470 {}
19471};
19472
19473static struct alc_config_preset alc680_presets[] = {
19474 [ALC680_BASE] = {
19475 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019476 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019477 .init_verbs = { alc680_init_verbs },
19478 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19479 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019480 .dig_out_nid = ALC680_DIGOUT_NID,
19481 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19482 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019483 .unsol_event = alc680_unsol_event,
19484 .setup = alc680_base_setup,
19485 .init_hook = alc680_inithook,
19486
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019487 },
19488};
19489
19490static int patch_alc680(struct hda_codec *codec)
19491{
19492 struct alc_spec *spec;
19493 int board_config;
19494 int err;
19495
19496 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19497 if (spec == NULL)
19498 return -ENOMEM;
19499
19500 codec->spec = spec;
19501
19502 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19503 alc680_models,
19504 alc680_cfg_tbl);
19505
19506 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19507 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19508 codec->chip_name);
19509 board_config = ALC680_AUTO;
19510 }
19511
19512 if (board_config == ALC680_AUTO) {
19513 /* automatic parse from the BIOS config */
19514 err = alc680_parse_auto_config(codec);
19515 if (err < 0) {
19516 alc_free(codec);
19517 return err;
19518 } else if (!err) {
19519 printk(KERN_INFO
19520 "hda_codec: Cannot set up configuration "
19521 "from BIOS. Using base mode...\n");
19522 board_config = ALC680_BASE;
19523 }
19524 }
19525
19526 if (board_config != ALC680_AUTO)
19527 setup_preset(codec, &alc680_presets[board_config]);
19528
19529 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019530 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019531 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019532 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019533
19534 if (!spec->adc_nids) {
19535 spec->adc_nids = alc680_adc_nids;
19536 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19537 }
19538
19539 if (!spec->cap_mixer)
19540 set_capture_mixer(codec);
19541
19542 spec->vmaster_nid = 0x02;
19543
19544 codec->patch_ops = alc_patch_ops;
19545 if (board_config == ALC680_AUTO)
19546 spec->init_hook = alc680_auto_init;
19547
19548 return 0;
19549}
19550
19551/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019552 * patch entries
19553 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019554static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019555 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019556 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019557 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019558 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019559 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019560 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019561 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019562 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019563 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019564 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019565 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19566 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19567 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019568 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019569 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019570 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19571 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019572 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019573 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019574 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019575 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019576 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019577 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019578 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019579 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019580 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019581 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019582 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019583 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019584 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019585 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019586 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019587 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019588 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019589 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019590 {} /* terminator */
19591};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019592
19593MODULE_ALIAS("snd-hda-codec-id:10ec*");
19594
19595MODULE_LICENSE("GPL");
19596MODULE_DESCRIPTION("Realtek HD-audio codec");
19597
19598static struct hda_codec_preset_list realtek_list = {
19599 .preset = snd_hda_preset_realtek,
19600 .owner = THIS_MODULE,
19601};
19602
19603static int __init patch_realtek_init(void)
19604{
19605 return snd_hda_add_codec_preset(&realtek_list);
19606}
19607
19608static void __exit patch_realtek_exit(void)
19609{
19610 snd_hda_delete_codec_preset(&realtek_list);
19611}
19612
19613module_init(patch_realtek_init)
19614module_exit(patch_realtek_exit)