blob: a432e6efd19bbe7bbce3ad9b6607c44661f912cf [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010081 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010082#ifdef CONFIG_SND_DEBUG
83 ALC260_TEST,
84#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010085 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020086 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
Kailang Yangdf694da2005-12-05 19:42:22 +010089/* ALC262 models */
90enum {
91 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020092 ALC262_HIPPO,
93 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010094 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020095 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010096 ALC262_HP_BPC_D7000_WL,
97 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010098 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010099 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200100 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200101 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200102 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200103 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100104 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200105 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200106 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200107 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000108 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100109 ALC262_AUTO,
110 ALC262_MODEL_LAST /* last tag */
111};
112
Kailang Yanga361d842007-06-05 12:30:55 +0200113/* ALC268 models */
114enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200115 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200116 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200117 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200118 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100119 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200120 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100121 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100122 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100123#ifdef CONFIG_SND_DEBUG
124 ALC268_TEST,
125#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200126 ALC268_AUTO,
127 ALC268_MODEL_LAST /* last tag */
128};
129
Kailang Yangf6a92242007-12-13 16:52:54 +0100130/* ALC269 models */
131enum {
132 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200133 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100134 ALC269_AMIC,
135 ALC269_DMIC,
136 ALC269VB_AMIC,
137 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100138 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000139 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200140 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100141 ALC269_AUTO,
142 ALC269_MODEL_LAST /* last tag */
143};
144
Kailang Yangdf694da2005-12-05 19:42:22 +0100145/* ALC861 models */
146enum {
147 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200148 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100149 ALC861_3ST_DIG,
150 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200151 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200152 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200153 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100154 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100155 ALC861_AUTO,
156 ALC861_MODEL_LAST,
157};
158
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100159/* ALC861-VD models */
160enum {
161 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200162 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100163 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100164 ALC861VD_3ST,
165 ALC861VD_3ST_DIG,
166 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200167 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200168 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200169 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100170 ALC861VD_AUTO,
171 ALC861VD_MODEL_LAST,
172};
173
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200174/* ALC662 models */
175enum {
176 ALC662_3ST_2ch_DIG,
177 ALC662_3ST_6ch_DIG,
178 ALC662_3ST_6ch,
179 ALC662_5ST_DIG,
180 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200181 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100182 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200183 ALC663_ASUS_M51VA,
184 ALC663_ASUS_G71V,
185 ALC663_ASUS_H13,
186 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200187 ALC662_ECS,
188 ALC663_ASUS_MODE1,
189 ALC662_ASUS_MODE2,
190 ALC663_ASUS_MODE3,
191 ALC663_ASUS_MODE4,
192 ALC663_ASUS_MODE5,
193 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100194 ALC663_ASUS_MODE7,
195 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200196 ALC272_DELL,
197 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200198 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200199 ALC662_AUTO,
200 ALC662_MODEL_LAST,
201};
202
Kailang Yangdf694da2005-12-05 19:42:22 +0100203/* ALC882 models */
204enum {
205 ALC882_3ST_DIG,
206 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200207 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200208 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200209 ALC882_TARGA,
210 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200211 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100212 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800213 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200214 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200215 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100216 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200217 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800218 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200219 ALC883_3ST_2ch_DIG,
220 ALC883_3ST_6ch_DIG,
221 ALC883_3ST_6ch,
222 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200223 ALC883_TARGA_DIG,
224 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200225 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200226 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200227 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800228 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100229 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200230 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200231 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200232 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200233 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
297};
298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299struct alc_spec {
300 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100301 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100303 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100304 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200306 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200307 * don't forget NULL
308 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200309 */
310 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200312 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 struct hda_pcm_stream *stream_analog_playback;
314 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100315 struct hda_pcm_stream *stream_analog_alt_playback;
316 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200318 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 struct hda_pcm_stream *stream_digital_playback;
320 struct hda_pcm_stream *stream_digital_capture;
321
322 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200323 struct hda_multi_out multiout; /* playback set-up
324 * max_channels, dacs must be set
325 * dig_out_nid and hp_nid are optional
326 */
Takashi Iwai63300792008-01-24 15:31:36 +0100327 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100328 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100329 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
331 /* capture */
332 unsigned int num_adc_nids;
333 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100334 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200335 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Takashi Iwai840b64c2010-07-13 22:49:01 +0200337 /* capture setup for dynamic dual-adc switch */
338 unsigned int cur_adc_idx;
339 hda_nid_t cur_adc;
340 unsigned int cur_adc_stream_tag;
341 unsigned int cur_adc_format;
342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200344 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 const struct hda_input_mux *input_mux;
346 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200347 struct alc_mic_route ext_mic;
348 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
350 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100351 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200353 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200354 int const_channel_count;
355 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100358 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200359
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200360 /* dynamic controls, init_verbs and input_mux */
361 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100362 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200363 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200364 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200365 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200366 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
367 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100368
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100369 /* hooks */
370 void (*init_hook)(struct hda_codec *codec);
371 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100372#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500373 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100374#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100375
Takashi Iwai834be882006-03-01 14:16:17 +0100376 /* for pin sensing */
377 unsigned int sense_updated: 1;
378 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100379 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200380 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200381
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100382 /* other flags */
383 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200384 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200385 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100386
Takashi Iwai2134ea42008-01-10 16:53:55 +0100387 /* for virtual master */
388 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200389#ifdef CONFIG_SND_HDA_POWER_SAVE
390 struct hda_loopback_check loopback;
391#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200392
393 /* for PLL fix */
394 hda_nid_t pll_nid;
395 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100396};
397
398/*
399 * configuration template - to be copied to the spec instance
400 */
401struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200402 struct snd_kcontrol_new *mixers[5]; /* should be identical size
403 * with spec
404 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100405 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100406 const struct hda_verb *init_verbs[5];
407 unsigned int num_dacs;
408 hda_nid_t *dac_nids;
409 hda_nid_t dig_out_nid; /* optional */
410 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800411 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100412 unsigned int num_adc_nids;
413 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100414 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100415 hda_nid_t dig_in_nid;
416 unsigned int num_channel_mode;
417 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200418 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200419 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200420 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100421 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100422 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200423 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100424 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200425#ifdef CONFIG_SND_HDA_POWER_SAVE
426 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500427 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200428#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429};
430
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
432/*
433 * input MUX handling
434 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200435static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437{
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200440 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
441 if (mux_idx >= spec->num_mux_defs)
442 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100443 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
444 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200445 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446}
447
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200448static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450{
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct alc_spec *spec = codec->spec;
453 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
454
455 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
456 return 0;
457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100464 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100466 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100467 hda_nid_t nid = spec->capsrc_nids ?
468 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200469 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470
Takashi Iwaicd896c32008-11-18 12:36:33 +0100471 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
472 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100473 if (!imux->num_items && mux_idx > 0)
474 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475
Takashi Iwaia22d5432009-07-27 12:54:26 +0200476 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200477 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100478 /* Matrix-mixer style (e.g. ALC882) */
479 unsigned int *cur_val = &spec->cur_mux[adc_idx];
480 unsigned int i, idx;
481
482 idx = ucontrol->value.enumerated.item[0];
483 if (idx >= imux->num_items)
484 idx = imux->num_items - 1;
485 if (*cur_val == idx)
486 return 0;
487 for (i = 0; i < imux->num_items; i++) {
488 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
489 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
490 imux->items[i].index,
491 HDA_AMP_MUTE, v);
492 }
493 *cur_val = idx;
494 return 1;
495 } else {
496 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100497 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100498 &spec->cur_mux[adc_idx]);
499 }
500}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200501
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502/*
503 * channel mode setting
504 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200505static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507{
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100510 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
511 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512}
513
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100519 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200520 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200521 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200529 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
530 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200531 &spec->ext_channel_count);
532 if (err >= 0 && !spec->const_channel_count) {
533 spec->multiout.max_channels = spec->ext_channel_count;
534 if (spec->need_dac_fix)
535 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
536 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200537 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538}
539
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200542 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543 * being part of a format specifier. Maximum allowed length of a value is
544 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100545 *
546 * Note: some retasking pin complexes seem to ignore requests for input
547 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
548 * are requested. Therefore order this list so that this behaviour will not
549 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200550 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
551 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200552 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100554 "Mic 50pc bias", "Mic 80pc bias",
555 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100556};
557static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100558 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100559};
560/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * in the pin being assumed to be exclusively an input or an output pin. In
562 * addition, "input" pins may or may not process the mic bias option
563 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
564 * accept requests for bias as of chip versions up to March 2006) and/or
565 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200567#define ALC_PIN_DIR_IN 0x00
568#define ALC_PIN_DIR_OUT 0x01
569#define ALC_PIN_DIR_INOUT 0x02
570#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
571#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100572
Kailang Yangea1fb292008-08-26 12:58:38 +0200573/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100574 * For each direction the minimum and maximum values are given.
575 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200576static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 { 0, 2 }, /* ALC_PIN_DIR_IN */
578 { 3, 4 }, /* ALC_PIN_DIR_OUT */
579 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200580 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
581 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582};
583#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
584#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
585#define alc_pin_mode_n_items(_dir) \
586 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
587
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200588static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
589 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200590{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591 unsigned int item_num = uinfo->value.enumerated.item;
592 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
593
594 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200595 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100596 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
597
598 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
599 item_num = alc_pin_mode_min(dir);
600 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601 return 0;
602}
603
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200608 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
609 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100610 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200612 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
613 AC_VERB_GET_PIN_WIDGET_CONTROL,
614 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200615
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100616 /* Find enumerated value for current pinctl setting */
617 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200618 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200620 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 return 0;
622}
623
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200624static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626{
627 signed int change;
628 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
629 hda_nid_t nid = kcontrol->private_value & 0xffff;
630 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
631 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200632 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
633 AC_VERB_GET_PIN_WIDGET_CONTROL,
634 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100635
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200636 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637 val = alc_pin_mode_min(dir);
638
639 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100640 if (change) {
641 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200642 snd_hda_codec_write_cache(codec, nid, 0,
643 AC_VERB_SET_PIN_WIDGET_CONTROL,
644 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100645
Kailang Yangea1fb292008-08-26 12:58:38 +0200646 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100647 * for the requested pin mode. Enum values of 2 or less are
648 * input modes.
649 *
650 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200651 * reduces noise slightly (particularly on input) so we'll
652 * do it. However, having both input and output buffers
653 * enabled simultaneously doesn't seem to be problematic if
654 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100655 */
656 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200657 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
658 HDA_AMP_MUTE, HDA_AMP_MUTE);
659 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
660 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100661 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200662 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
663 HDA_AMP_MUTE, HDA_AMP_MUTE);
664 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
665 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100666 }
667 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200668 return change;
669}
670
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100671#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200672 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100673 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100674 .info = alc_pin_mode_info, \
675 .get = alc_pin_mode_get, \
676 .put = alc_pin_mode_put, \
677 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100678
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100679/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
680 * together using a mask with more than one bit set. This control is
681 * currently used only by the ALC260 test model. At this stage they are not
682 * needed for any "production" models.
683 */
684#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200685#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200686
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200687static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
688 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689{
690 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
691 hda_nid_t nid = kcontrol->private_value & 0xffff;
692 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
693 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200694 unsigned int val = snd_hda_codec_read(codec, nid, 0,
695 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100696
697 *valp = (val & mask) != 0;
698 return 0;
699}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200700static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
701 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100702{
703 signed int change;
704 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
705 hda_nid_t nid = kcontrol->private_value & 0xffff;
706 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
707 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200708 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
709 AC_VERB_GET_GPIO_DATA,
710 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711
712 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200713 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
714 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100715 gpio_data &= ~mask;
716 else
717 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200718 snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100720
721 return change;
722}
723#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
724 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100725 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726 .info = alc_gpio_data_info, \
727 .get = alc_gpio_data_get, \
728 .put = alc_gpio_data_put, \
729 .private_value = nid | (mask<<16) }
730#endif /* CONFIG_SND_DEBUG */
731
Jonathan Woithe92621f12006-02-28 11:47:47 +0100732/* A switch control to allow the enabling of the digital IO pins on the
733 * ALC260. This is incredibly simplistic; the intention of this control is
734 * to provide something in the test model allowing digital outputs to be
735 * identified if present. If models are found which can utilise these
736 * outputs a more complete mixer control can be devised for those models if
737 * necessary.
738 */
739#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200740#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200741
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200742static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
743 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100744{
745 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
746 hda_nid_t nid = kcontrol->private_value & 0xffff;
747 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
748 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200749 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100750 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100751
752 *valp = (val & mask) != 0;
753 return 0;
754}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200755static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
756 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100757{
758 signed int change;
759 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
760 hda_nid_t nid = kcontrol->private_value & 0xffff;
761 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
762 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200763 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100764 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200765 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766
767 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200768 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100769 if (val==0)
770 ctrl_data &= ~mask;
771 else
772 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200773 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
774 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100775
776 return change;
777}
778#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
779 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100780 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100781 .info = alc_spdif_ctrl_info, \
782 .get = alc_spdif_ctrl_get, \
783 .put = alc_spdif_ctrl_put, \
784 .private_value = nid | (mask<<16) }
785#endif /* CONFIG_SND_DEBUG */
786
Jonathan Woithef8225f62008-01-08 12:16:54 +0100787/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
788 * Again, this is only used in the ALC26x test models to help identify when
789 * the EAPD line must be asserted for features to work.
790 */
791#ifdef CONFIG_SND_DEBUG
792#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
793
794static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
795 struct snd_ctl_elem_value *ucontrol)
796{
797 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
798 hda_nid_t nid = kcontrol->private_value & 0xffff;
799 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
800 long *valp = ucontrol->value.integer.value;
801 unsigned int val = snd_hda_codec_read(codec, nid, 0,
802 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
803
804 *valp = (val & mask) != 0;
805 return 0;
806}
807
808static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
810{
811 int change;
812 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
813 hda_nid_t nid = kcontrol->private_value & 0xffff;
814 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
815 long val = *ucontrol->value.integer.value;
816 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
817 AC_VERB_GET_EAPD_BTLENABLE,
818 0x00);
819
820 /* Set/unset the masked control bit(s) as needed */
821 change = (!val ? 0 : mask) != (ctrl_data & mask);
822 if (!val)
823 ctrl_data &= ~mask;
824 else
825 ctrl_data |= mask;
826 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
827 ctrl_data);
828
829 return change;
830}
831
832#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
833 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100834 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100835 .info = alc_eapd_ctrl_info, \
836 .get = alc_eapd_ctrl_get, \
837 .put = alc_eapd_ctrl_put, \
838 .private_value = nid | (mask<<16) }
839#endif /* CONFIG_SND_DEBUG */
840
Kailang Yangdf694da2005-12-05 19:42:22 +0100841/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100842 * set up the input pin config (depending on the given auto-pin type)
843 */
844static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
845 int auto_pin_type)
846{
847 unsigned int val = PIN_IN;
848
849 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
850 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200851 unsigned int oldval;
852 oldval = snd_hda_codec_read(codec, nid, 0,
853 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100854 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100855 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200856 /* if the default pin setup is vref50, we give it priority */
857 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100858 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200859 else if (pincap & AC_PINCAP_VREF_50)
860 val = PIN_VREF50;
861 else if (pincap & AC_PINCAP_VREF_100)
862 val = PIN_VREF100;
863 else if (pincap & AC_PINCAP_VREF_GRD)
864 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100865 }
866 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
867}
868
869/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100870 */
871static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
872{
873 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
874 return;
875 spec->mixers[spec->num_mixers++] = mix;
876}
877
878static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
879{
880 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
881 return;
882 spec->init_verbs[spec->num_init_verbs++] = verb;
883}
884
885/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100886 * set up from the preset table
887 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200888static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200889 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100890{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200891 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100892 int i;
893
894 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100895 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100896 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200897 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
898 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100899 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200900
Kailang Yangdf694da2005-12-05 19:42:22 +0100901 spec->channel_mode = preset->channel_mode;
902 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200903 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200904 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100905
Hector Martin3b315d72009-06-02 10:54:19 +0200906 if (preset->const_channel_count)
907 spec->multiout.max_channels = preset->const_channel_count;
908 else
909 spec->multiout.max_channels = spec->channel_mode[0].channels;
910 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100911
912 spec->multiout.num_dacs = preset->num_dacs;
913 spec->multiout.dac_nids = preset->dac_nids;
914 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800915 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100916 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200917
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200918 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200919 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200920 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100921 spec->input_mux = preset->input_mux;
922
923 spec->num_adc_nids = preset->num_adc_nids;
924 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100925 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100926 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100927
928 spec->unsol_event = preset->unsol_event;
929 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200930#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100931 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200932 spec->loopback.amplist = preset->loopbacks;
933#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200934
935 if (preset->setup)
936 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100937}
938
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200939/* Enable GPIO mask and set output */
940static struct hda_verb alc_gpio1_init_verbs[] = {
941 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
942 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
943 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
944 { }
945};
946
947static struct hda_verb alc_gpio2_init_verbs[] = {
948 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
949 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
950 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
951 { }
952};
953
Kailang Yangbdd148a2007-05-08 15:19:08 +0200954static struct hda_verb alc_gpio3_init_verbs[] = {
955 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
956 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
957 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
958 { }
959};
960
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200961/*
962 * Fix hardware PLL issue
963 * On some codecs, the analog PLL gating control must be off while
964 * the default value is 1.
965 */
966static void alc_fix_pll(struct hda_codec *codec)
967{
968 struct alc_spec *spec = codec->spec;
969 unsigned int val;
970
971 if (!spec->pll_nid)
972 return;
973 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
974 spec->pll_coef_idx);
975 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
976 AC_VERB_GET_PROC_COEF, 0);
977 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
978 spec->pll_coef_idx);
979 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
980 val & ~(1 << spec->pll_coef_bit));
981}
982
983static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
984 unsigned int coef_idx, unsigned int coef_bit)
985{
986 struct alc_spec *spec = codec->spec;
987 spec->pll_nid = nid;
988 spec->pll_coef_idx = coef_idx;
989 spec->pll_coef_bit = coef_bit;
990 alc_fix_pll(codec);
991}
992
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200993static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200994{
995 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200996 unsigned int nid = spec->autocfg.hp_pins[0];
997 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200998
Takashi Iwaiad87c642009-11-02 14:23:15 +0100999 if (!nid)
1000 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001001 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001002 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1003 nid = spec->autocfg.speaker_pins[i];
1004 if (!nid)
1005 break;
1006 snd_hda_codec_write(codec, nid, 0,
1007 AC_VERB_SET_PIN_WIDGET_CONTROL,
1008 spec->jack_present ? 0 : PIN_OUT);
1009 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001010}
1011
Takashi Iwai6c819492009-08-10 18:47:44 +02001012static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1013 hda_nid_t nid)
1014{
1015 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1016 int i, nums;
1017
1018 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1019 for (i = 0; i < nums; i++)
1020 if (conn[i] == nid)
1021 return i;
1022 return -1;
1023}
1024
Takashi Iwai840b64c2010-07-13 22:49:01 +02001025/* switch the current ADC according to the jack state */
1026static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1027{
1028 struct alc_spec *spec = codec->spec;
1029 unsigned int present;
1030 hda_nid_t new_adc;
1031
1032 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1033 if (present)
1034 spec->cur_adc_idx = 1;
1035 else
1036 spec->cur_adc_idx = 0;
1037 new_adc = spec->adc_nids[spec->cur_adc_idx];
1038 if (spec->cur_adc && spec->cur_adc != new_adc) {
1039 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001040 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001041 spec->cur_adc = new_adc;
1042 snd_hda_codec_setup_stream(codec, new_adc,
1043 spec->cur_adc_stream_tag, 0,
1044 spec->cur_adc_format);
1045 }
1046}
1047
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048static void alc_mic_automute(struct hda_codec *codec)
1049{
1050 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001051 struct alc_mic_route *dead, *alive;
1052 unsigned int present, type;
1053 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001054
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001055 if (!spec->auto_mic)
1056 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001057 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1058 return;
1059 if (snd_BUG_ON(!spec->adc_nids))
1060 return;
1061
Takashi Iwai840b64c2010-07-13 22:49:01 +02001062 if (spec->dual_adc_switch) {
1063 alc_dual_mic_adc_auto_switch(codec);
1064 return;
1065 }
1066
Takashi Iwai6c819492009-08-10 18:47:44 +02001067 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1068
Wu Fengguang864f92b2009-11-18 12:38:02 +08001069 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001070 if (present) {
1071 alive = &spec->ext_mic;
1072 dead = &spec->int_mic;
1073 } else {
1074 alive = &spec->int_mic;
1075 dead = &spec->ext_mic;
1076 }
1077
Takashi Iwai6c819492009-08-10 18:47:44 +02001078 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1079 if (type == AC_WID_AUD_MIX) {
1080 /* Matrix-mixer style (e.g. ALC882) */
1081 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1082 alive->mux_idx,
1083 HDA_AMP_MUTE, 0);
1084 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1085 dead->mux_idx,
1086 HDA_AMP_MUTE, HDA_AMP_MUTE);
1087 } else {
1088 /* MUX style (e.g. ALC880) */
1089 snd_hda_codec_write_cache(codec, cap_nid, 0,
1090 AC_VERB_SET_CONNECT_SEL,
1091 alive->mux_idx);
1092 }
1093
1094 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001095}
1096
Kailang Yangc9b58002007-10-16 14:30:01 +02001097/* unsolicited event for HP jack sensing */
1098static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1099{
1100 if (codec->vendor_id == 0x10ec0880)
1101 res >>= 28;
1102 else
1103 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001104 switch (res) {
1105 case ALC880_HP_EVENT:
1106 alc_automute_pin(codec);
1107 break;
1108 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001109 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001110 break;
1111 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001112}
1113
1114static void alc_inithook(struct hda_codec *codec)
1115{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001116 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001117 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001118}
1119
Kailang Yangf9423e72008-05-27 12:32:25 +02001120/* additional initialization for ALC888 variants */
1121static void alc888_coef_init(struct hda_codec *codec)
1122{
1123 unsigned int tmp;
1124
1125 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1126 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1127 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001128 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001129 /* alc888S-VC */
1130 snd_hda_codec_read(codec, 0x20, 0,
1131 AC_VERB_SET_PROC_COEF, 0x830);
1132 else
1133 /* alc888-VB */
1134 snd_hda_codec_read(codec, 0x20, 0,
1135 AC_VERB_SET_PROC_COEF, 0x3030);
1136}
1137
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001138static void alc889_coef_init(struct hda_codec *codec)
1139{
1140 unsigned int tmp;
1141
1142 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1143 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1144 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1145 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1146}
1147
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001148/* turn on/off EAPD control (only if available) */
1149static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1150{
1151 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1152 return;
1153 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1154 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1155 on ? 2 : 0);
1156}
1157
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001158static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001159{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001160 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001161
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001162 switch (type) {
1163 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001164 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1165 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001166 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001167 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1168 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001169 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001170 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1171 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001172 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001173 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001174 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001175 set_eapd(codec, 0x0f, 1);
1176 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001177 break;
1178 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001179 case 0x10ec0267:
1180 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001181 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001182 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001183 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001184 case 0x10ec0660:
1185 case 0x10ec0662:
1186 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001188 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001189 set_eapd(codec, 0x14, 1);
1190 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001191 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001192 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001193 switch (codec->vendor_id) {
1194 case 0x10ec0260:
1195 snd_hda_codec_write(codec, 0x1a, 0,
1196 AC_VERB_SET_COEF_INDEX, 7);
1197 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1198 AC_VERB_GET_PROC_COEF, 0);
1199 snd_hda_codec_write(codec, 0x1a, 0,
1200 AC_VERB_SET_COEF_INDEX, 7);
1201 snd_hda_codec_write(codec, 0x1a, 0,
1202 AC_VERB_SET_PROC_COEF,
1203 tmp | 0x2010);
1204 break;
1205 case 0x10ec0262:
1206 case 0x10ec0880:
1207 case 0x10ec0882:
1208 case 0x10ec0883:
1209 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001210 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001211 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001212 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001213 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001214 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001215 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001216 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001217#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001218 case 0x10ec0267:
1219 case 0x10ec0268:
1220 snd_hda_codec_write(codec, 0x20, 0,
1221 AC_VERB_SET_COEF_INDEX, 7);
1222 tmp = snd_hda_codec_read(codec, 0x20, 0,
1223 AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001225 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001226 snd_hda_codec_write(codec, 0x20, 0,
1227 AC_VERB_SET_PROC_COEF,
1228 tmp | 0x3000);
1229 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001230#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001231 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001232 break;
1233 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001234}
Kailang Yangea1fb292008-08-26 12:58:38 +02001235
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001236static void alc_init_auto_hp(struct hda_codec *codec)
1237{
1238 struct alc_spec *spec = codec->spec;
1239
1240 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001241 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242
Kailang Yangc9b58002007-10-16 14:30:01 +02001243 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001244 if (spec->autocfg.line_out_pins[0] &&
1245 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001246 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001247 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001248 else
1249 return;
1250 }
1251
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001252 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1253 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001254 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1255 AC_VERB_SET_UNSOLICITED_ENABLE,
1256 AC_USRSP_EN | ALC880_HP_EVENT);
1257 spec->unsol_event = alc_sku_unsol_event;
1258}
1259
Takashi Iwai6c819492009-08-10 18:47:44 +02001260static void alc_init_auto_mic(struct hda_codec *codec)
1261{
1262 struct alc_spec *spec = codec->spec;
1263 struct auto_pin_cfg *cfg = &spec->autocfg;
1264 hda_nid_t fixed, ext;
1265 int i;
1266
1267 /* there must be only two mic inputs exclusively */
1268 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1269 if (cfg->input_pins[i])
1270 return;
1271
1272 fixed = ext = 0;
1273 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1274 hda_nid_t nid = cfg->input_pins[i];
1275 unsigned int defcfg;
1276 if (!nid)
1277 return;
1278 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1279 switch (get_defcfg_connect(defcfg)) {
1280 case AC_JACK_PORT_FIXED:
1281 if (fixed)
1282 return; /* already occupied */
1283 fixed = nid;
1284 break;
1285 case AC_JACK_PORT_COMPLEX:
1286 if (ext)
1287 return; /* already occupied */
1288 ext = nid;
1289 break;
1290 default:
1291 return; /* invalid entry */
1292 }
1293 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001294 if (!ext || !fixed)
1295 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001296 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1297 return; /* no unsol support */
1298 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1299 ext, fixed);
1300 spec->ext_mic.pin = ext;
1301 spec->int_mic.pin = fixed;
1302 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1303 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1304 spec->auto_mic = 1;
1305 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1306 AC_VERB_SET_UNSOLICITED_ENABLE,
1307 AC_USRSP_EN | ALC880_MIC_EVENT);
1308 spec->unsol_event = alc_sku_unsol_event;
1309}
1310
Kailang Yangda00c242010-03-19 11:23:45 +01001311static int alc_auto_parse_customize_define(struct hda_codec *codec)
1312{
1313 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001314 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001315 struct alc_spec *spec = codec->spec;
1316
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001317 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1318
Kailang Yangda00c242010-03-19 11:23:45 +01001319 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001320 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001321 goto do_sku;
1322
1323 nid = 0x1d;
1324 if (codec->vendor_id == 0x10ec0260)
1325 nid = 0x17;
1326 ass = snd_hda_codec_get_pincfg(codec, nid);
1327
1328 if (!(ass & 1)) {
1329 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1330 codec->chip_name, ass);
1331 return -1;
1332 }
1333
1334 /* check sum */
1335 tmp = 0;
1336 for (i = 1; i < 16; i++) {
1337 if ((ass >> i) & 1)
1338 tmp++;
1339 }
1340 if (((ass >> 16) & 0xf) != tmp)
1341 return -1;
1342
1343 spec->cdefine.port_connectivity = ass >> 30;
1344 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1345 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1346 spec->cdefine.customization = ass >> 8;
1347do_sku:
1348 spec->cdefine.sku_cfg = ass;
1349 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1350 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1351 spec->cdefine.swap = (ass & 0x2) >> 1;
1352 spec->cdefine.override = ass & 0x1;
1353
1354 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1355 nid, spec->cdefine.sku_cfg);
1356 snd_printd("SKU: port_connectivity=0x%x\n",
1357 spec->cdefine.port_connectivity);
1358 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1359 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1360 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1361 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1362 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1363 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1364 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1365
1366 return 0;
1367}
1368
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001369/* check subsystem ID and set up device-specific initialization;
1370 * return 1 if initialized, 0 if invalid SSID
1371 */
1372/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1373 * 31 ~ 16 : Manufacture ID
1374 * 15 ~ 8 : SKU ID
1375 * 7 ~ 0 : Assembly ID
1376 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1377 */
1378static int alc_subsystem_id(struct hda_codec *codec,
1379 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001380 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001381{
1382 unsigned int ass, tmp, i;
1383 unsigned nid;
1384 struct alc_spec *spec = codec->spec;
1385
1386 ass = codec->subsystem_id & 0xffff;
1387 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1388 goto do_sku;
1389
1390 /* invalid SSID, check the special NID pin defcfg instead */
1391 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001392 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001393 * 29~21 : reserve
1394 * 20 : PCBEEP input
1395 * 19~16 : Check sum (15:1)
1396 * 15~1 : Custom
1397 * 0 : override
1398 */
1399 nid = 0x1d;
1400 if (codec->vendor_id == 0x10ec0260)
1401 nid = 0x17;
1402 ass = snd_hda_codec_get_pincfg(codec, nid);
1403 snd_printd("realtek: No valid SSID, "
1404 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001405 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001406 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001407 return 0;
1408 if ((ass >> 30) != 1) /* no physical connection */
1409 return 0;
1410
1411 /* check sum */
1412 tmp = 0;
1413 for (i = 1; i < 16; i++) {
1414 if ((ass >> i) & 1)
1415 tmp++;
1416 }
1417 if (((ass >> 16) & 0xf) != tmp)
1418 return 0;
1419do_sku:
1420 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1421 ass & 0xffff, codec->vendor_id);
1422 /*
1423 * 0 : override
1424 * 1 : Swap Jack
1425 * 2 : 0 --> Desktop, 1 --> Laptop
1426 * 3~5 : External Amplifier control
1427 * 7~6 : Reserved
1428 */
1429 tmp = (ass & 0x38) >> 3; /* external Amp control */
1430 switch (tmp) {
1431 case 1:
1432 spec->init_amp = ALC_INIT_GPIO1;
1433 break;
1434 case 3:
1435 spec->init_amp = ALC_INIT_GPIO2;
1436 break;
1437 case 7:
1438 spec->init_amp = ALC_INIT_GPIO3;
1439 break;
1440 case 5:
1441 spec->init_amp = ALC_INIT_DEFAULT;
1442 break;
1443 }
1444
1445 /* is laptop or Desktop and enable the function "Mute internal speaker
1446 * when the external headphone out jack is plugged"
1447 */
1448 if (!(ass & 0x8000))
1449 return 1;
1450 /*
1451 * 10~8 : Jack location
1452 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1453 * 14~13: Resvered
1454 * 15 : 1 --> enable the function "Mute internal speaker
1455 * when the external headphone out jack is plugged"
1456 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001457 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001458 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001459 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1460 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001461 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001462 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001463 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001464 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001465 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001466 else if (tmp == 3)
1467 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001468 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001469 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001470 for (i = 0; i < spec->autocfg.line_outs; i++)
1471 if (spec->autocfg.line_out_pins[i] == nid)
1472 return 1;
1473 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001474 }
1475
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001476 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001477 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001478 return 1;
1479}
Kailang Yangea1fb292008-08-26 12:58:38 +02001480
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001481static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001482 hda_nid_t porta, hda_nid_t porte,
1483 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001484{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001485 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001486 struct alc_spec *spec = codec->spec;
1487 snd_printd("realtek: "
1488 "Enable default setup for auto mode as fallback\n");
1489 spec->init_amp = ALC_INIT_DEFAULT;
1490 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001491 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001492 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001493}
1494
Takashi Iwai41e41f12005-06-08 14:48:49 +02001495/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001496 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001497 */
1498
1499struct alc_pincfg {
1500 hda_nid_t nid;
1501 u32 val;
1502};
1503
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001504struct alc_fixup {
1505 const struct alc_pincfg *pins;
1506 const struct hda_verb *verbs;
1507};
1508
1509static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001510 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001511 const struct alc_fixup *fix,
1512 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001513{
1514 const struct alc_pincfg *cfg;
1515
1516 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1517 if (!quirk)
1518 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001519 fix += quirk->value;
1520 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001521 if (pre_init && cfg) {
1522#ifdef CONFIG_SND_DEBUG_VERBOSE
1523 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1524 codec->chip_name, quirk->name);
1525#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001526 for (; cfg->nid; cfg++)
1527 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1528 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001529 if (!pre_init && fix->verbs) {
1530#ifdef CONFIG_SND_DEBUG_VERBOSE
1531 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1532 codec->chip_name, quirk->name);
1533#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001534 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001535 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001536}
1537
Kailang Yang274693f2009-12-03 10:07:50 +01001538static int alc_read_coef_idx(struct hda_codec *codec,
1539 unsigned int coef_idx)
1540{
1541 unsigned int val;
1542 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1543 coef_idx);
1544 val = snd_hda_codec_read(codec, 0x20, 0,
1545 AC_VERB_GET_PROC_COEF, 0);
1546 return val;
1547}
1548
Takashi Iwai757899a2010-07-30 10:48:14 +02001549/* set right pin controls for digital I/O */
1550static void alc_auto_init_digital(struct hda_codec *codec)
1551{
1552 struct alc_spec *spec = codec->spec;
1553 int i;
1554 hda_nid_t pin;
1555
1556 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1557 pin = spec->autocfg.dig_out_pins[i];
1558 if (pin) {
1559 snd_hda_codec_write(codec, pin, 0,
1560 AC_VERB_SET_PIN_WIDGET_CONTROL,
1561 PIN_OUT);
1562 }
1563 }
1564 pin = spec->autocfg.dig_in_pin;
1565 if (pin)
1566 snd_hda_codec_write(codec, pin, 0,
1567 AC_VERB_SET_PIN_WIDGET_CONTROL,
1568 PIN_IN);
1569}
1570
1571/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1572static void alc_auto_parse_digital(struct hda_codec *codec)
1573{
1574 struct alc_spec *spec = codec->spec;
1575 int i, err;
1576 hda_nid_t dig_nid;
1577
1578 /* support multiple SPDIFs; the secondary is set up as a slave */
1579 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1580 err = snd_hda_get_connections(codec,
1581 spec->autocfg.dig_out_pins[i],
1582 &dig_nid, 1);
1583 if (err < 0)
1584 continue;
1585 if (!i) {
1586 spec->multiout.dig_out_nid = dig_nid;
1587 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1588 } else {
1589 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1590 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1591 break;
1592 spec->slave_dig_outs[i - 1] = dig_nid;
1593 }
1594 }
1595
1596 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001597 dig_nid = codec->start_nid;
1598 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1599 unsigned int wcaps = get_wcaps(codec, dig_nid);
1600 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1601 continue;
1602 if (!(wcaps & AC_WCAP_DIGITAL))
1603 continue;
1604 if (!(wcaps & AC_WCAP_CONN_LIST))
1605 continue;
1606 err = get_connection_index(codec, dig_nid,
1607 spec->autocfg.dig_in_pin);
1608 if (err >= 0) {
1609 spec->dig_in_nid = dig_nid;
1610 break;
1611 }
1612 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001613 }
1614}
1615
Takashi Iwaif95474e2007-07-10 00:47:43 +02001616/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001617 * ALC888
1618 */
1619
1620/*
1621 * 2ch mode
1622 */
1623static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1624/* Mic-in jack as mic in */
1625 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1626 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1627/* Line-in jack as Line in */
1628 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1629 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1630/* Line-Out as Front */
1631 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1632 { } /* end */
1633};
1634
1635/*
1636 * 4ch mode
1637 */
1638static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1639/* Mic-in jack as mic in */
1640 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1641 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1642/* Line-in jack as Surround */
1643 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1644 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1645/* Line-Out as Front */
1646 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1647 { } /* end */
1648};
1649
1650/*
1651 * 6ch mode
1652 */
1653static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1654/* Mic-in jack as CLFE */
1655 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1656 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1657/* Line-in jack as Surround */
1658 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1659 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1660/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1661 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1662 { } /* end */
1663};
1664
1665/*
1666 * 8ch mode
1667 */
1668static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1669/* Mic-in jack as CLFE */
1670 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1671 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1672/* Line-in jack as Surround */
1673 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1674 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1675/* Line-Out as Side */
1676 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1677 { } /* end */
1678};
1679
1680static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1681 { 2, alc888_4ST_ch2_intel_init },
1682 { 4, alc888_4ST_ch4_intel_init },
1683 { 6, alc888_4ST_ch6_intel_init },
1684 { 8, alc888_4ST_ch8_intel_init },
1685};
1686
1687/*
1688 * ALC888 Fujitsu Siemens Amillo xa3530
1689 */
1690
1691static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1692/* Front Mic: set to PIN_IN (empty by default) */
1693 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1694/* Connect Internal HP to Front */
1695 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1696 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1697 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1698/* Connect Bass HP to Front */
1699 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1700 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1701 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1702/* Connect Line-Out side jack (SPDIF) to Side */
1703 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1706/* Connect Mic jack to CLFE */
1707 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1708 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1709 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1710/* Connect Line-in jack to Surround */
1711 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1712 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1713 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1714/* Connect HP out jack to Front */
1715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1717 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1718/* Enable unsolicited event for HP jack and Line-out jack */
1719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1720 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1721 {}
1722};
1723
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001724static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001725{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001726 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001727 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001728 hda_nid_t nid;
1729 int i;
1730
1731 spec->jack_present = 0;
1732 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1733 nid = spec->autocfg.hp_pins[i];
1734 if (!nid)
1735 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001736 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001737 spec->jack_present = 1;
1738 break;
1739 }
1740 }
1741
1742 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001743 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001744 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1745 nid = spec->autocfg.speaker_pins[i];
1746 if (!nid)
1747 break;
1748 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1749 HDA_AMP_MUTE, mute);
1750 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001751}
1752
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001753static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1754 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001755{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001756 if (codec->vendor_id == 0x10ec0880)
1757 res >>= 28;
1758 else
1759 res >>= 26;
1760 if (res == ALC880_HP_EVENT)
1761 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001762}
1763
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001764static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001765{
1766 struct alc_spec *spec = codec->spec;
1767
1768 spec->autocfg.hp_pins[0] = 0x15;
1769 spec->autocfg.speaker_pins[0] = 0x14;
1770 spec->autocfg.speaker_pins[1] = 0x16;
1771 spec->autocfg.speaker_pins[2] = 0x17;
1772 spec->autocfg.speaker_pins[3] = 0x19;
1773 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001774}
1775
1776static void alc889_intel_init_hook(struct hda_codec *codec)
1777{
1778 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001779 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001780}
1781
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001782static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001783{
1784 struct alc_spec *spec = codec->spec;
1785
1786 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1787 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1788 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1789 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001790}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001791
1792/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001793 * ALC888 Acer Aspire 4930G model
1794 */
1795
1796static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1797/* Front Mic: set to PIN_IN (empty by default) */
1798 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1799/* Unselect Front Mic by default in input mixer 3 */
1800 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001801/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001802 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1803/* Connect Internal HP to front */
1804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1806 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1807/* Connect HP out to front */
1808 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1809 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1810 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1811 { }
1812};
1813
Hector Martin3b315d72009-06-02 10:54:19 +02001814/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001815 * ALC888 Acer Aspire 6530G model
1816 */
1817
1818static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001819/* Route to built-in subwoofer as well as speakers */
1820 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1821 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1822 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001824/* Bias voltage on for external mic port */
1825 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001826/* Front Mic: set to PIN_IN (empty by default) */
1827 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1828/* Unselect Front Mic by default in input mixer 3 */
1829 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001830/* Enable unsolicited event for HP jack */
1831 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1832/* Enable speaker output */
1833 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1834 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001835 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001836/* Enable headphone output */
1837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001840 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001841 { }
1842};
1843
1844/*
Hector Martin018df412009-06-04 00:13:40 +02001845 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001846 */
1847
Hector Martin018df412009-06-04 00:13:40 +02001848static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001849/* Front Mic: set to PIN_IN (empty by default) */
1850 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1851/* Unselect Front Mic by default in input mixer 3 */
1852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1853/* Enable unsolicited event for HP jack */
1854 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1855/* Connect Internal Front to Front */
1856 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1857 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1858 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1859/* Connect Internal Rear to Rear */
1860 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1861 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1862 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1863/* Connect Internal CLFE to CLFE */
1864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1866 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1867/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1870 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1871/* Enable all DACs */
1872/* DAC DISABLE/MUTE 1? */
1873/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1874 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1875 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1876/* DAC DISABLE/MUTE 2? */
1877/* some bit here disables the other DACs. Init=0x4900 */
1878 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1879 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001880/* DMIC fix
1881 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1882 * which makes the stereo useless. However, either the mic or the ALC889
1883 * makes the signal become a difference/sum signal instead of standard
1884 * stereo, which is annoying. So instead we flip this bit which makes the
1885 * codec replicate the sum signal to both channels, turning it into a
1886 * normal mono mic.
1887 */
1888/* DMIC_CONTROL? Init value = 0x0001 */
1889 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1890 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001891 { }
1892};
1893
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001894static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001895 /* Front mic only available on one ADC */
1896 {
1897 .num_items = 4,
1898 .items = {
1899 { "Mic", 0x0 },
1900 { "Line", 0x2 },
1901 { "CD", 0x4 },
1902 { "Front Mic", 0xb },
1903 },
1904 },
1905 {
1906 .num_items = 3,
1907 .items = {
1908 { "Mic", 0x0 },
1909 { "Line", 0x2 },
1910 { "CD", 0x4 },
1911 },
1912 }
1913};
1914
Tony Vroond2fd4b02009-06-21 00:40:10 +01001915static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1916 /* Interal mic only available on one ADC */
1917 {
Tony Vroon684a8842009-06-26 09:27:50 +01001918 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001919 .items = {
1920 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001921 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001922 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001923 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001924 { "Int Mic", 0xb },
1925 },
1926 },
1927 {
Tony Vroon684a8842009-06-26 09:27:50 +01001928 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001929 .items = {
1930 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001931 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001932 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001933 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001934 },
1935 }
1936};
1937
Hector Martin018df412009-06-04 00:13:40 +02001938static struct hda_input_mux alc889_capture_sources[3] = {
1939 /* Digital mic only available on first "ADC" */
1940 {
1941 .num_items = 5,
1942 .items = {
1943 { "Mic", 0x0 },
1944 { "Line", 0x2 },
1945 { "CD", 0x4 },
1946 { "Front Mic", 0xb },
1947 { "Input Mix", 0xa },
1948 },
1949 },
1950 {
1951 .num_items = 4,
1952 .items = {
1953 { "Mic", 0x0 },
1954 { "Line", 0x2 },
1955 { "CD", 0x4 },
1956 { "Input Mix", 0xa },
1957 },
1958 },
1959 {
1960 .num_items = 4,
1961 .items = {
1962 { "Mic", 0x0 },
1963 { "Line", 0x2 },
1964 { "CD", 0x4 },
1965 { "Input Mix", 0xa },
1966 },
1967 }
1968};
1969
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001970static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001971 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1972 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1973 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1974 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1975 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1976 HDA_OUTPUT),
1977 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1978 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1979 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1980 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1981 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1984 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1985 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1987 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001989 { } /* end */
1990};
1991
Hector Martin556eea92009-12-20 22:51:23 +01001992static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1993 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1994 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1995 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1996 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1997 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1998 HDA_OUTPUT),
1999 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2000 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2001 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2002 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2003 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2004 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2006 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2007 { } /* end */
2008};
2009
2010
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002011static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002012{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002013 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002014
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002015 spec->autocfg.hp_pins[0] = 0x15;
2016 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002017 spec->autocfg.speaker_pins[1] = 0x16;
2018 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002019}
2020
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002021static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002022{
2023 struct alc_spec *spec = codec->spec;
2024
2025 spec->autocfg.hp_pins[0] = 0x15;
2026 spec->autocfg.speaker_pins[0] = 0x14;
2027 spec->autocfg.speaker_pins[1] = 0x16;
2028 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002029}
2030
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002031static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002032{
2033 struct alc_spec *spec = codec->spec;
2034
2035 spec->autocfg.hp_pins[0] = 0x15;
2036 spec->autocfg.speaker_pins[0] = 0x14;
2037 spec->autocfg.speaker_pins[1] = 0x16;
2038 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002039}
2040
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002041/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042 * ALC880 3-stack model
2043 *
2044 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002045 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2046 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047 */
2048
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002049static hda_nid_t alc880_dac_nids[4] = {
2050 /* front, rear, clfe, rear_surr */
2051 0x02, 0x05, 0x04, 0x03
2052};
2053
2054static hda_nid_t alc880_adc_nids[3] = {
2055 /* ADC0-2 */
2056 0x07, 0x08, 0x09,
2057};
2058
2059/* The datasheet says the node 0x07 is connected from inputs,
2060 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002061 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002063static hda_nid_t alc880_adc_nids_alt[2] = {
2064 /* ADC1-2 */
2065 0x08, 0x09,
2066};
2067
2068#define ALC880_DIGOUT_NID 0x06
2069#define ALC880_DIGIN_NID 0x0a
2070
2071static struct hda_input_mux alc880_capture_source = {
2072 .num_items = 4,
2073 .items = {
2074 { "Mic", 0x0 },
2075 { "Front Mic", 0x3 },
2076 { "Line", 0x2 },
2077 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002078 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002079};
2080
2081/* channel source setting (2/6 channel selection for 3-stack) */
2082/* 2ch mode */
2083static struct hda_verb alc880_threestack_ch2_init[] = {
2084 /* set line-in to input, mute it */
2085 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2086 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2087 /* set mic-in to input vref 80%, mute it */
2088 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2089 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090 { } /* end */
2091};
2092
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002093/* 6ch mode */
2094static struct hda_verb alc880_threestack_ch6_init[] = {
2095 /* set line-in to output, unmute it */
2096 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2097 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2098 /* set mic-in to output, unmute it */
2099 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2100 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2101 { } /* end */
2102};
2103
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002104static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002105 { 2, alc880_threestack_ch2_init },
2106 { 6, alc880_threestack_ch6_init },
2107};
2108
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002109static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002111 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002112 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002113 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002114 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2115 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002116 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2117 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2119 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2120 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2121 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2122 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2123 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2124 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2125 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002127 {
2128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2129 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002130 .info = alc_ch_mode_info,
2131 .get = alc_ch_mode_get,
2132 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002133 },
2134 { } /* end */
2135};
2136
2137/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002138static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2139 struct snd_ctl_elem_info *uinfo)
2140{
2141 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2142 struct alc_spec *spec = codec->spec;
2143 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002144
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002145 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002146 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2147 HDA_INPUT);
2148 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002149 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002150 return err;
2151}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002152
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002153static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2154 unsigned int size, unsigned int __user *tlv)
2155{
2156 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2157 struct alc_spec *spec = codec->spec;
2158 int err;
2159
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002160 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002161 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2162 HDA_INPUT);
2163 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002164 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002165 return err;
2166}
2167
2168typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2169 struct snd_ctl_elem_value *ucontrol);
2170
2171static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2172 struct snd_ctl_elem_value *ucontrol,
2173 getput_call_t func)
2174{
2175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2176 struct alc_spec *spec = codec->spec;
2177 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2178 int err;
2179
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002180 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002181 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2182 3, 0, HDA_INPUT);
2183 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002184 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002185 return err;
2186}
2187
2188static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2189 struct snd_ctl_elem_value *ucontrol)
2190{
2191 return alc_cap_getput_caller(kcontrol, ucontrol,
2192 snd_hda_mixer_amp_volume_get);
2193}
2194
2195static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2196 struct snd_ctl_elem_value *ucontrol)
2197{
2198 return alc_cap_getput_caller(kcontrol, ucontrol,
2199 snd_hda_mixer_amp_volume_put);
2200}
2201
2202/* capture mixer elements */
2203#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2204
2205static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2206 struct snd_ctl_elem_value *ucontrol)
2207{
2208 return alc_cap_getput_caller(kcontrol, ucontrol,
2209 snd_hda_mixer_amp_switch_get);
2210}
2211
2212static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2213 struct snd_ctl_elem_value *ucontrol)
2214{
2215 return alc_cap_getput_caller(kcontrol, ucontrol,
2216 snd_hda_mixer_amp_switch_put);
2217}
2218
Takashi Iwaia23b6882009-03-23 15:21:36 +01002219#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002220 { \
2221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2222 .name = "Capture Switch", \
2223 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2224 .count = num, \
2225 .info = alc_cap_sw_info, \
2226 .get = alc_cap_sw_get, \
2227 .put = alc_cap_sw_put, \
2228 }, \
2229 { \
2230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2231 .name = "Capture Volume", \
2232 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2233 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2234 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2235 .count = num, \
2236 .info = alc_cap_vol_info, \
2237 .get = alc_cap_vol_get, \
2238 .put = alc_cap_vol_put, \
2239 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002240 }
2241
2242#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002243 { \
2244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2245 /* .name = "Capture Source", */ \
2246 .name = "Input Source", \
2247 .count = num, \
2248 .info = alc_mux_enum_info, \
2249 .get = alc_mux_enum_get, \
2250 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002251 }
2252
2253#define DEFINE_CAPMIX(num) \
2254static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2255 _DEFINE_CAPMIX(num), \
2256 _DEFINE_CAPSRC(num), \
2257 { } /* end */ \
2258}
2259
2260#define DEFINE_CAPMIX_NOSRC(num) \
2261static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2262 _DEFINE_CAPMIX(num), \
2263 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002264}
2265
2266/* up to three ADCs */
2267DEFINE_CAPMIX(1);
2268DEFINE_CAPMIX(2);
2269DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002270DEFINE_CAPMIX_NOSRC(1);
2271DEFINE_CAPMIX_NOSRC(2);
2272DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002273
2274/*
2275 * ALC880 5-stack model
2276 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002277 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2278 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002279 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2280 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2281 */
2282
2283/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002284static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002285 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002286 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287 { } /* end */
2288};
2289
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002290/* channel source setting (6/8 channel selection for 5-stack) */
2291/* 6ch mode */
2292static struct hda_verb alc880_fivestack_ch6_init[] = {
2293 /* set line-in to input, mute it */
2294 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2295 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002296 { } /* end */
2297};
2298
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002299/* 8ch mode */
2300static struct hda_verb alc880_fivestack_ch8_init[] = {
2301 /* set line-in to output, unmute it */
2302 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2303 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2304 { } /* end */
2305};
2306
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002307static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308 { 6, alc880_fivestack_ch6_init },
2309 { 8, alc880_fivestack_ch8_init },
2310};
2311
2312
2313/*
2314 * ALC880 6-stack model
2315 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002316 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2317 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002318 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2319 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2320 */
2321
2322static hda_nid_t alc880_6st_dac_nids[4] = {
2323 /* front, rear, clfe, rear_surr */
2324 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002325};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002326
2327static struct hda_input_mux alc880_6stack_capture_source = {
2328 .num_items = 4,
2329 .items = {
2330 { "Mic", 0x0 },
2331 { "Front Mic", 0x1 },
2332 { "Line", 0x2 },
2333 { "CD", 0x4 },
2334 },
2335};
2336
2337/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002338static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002339 { 8, NULL },
2340};
2341
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002342static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002343 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002344 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002345 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002346 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002347 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2348 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002349 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2350 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002351 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002352 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002353 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2354 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2359 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2360 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002361 {
2362 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2363 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002364 .info = alc_ch_mode_info,
2365 .get = alc_ch_mode_get,
2366 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002367 },
2368 { } /* end */
2369};
2370
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002371
2372/*
2373 * ALC880 W810 model
2374 *
2375 * W810 has rear IO for:
2376 * Front (DAC 02)
2377 * Surround (DAC 03)
2378 * Center/LFE (DAC 04)
2379 * Digital out (06)
2380 *
2381 * The system also has a pair of internal speakers, and a headphone jack.
2382 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002383 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002384 * There is a variable resistor to control the speaker or headphone
2385 * volume. This is a hardware-only device without a software API.
2386 *
2387 * Plugging headphones in will disable the internal speakers. This is
2388 * implemented in hardware, not via the driver using jack sense. In
2389 * a similar fashion, plugging into the rear socket marked "front" will
2390 * disable both the speakers and headphones.
2391 *
2392 * For input, there's a microphone jack, and an "audio in" jack.
2393 * These may not do anything useful with this driver yet, because I
2394 * haven't setup any initialization verbs for these yet...
2395 */
2396
2397static hda_nid_t alc880_w810_dac_nids[3] = {
2398 /* front, rear/surround, clfe */
2399 0x02, 0x03, 0x04
2400};
2401
2402/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002403static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002404 { 6, NULL }
2405};
2406
2407/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002408static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002409 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002410 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002411 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002412 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002413 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2414 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002415 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2416 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002417 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2418 { } /* end */
2419};
2420
2421
2422/*
2423 * Z710V model
2424 *
2425 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002426 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2427 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428 */
2429
2430static hda_nid_t alc880_z71v_dac_nids[1] = {
2431 0x02
2432};
2433#define ALC880_Z71V_HP_DAC 0x03
2434
2435/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002436static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002437 { 2, NULL }
2438};
2439
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002440static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002441 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002442 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002443 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002444 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2447 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2448 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2449 { } /* end */
2450};
2451
2452
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002453/*
2454 * ALC880 F1734 model
2455 *
2456 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2457 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2458 */
2459
2460static hda_nid_t alc880_f1734_dac_nids[1] = {
2461 0x03
2462};
2463#define ALC880_F1734_HP_DAC 0x02
2464
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002465static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002466 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002467 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002468 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2469 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002470 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2471 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002474 { } /* end */
2475};
2476
Takashi Iwai937b4162008-02-11 14:52:36 +01002477static struct hda_input_mux alc880_f1734_capture_source = {
2478 .num_items = 2,
2479 .items = {
2480 { "Mic", 0x1 },
2481 { "CD", 0x4 },
2482 },
2483};
2484
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002485
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486/*
2487 * ALC880 ASUS model
2488 *
2489 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2490 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2491 * Mic = 0x18, Line = 0x1a
2492 */
2493
2494#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2495#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2496
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002497static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002498 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002499 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002500 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002501 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002502 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2503 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002504 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2505 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002506 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2507 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2508 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2509 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2510 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2511 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002512 {
2513 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2514 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002515 .info = alc_ch_mode_info,
2516 .get = alc_ch_mode_get,
2517 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002518 },
2519 { } /* end */
2520};
2521
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002522/*
2523 * ALC880 ASUS W1V model
2524 *
2525 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2526 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2527 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2528 */
2529
2530/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002531static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002532 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2533 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002534 { } /* end */
2535};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002536
Kailang Yangdf694da2005-12-05 19:42:22 +01002537/* TCL S700 */
2538static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2539 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2540 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2543 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2544 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2545 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2546 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2547 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002548 { } /* end */
2549};
2550
Kailang Yangccc656c2006-10-17 12:32:26 +02002551/* Uniwill */
2552static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2554 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2555 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2556 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002557 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2558 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2559 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2560 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2561 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2562 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2567 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002569 {
2570 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2571 .name = "Channel Mode",
2572 .info = alc_ch_mode_info,
2573 .get = alc_ch_mode_get,
2574 .put = alc_ch_mode_put,
2575 },
2576 { } /* end */
2577};
2578
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002579static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2580 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2581 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2583 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2584 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2585 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2586 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2587 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2588 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2589 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2590 { } /* end */
2591};
2592
Kailang Yangccc656c2006-10-17 12:32:26 +02002593static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002594 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2595 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2596 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2597 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2600 { } /* end */
2601};
2602
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002604 * virtual master controls
2605 */
2606
2607/*
2608 * slave controls for virtual master
2609 */
2610static const char *alc_slave_vols[] = {
2611 "Front Playback Volume",
2612 "Surround Playback Volume",
2613 "Center Playback Volume",
2614 "LFE Playback Volume",
2615 "Side Playback Volume",
2616 "Headphone Playback Volume",
2617 "Speaker Playback Volume",
2618 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002619 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002620 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002621 NULL,
2622};
2623
2624static const char *alc_slave_sws[] = {
2625 "Front Playback Switch",
2626 "Surround Playback Switch",
2627 "Center Playback Switch",
2628 "LFE Playback Switch",
2629 "Side Playback Switch",
2630 "Headphone Playback Switch",
2631 "Speaker Playback Switch",
2632 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002633 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002634 "Line-Out Playback Switch",
2635 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002636 NULL,
2637};
2638
2639/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002640 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002642
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002643#define NID_MAPPING (-1)
2644
2645#define SUBDEV_SPEAKER_ (0 << 6)
2646#define SUBDEV_HP_ (1 << 6)
2647#define SUBDEV_LINE_ (2 << 6)
2648#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2649#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2650#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2651
Takashi Iwai603c4012008-07-30 15:01:44 +02002652static void alc_free_kctls(struct hda_codec *codec);
2653
Takashi Iwai67d634c2009-11-16 15:35:59 +01002654#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002655/* additional beep mixers; the actual parameters are overwritten at build */
2656static struct snd_kcontrol_new alc_beep_mixer[] = {
2657 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002658 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002659 { } /* end */
2660};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002661#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002662
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663static int alc_build_controls(struct hda_codec *codec)
2664{
2665 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002666 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002667 struct snd_kcontrol_new *knew;
2668 int i, j, err;
2669 unsigned int u;
2670 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671
2672 for (i = 0; i < spec->num_mixers; i++) {
2673 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2674 if (err < 0)
2675 return err;
2676 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002677 if (spec->cap_mixer) {
2678 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2679 if (err < 0)
2680 return err;
2681 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002683 err = snd_hda_create_spdif_out_ctls(codec,
2684 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 if (err < 0)
2686 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002687 if (!spec->no_analog) {
2688 err = snd_hda_create_spdif_share_sw(codec,
2689 &spec->multiout);
2690 if (err < 0)
2691 return err;
2692 spec->multiout.share_spdif = 1;
2693 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 }
2695 if (spec->dig_in_nid) {
2696 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2697 if (err < 0)
2698 return err;
2699 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002700
Takashi Iwai67d634c2009-11-16 15:35:59 +01002701#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002702 /* create beep controls if needed */
2703 if (spec->beep_amp) {
2704 struct snd_kcontrol_new *knew;
2705 for (knew = alc_beep_mixer; knew->name; knew++) {
2706 struct snd_kcontrol *kctl;
2707 kctl = snd_ctl_new1(knew, codec);
2708 if (!kctl)
2709 return -ENOMEM;
2710 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002711 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002712 if (err < 0)
2713 return err;
2714 }
2715 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002716#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002717
Takashi Iwai2134ea42008-01-10 16:53:55 +01002718 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002719 if (!spec->no_analog &&
2720 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002721 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002722 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002723 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002724 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002725 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002726 if (err < 0)
2727 return err;
2728 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002729 if (!spec->no_analog &&
2730 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002731 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2732 NULL, alc_slave_sws);
2733 if (err < 0)
2734 return err;
2735 }
2736
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002737 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002738 if (spec->capsrc_nids || spec->adc_nids) {
2739 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2740 if (!kctl)
2741 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2742 for (i = 0; kctl && i < kctl->count; i++) {
2743 hda_nid_t *nids = spec->capsrc_nids;
2744 if (!nids)
2745 nids = spec->adc_nids;
2746 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2747 if (err < 0)
2748 return err;
2749 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002750 }
2751 if (spec->cap_mixer) {
2752 const char *kname = kctl ? kctl->id.name : NULL;
2753 for (knew = spec->cap_mixer; knew->name; knew++) {
2754 if (kname && strcmp(knew->name, kname) == 0)
2755 continue;
2756 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2757 for (i = 0; kctl && i < kctl->count; i++) {
2758 err = snd_hda_add_nid(codec, kctl, i,
2759 spec->adc_nids[i]);
2760 if (err < 0)
2761 return err;
2762 }
2763 }
2764 }
2765
2766 /* other nid->control mapping */
2767 for (i = 0; i < spec->num_mixers; i++) {
2768 for (knew = spec->mixers[i]; knew->name; knew++) {
2769 if (knew->iface != NID_MAPPING)
2770 continue;
2771 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2772 if (kctl == NULL)
2773 continue;
2774 u = knew->subdevice;
2775 for (j = 0; j < 4; j++, u >>= 8) {
2776 nid = u & 0x3f;
2777 if (nid == 0)
2778 continue;
2779 switch (u & 0xc0) {
2780 case SUBDEV_SPEAKER_:
2781 nid = spec->autocfg.speaker_pins[nid];
2782 break;
2783 case SUBDEV_LINE_:
2784 nid = spec->autocfg.line_out_pins[nid];
2785 break;
2786 case SUBDEV_HP_:
2787 nid = spec->autocfg.hp_pins[nid];
2788 break;
2789 default:
2790 continue;
2791 }
2792 err = snd_hda_add_nid(codec, kctl, 0, nid);
2793 if (err < 0)
2794 return err;
2795 }
2796 u = knew->private_value;
2797 for (j = 0; j < 4; j++, u >>= 8) {
2798 nid = u & 0xff;
2799 if (nid == 0)
2800 continue;
2801 err = snd_hda_add_nid(codec, kctl, 0, nid);
2802 if (err < 0)
2803 return err;
2804 }
2805 }
2806 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002807
2808 alc_free_kctls(codec); /* no longer needed */
2809
Linus Torvalds1da177e2005-04-16 15:20:36 -07002810 return 0;
2811}
2812
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002813
Linus Torvalds1da177e2005-04-16 15:20:36 -07002814/*
2815 * initialize the codec volumes, etc
2816 */
2817
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002818/*
2819 * generic initialization of ADC, input mixers and output mixers
2820 */
2821static struct hda_verb alc880_volume_init_verbs[] = {
2822 /*
2823 * Unmute ADC0-2 and set the default input to mic-in
2824 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002825 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002827 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002828 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002829 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002830 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002831
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002832 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2833 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002834 * Note: PASD motherboards uses the Line In 2 as the input for front
2835 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002836 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002838 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2839 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2840 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2841 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2842 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2843 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2844 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002845
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002846 /*
2847 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002848 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002849 /* set vol=0 to output mixers */
2850 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2851 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2852 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2853 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2854 /* set up input amps for analog loopback */
2855 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002856 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2857 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002858 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2859 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002860 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2861 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002862 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2863 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864
2865 { }
2866};
2867
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002868/*
2869 * 3-stack pin configuration:
2870 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2871 */
2872static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2873 /*
2874 * preset connection lists of input pins
2875 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2876 */
2877 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2878 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2879 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2880
2881 /*
2882 * Set pin mode and muting
2883 */
2884 /* set front pin widgets 0x14 for output */
2885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2886 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2887 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2888 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2889 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2890 /* Mic2 (as headphone out) for HP output */
2891 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2892 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2893 /* Line In pin widget for input */
2894 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2895 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2896 /* Line2 (as front mic) pin widget for input and vref at 80% */
2897 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2898 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2899 /* CD pin widget for input */
2900 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2901
2902 { }
2903};
2904
2905/*
2906 * 5-stack pin configuration:
2907 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2908 * line-in/side = 0x1a, f-mic = 0x1b
2909 */
2910static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2911 /*
2912 * preset connection lists of input pins
2913 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2914 */
2915 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2916 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2917
2918 /*
2919 * Set pin mode and muting
2920 */
2921 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002922 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2923 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2924 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2925 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002926 /* unmute pins for output (no gain on this amp) */
2927 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2928 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2929 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2930 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2931
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002933 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2935 /* Mic2 (as headphone out) for HP output */
2936 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002937 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002938 /* Line In pin widget for input */
2939 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2940 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2941 /* Line2 (as front mic) pin widget for input and vref at 80% */
2942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2943 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2944 /* CD pin widget for input */
2945 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946
2947 { }
2948};
2949
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002950/*
2951 * W810 pin configuration:
2952 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2953 */
2954static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 /* hphone/speaker input selector: front DAC */
2956 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2957
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2960 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2961 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2963 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2964
2965 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002966 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967
Linus Torvalds1da177e2005-04-16 15:20:36 -07002968 { }
2969};
2970
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002971/*
2972 * Z71V pin configuration:
2973 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2974 */
2975static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002977 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002978 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002980
Takashi Iwai16ded522005-06-10 19:58:24 +02002981 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002982 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002983 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002985
2986 { }
2987};
2988
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002989/*
2990 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002991 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2992 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002993 */
2994static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2995 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2996
Takashi Iwai16ded522005-06-10 19:58:24 +02002997 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003001 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003003 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003004 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3005
Takashi Iwai16ded522005-06-10 19:58:24 +02003006 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003007 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003008 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003009 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003010 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003011 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003013 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003014 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003015
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003016 { }
3017};
Takashi Iwai16ded522005-06-10 19:58:24 +02003018
Kailang Yangccc656c2006-10-17 12:32:26 +02003019/*
3020 * Uniwill pin configuration:
3021 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3022 * line = 0x1a
3023 */
3024static struct hda_verb alc880_uniwill_init_verbs[] = {
3025 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3026
3027 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3028 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3029 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3031 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3032 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3033 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3034 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3037 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3038 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3039 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3040 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3041
3042 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3043 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3044 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3046 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3048 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3049 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3050 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3051
3052 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3054
3055 { }
3056};
3057
3058/*
3059* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003060* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003061 */
3062static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3063 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3064
3065 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3066 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3071 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3073 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3075 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3077
3078 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3079 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3082 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3083 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3084
3085 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3086 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3087
3088 { }
3089};
3090
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003091static struct hda_verb alc880_beep_init_verbs[] = {
3092 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3093 { }
3094};
3095
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003096/* auto-toggle front mic */
3097static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3098{
3099 unsigned int present;
3100 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003101
Wu Fengguang864f92b2009-11-18 12:38:02 +08003102 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003103 bits = present ? HDA_AMP_MUTE : 0;
3104 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003105}
3106
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003107static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003108{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003109 struct alc_spec *spec = codec->spec;
3110
3111 spec->autocfg.hp_pins[0] = 0x14;
3112 spec->autocfg.speaker_pins[0] = 0x15;
3113 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003114}
3115
3116static void alc880_uniwill_init_hook(struct hda_codec *codec)
3117{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003118 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003119 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003120}
3121
3122static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3123 unsigned int res)
3124{
3125 /* Looks like the unsol event is incompatible with the standard
3126 * definition. 4bit tag is placed at 28 bit!
3127 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003128 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003129 case ALC880_MIC_EVENT:
3130 alc880_uniwill_mic_automute(codec);
3131 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003132 default:
3133 alc_automute_amp_unsol_event(codec, res);
3134 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003135 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003136}
3137
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003138static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003139{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003140 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003141
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003142 spec->autocfg.hp_pins[0] = 0x14;
3143 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003144}
3145
3146static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3147{
3148 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003149
Kailang Yangccc656c2006-10-17 12:32:26 +02003150 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003151 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3152 present &= HDA_AMP_VOLMASK;
3153 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3154 HDA_AMP_VOLMASK, present);
3155 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3156 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003157}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003158
Kailang Yangccc656c2006-10-17 12:32:26 +02003159static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3160 unsigned int res)
3161{
3162 /* Looks like the unsol event is incompatible with the standard
3163 * definition. 4bit tag is placed at 28 bit!
3164 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003165 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003166 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003167 else
3168 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003169}
3170
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003171/*
3172 * F1734 pin configuration:
3173 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3174 */
3175static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003176 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003177 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3178 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3179 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3180 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3181
3182 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3183 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186
3187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3188 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3191 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3192 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003196
Takashi Iwai937b4162008-02-11 14:52:36 +01003197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3198 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3199
Takashi Iwai16ded522005-06-10 19:58:24 +02003200 { }
3201};
3202
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003203/*
3204 * ASUS pin configuration:
3205 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3206 */
3207static struct hda_verb alc880_pin_asus_init_verbs[] = {
3208 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3209 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3210 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3211 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3212
3213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3214 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3215 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3216 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3217 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3219 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3221
3222 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3223 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3224 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3226 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3227 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3228 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3229 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3230 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003231
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003232 { }
3233};
3234
3235/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003236#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3237#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003238#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003239
Kailang Yangdf694da2005-12-05 19:42:22 +01003240/* Clevo m520g init */
3241static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3242 /* headphone output */
3243 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3244 /* line-out */
3245 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3246 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3247 /* Line-in */
3248 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3249 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3250 /* CD */
3251 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3252 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3253 /* Mic1 (rear panel) */
3254 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3255 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3256 /* Mic2 (front panel) */
3257 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3258 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3259 /* headphone */
3260 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3261 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3262 /* change to EAPD mode */
3263 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3264 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3265
3266 { }
3267};
3268
3269static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003270 /* change to EAPD mode */
3271 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3272 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3273
Kailang Yangdf694da2005-12-05 19:42:22 +01003274 /* Headphone output */
3275 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3276 /* Front output*/
3277 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3278 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3279
3280 /* Line In pin widget for input */
3281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3282 /* CD pin widget for input */
3283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3284 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3286
3287 /* change to EAPD mode */
3288 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3289 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3290
3291 { }
3292};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003293
3294/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003295 * LG m1 express dual
3296 *
3297 * Pin assignment:
3298 * Rear Line-In/Out (blue): 0x14
3299 * Build-in Mic-In: 0x15
3300 * Speaker-out: 0x17
3301 * HP-Out (green): 0x1b
3302 * Mic-In/Out (red): 0x19
3303 * SPDIF-Out: 0x1e
3304 */
3305
3306/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3307static hda_nid_t alc880_lg_dac_nids[3] = {
3308 0x05, 0x02, 0x03
3309};
3310
3311/* seems analog CD is not working */
3312static struct hda_input_mux alc880_lg_capture_source = {
3313 .num_items = 3,
3314 .items = {
3315 { "Mic", 0x1 },
3316 { "Line", 0x5 },
3317 { "Internal Mic", 0x6 },
3318 },
3319};
3320
3321/* 2,4,6 channel modes */
3322static struct hda_verb alc880_lg_ch2_init[] = {
3323 /* set line-in and mic-in to input */
3324 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3325 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3326 { }
3327};
3328
3329static struct hda_verb alc880_lg_ch4_init[] = {
3330 /* set line-in to out and mic-in to input */
3331 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3332 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3333 { }
3334};
3335
3336static struct hda_verb alc880_lg_ch6_init[] = {
3337 /* set line-in and mic-in to output */
3338 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3339 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3340 { }
3341};
3342
3343static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3344 { 2, alc880_lg_ch2_init },
3345 { 4, alc880_lg_ch4_init },
3346 { 6, alc880_lg_ch6_init },
3347};
3348
3349static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003350 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3351 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003352 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3353 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3354 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3355 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3356 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3357 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3360 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3361 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3362 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3363 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3364 {
3365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3366 .name = "Channel Mode",
3367 .info = alc_ch_mode_info,
3368 .get = alc_ch_mode_get,
3369 .put = alc_ch_mode_put,
3370 },
3371 { } /* end */
3372};
3373
3374static struct hda_verb alc880_lg_init_verbs[] = {
3375 /* set capture source to mic-in */
3376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3377 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3378 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3379 /* mute all amp mixer inputs */
3380 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003381 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3382 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003383 /* line-in to input */
3384 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3385 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3386 /* built-in mic */
3387 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3389 /* speaker-out */
3390 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3391 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3392 /* mic-in to input */
3393 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3394 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3396 /* HP-out */
3397 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3398 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3399 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3400 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003401 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003402 { }
3403};
3404
3405/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003406static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003407{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003408 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003409
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003410 spec->autocfg.hp_pins[0] = 0x1b;
3411 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003412}
3413
3414/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003415 * LG LW20
3416 *
3417 * Pin assignment:
3418 * Speaker-out: 0x14
3419 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003420 * Built-in Mic-In: 0x19
3421 * Line-In: 0x1b
3422 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003423 * SPDIF-Out: 0x1e
3424 */
3425
Takashi Iwaid6815182006-03-23 16:06:23 +01003426static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003427 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003428 .items = {
3429 { "Mic", 0x0 },
3430 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003431 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003432 },
3433};
3434
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003435#define alc880_lg_lw_modes alc880_threestack_modes
3436
Takashi Iwaid6815182006-03-23 16:06:23 +01003437static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003438 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3439 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3440 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3441 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3442 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3443 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3444 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3445 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003448 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3449 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3450 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3451 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003452 {
3453 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3454 .name = "Channel Mode",
3455 .info = alc_ch_mode_info,
3456 .get = alc_ch_mode_get,
3457 .put = alc_ch_mode_put,
3458 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003459 { } /* end */
3460};
3461
3462static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003463 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3464 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3465 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3466
Takashi Iwaid6815182006-03-23 16:06:23 +01003467 /* set capture source to mic-in */
3468 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3469 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3470 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003471 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003472 /* speaker-out */
3473 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003476 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3477 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 /* mic-in to input */
3479 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3481 /* built-in mic */
3482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3484 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003485 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003486 { }
3487};
3488
3489/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003490static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003491{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003492 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003493
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003494 spec->autocfg.hp_pins[0] = 0x1b;
3495 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003496}
3497
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003498static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3499 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3500 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3501 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3502 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3503 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3504 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3505 { } /* end */
3506};
3507
3508static struct hda_input_mux alc880_medion_rim_capture_source = {
3509 .num_items = 2,
3510 .items = {
3511 { "Mic", 0x0 },
3512 { "Internal Mic", 0x1 },
3513 },
3514};
3515
3516static struct hda_verb alc880_medion_rim_init_verbs[] = {
3517 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3518
3519 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3520 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521
3522 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3524 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3525 /* Mic2 (as headphone out) for HP output */
3526 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3527 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3528 /* Internal Speaker */
3529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3530 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3531
3532 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3533 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3534
3535 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3536 { }
3537};
3538
3539/* toggle speaker-output according to the hp-jack state */
3540static void alc880_medion_rim_automute(struct hda_codec *codec)
3541{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003542 struct alc_spec *spec = codec->spec;
3543 alc_automute_amp(codec);
3544 /* toggle EAPD */
3545 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003546 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3547 else
3548 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3549}
3550
3551static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3552 unsigned int res)
3553{
3554 /* Looks like the unsol event is incompatible with the standard
3555 * definition. 4bit tag is placed at 28 bit!
3556 */
3557 if ((res >> 28) == ALC880_HP_EVENT)
3558 alc880_medion_rim_automute(codec);
3559}
3560
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003561static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003562{
3563 struct alc_spec *spec = codec->spec;
3564
3565 spec->autocfg.hp_pins[0] = 0x14;
3566 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003567}
3568
Takashi Iwaicb53c622007-08-10 17:21:45 +02003569#ifdef CONFIG_SND_HDA_POWER_SAVE
3570static struct hda_amp_list alc880_loopbacks[] = {
3571 { 0x0b, HDA_INPUT, 0 },
3572 { 0x0b, HDA_INPUT, 1 },
3573 { 0x0b, HDA_INPUT, 2 },
3574 { 0x0b, HDA_INPUT, 3 },
3575 { 0x0b, HDA_INPUT, 4 },
3576 { } /* end */
3577};
3578
3579static struct hda_amp_list alc880_lg_loopbacks[] = {
3580 { 0x0b, HDA_INPUT, 1 },
3581 { 0x0b, HDA_INPUT, 6 },
3582 { 0x0b, HDA_INPUT, 7 },
3583 { } /* end */
3584};
3585#endif
3586
Takashi Iwaid6815182006-03-23 16:06:23 +01003587/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003588 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003590
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591static int alc_init(struct hda_codec *codec)
3592{
3593 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 unsigned int i;
3595
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003596 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003597 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003598
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003599 for (i = 0; i < spec->num_init_verbs; i++)
3600 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003601
3602 if (spec->init_hook)
3603 spec->init_hook(codec);
3604
Takashi Iwaiad358792010-03-30 18:00:59 +02003605#ifdef CONFIG_SND_HDA_POWER_SAVE
3606 if (codec->patch_ops.check_power_status)
3607 codec->patch_ops.check_power_status(codec, 0x01);
3608#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003609 return 0;
3610}
3611
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003612static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3613{
3614 struct alc_spec *spec = codec->spec;
3615
3616 if (spec->unsol_event)
3617 spec->unsol_event(codec, res);
3618}
3619
Takashi Iwaicb53c622007-08-10 17:21:45 +02003620#ifdef CONFIG_SND_HDA_POWER_SAVE
3621static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3622{
3623 struct alc_spec *spec = codec->spec;
3624 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3625}
3626#endif
3627
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628/*
3629 * Analog playback callbacks
3630 */
3631static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3632 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003633 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003634{
3635 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003636 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3637 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003638}
3639
3640static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3641 struct hda_codec *codec,
3642 unsigned int stream_tag,
3643 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003644 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003645{
3646 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003647 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3648 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003649}
3650
3651static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3652 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003653 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003654{
3655 struct alc_spec *spec = codec->spec;
3656 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3657}
3658
3659/*
3660 * Digital out
3661 */
3662static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3663 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003664 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003665{
3666 struct alc_spec *spec = codec->spec;
3667 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3668}
3669
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003670static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3671 struct hda_codec *codec,
3672 unsigned int stream_tag,
3673 unsigned int format,
3674 struct snd_pcm_substream *substream)
3675{
3676 struct alc_spec *spec = codec->spec;
3677 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3678 stream_tag, format, substream);
3679}
3680
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003681static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3682 struct hda_codec *codec,
3683 struct snd_pcm_substream *substream)
3684{
3685 struct alc_spec *spec = codec->spec;
3686 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3687}
3688
Linus Torvalds1da177e2005-04-16 15:20:36 -07003689static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3690 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003691 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003692{
3693 struct alc_spec *spec = codec->spec;
3694 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3695}
3696
3697/*
3698 * Analog capture
3699 */
Takashi Iwai63300792008-01-24 15:31:36 +01003700static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003701 struct hda_codec *codec,
3702 unsigned int stream_tag,
3703 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003704 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705{
3706 struct alc_spec *spec = codec->spec;
3707
Takashi Iwai63300792008-01-24 15:31:36 +01003708 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003709 stream_tag, 0, format);
3710 return 0;
3711}
3712
Takashi Iwai63300792008-01-24 15:31:36 +01003713static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003714 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003715 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716{
3717 struct alc_spec *spec = codec->spec;
3718
Takashi Iwai888afa12008-03-18 09:57:50 +01003719 snd_hda_codec_cleanup_stream(codec,
3720 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003721 return 0;
3722}
3723
Takashi Iwai840b64c2010-07-13 22:49:01 +02003724/* analog capture with dynamic dual-adc changes */
3725static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3726 struct hda_codec *codec,
3727 unsigned int stream_tag,
3728 unsigned int format,
3729 struct snd_pcm_substream *substream)
3730{
3731 struct alc_spec *spec = codec->spec;
3732 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3733 spec->cur_adc_stream_tag = stream_tag;
3734 spec->cur_adc_format = format;
3735 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3736 return 0;
3737}
3738
3739static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3740 struct hda_codec *codec,
3741 struct snd_pcm_substream *substream)
3742{
3743 struct alc_spec *spec = codec->spec;
3744 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3745 spec->cur_adc = 0;
3746 return 0;
3747}
3748
3749static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3750 .substreams = 1,
3751 .channels_min = 2,
3752 .channels_max = 2,
3753 .nid = 0, /* fill later */
3754 .ops = {
3755 .prepare = dualmic_capture_pcm_prepare,
3756 .cleanup = dualmic_capture_pcm_cleanup
3757 },
3758};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003759
3760/*
3761 */
3762static struct hda_pcm_stream alc880_pcm_analog_playback = {
3763 .substreams = 1,
3764 .channels_min = 2,
3765 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003767 .ops = {
3768 .open = alc880_playback_pcm_open,
3769 .prepare = alc880_playback_pcm_prepare,
3770 .cleanup = alc880_playback_pcm_cleanup
3771 },
3772};
3773
3774static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003775 .substreams = 1,
3776 .channels_min = 2,
3777 .channels_max = 2,
3778 /* NID is set in alc_build_pcms */
3779};
3780
3781static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3782 .substreams = 1,
3783 .channels_min = 2,
3784 .channels_max = 2,
3785 /* NID is set in alc_build_pcms */
3786};
3787
3788static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3789 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003790 .channels_min = 2,
3791 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003792 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003793 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003794 .prepare = alc880_alt_capture_pcm_prepare,
3795 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003796 },
3797};
3798
3799static struct hda_pcm_stream alc880_pcm_digital_playback = {
3800 .substreams = 1,
3801 .channels_min = 2,
3802 .channels_max = 2,
3803 /* NID is set in alc_build_pcms */
3804 .ops = {
3805 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003806 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003807 .prepare = alc880_dig_playback_pcm_prepare,
3808 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003809 },
3810};
3811
3812static struct hda_pcm_stream alc880_pcm_digital_capture = {
3813 .substreams = 1,
3814 .channels_min = 2,
3815 .channels_max = 2,
3816 /* NID is set in alc_build_pcms */
3817};
3818
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003819/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003820static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003821 .substreams = 0,
3822 .channels_min = 0,
3823 .channels_max = 0,
3824};
3825
Linus Torvalds1da177e2005-04-16 15:20:36 -07003826static int alc_build_pcms(struct hda_codec *codec)
3827{
3828 struct alc_spec *spec = codec->spec;
3829 struct hda_pcm *info = spec->pcm_rec;
3830 int i;
3831
3832 codec->num_pcms = 1;
3833 codec->pcm_info = info;
3834
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003835 if (spec->no_analog)
3836 goto skip_analog;
3837
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003838 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3839 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003840 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003841
Takashi Iwai4a471b72005-12-07 13:56:29 +01003842 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003843 if (snd_BUG_ON(!spec->multiout.dac_nids))
3844 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003845 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3846 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3847 }
3848 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003849 if (snd_BUG_ON(!spec->adc_nids))
3850 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003851 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3852 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3853 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003854
Takashi Iwai4a471b72005-12-07 13:56:29 +01003855 if (spec->channel_mode) {
3856 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3857 for (i = 0; i < spec->num_channel_mode; i++) {
3858 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3859 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3860 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861 }
3862 }
3863
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003864 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003865 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003866 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003867 snprintf(spec->stream_name_digital,
3868 sizeof(spec->stream_name_digital),
3869 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003870 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003871 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003872 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003873 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003874 if (spec->dig_out_type)
3875 info->pcm_type = spec->dig_out_type;
3876 else
3877 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003878 if (spec->multiout.dig_out_nid &&
3879 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003880 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3881 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3882 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003883 if (spec->dig_in_nid &&
3884 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3886 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3887 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003888 /* FIXME: do we need this for all Realtek codec models? */
3889 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003890 }
3891
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003892 if (spec->no_analog)
3893 return 0;
3894
Takashi Iwaie08a0072006-09-07 17:52:14 +02003895 /* If the use of more than one ADC is requested for the current
3896 * model, configure a second analog capture-only PCM.
3897 */
3898 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003899 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3900 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003901 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003902 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003903 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003904 if (spec->alt_dac_nid) {
3905 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3906 *spec->stream_analog_alt_playback;
3907 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3908 spec->alt_dac_nid;
3909 } else {
3910 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3911 alc_pcm_null_stream;
3912 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3913 }
3914 if (spec->num_adc_nids > 1) {
3915 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3916 *spec->stream_analog_alt_capture;
3917 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3918 spec->adc_nids[1];
3919 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3920 spec->num_adc_nids - 1;
3921 } else {
3922 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3923 alc_pcm_null_stream;
3924 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003925 }
3926 }
3927
Linus Torvalds1da177e2005-04-16 15:20:36 -07003928 return 0;
3929}
3930
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003931static inline void alc_shutup(struct hda_codec *codec)
3932{
3933 snd_hda_shutup_pins(codec);
3934}
3935
Takashi Iwai603c4012008-07-30 15:01:44 +02003936static void alc_free_kctls(struct hda_codec *codec)
3937{
3938 struct alc_spec *spec = codec->spec;
3939
3940 if (spec->kctls.list) {
3941 struct snd_kcontrol_new *kctl = spec->kctls.list;
3942 int i;
3943 for (i = 0; i < spec->kctls.used; i++)
3944 kfree(kctl[i].name);
3945 }
3946 snd_array_free(&spec->kctls);
3947}
3948
Linus Torvalds1da177e2005-04-16 15:20:36 -07003949static void alc_free(struct hda_codec *codec)
3950{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003951 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003952
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003953 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003954 return;
3955
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003956 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003957 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003959 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003960}
3961
Hector Martinf5de24b2009-12-20 22:51:31 +01003962#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003963static void alc_power_eapd(struct hda_codec *codec)
3964{
3965 /* We currently only handle front, HP */
3966 switch (codec->vendor_id) {
3967 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003968 set_eapd(codec, 0x0f, 0);
3969 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003970 break;
3971 case 0x10ec0262:
3972 case 0x10ec0267:
3973 case 0x10ec0268:
3974 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003975 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003976 case 0x10ec0272:
3977 case 0x10ec0660:
3978 case 0x10ec0662:
3979 case 0x10ec0663:
3980 case 0x10ec0862:
3981 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003982 set_eapd(codec, 0x14, 0);
3983 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003984 break;
3985 }
3986}
3987
Hector Martinf5de24b2009-12-20 22:51:31 +01003988static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3989{
3990 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003991 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003992 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003993 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003994 return 0;
3995}
3996#endif
3997
Takashi Iwaie044c392008-10-27 16:56:24 +01003998#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003999static int alc_resume(struct hda_codec *codec)
4000{
Takashi Iwaie044c392008-10-27 16:56:24 +01004001 codec->patch_ops.init(codec);
4002 snd_hda_codec_resume_amp(codec);
4003 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02004004#ifdef CONFIG_SND_HDA_POWER_SAVE
4005 if (codec->patch_ops.check_power_status)
4006 codec->patch_ops.check_power_status(codec, 0x01);
4007#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01004008 return 0;
4009}
Takashi Iwaie044c392008-10-27 16:56:24 +01004010#endif
4011
Linus Torvalds1da177e2005-04-16 15:20:36 -07004012/*
4013 */
4014static struct hda_codec_ops alc_patch_ops = {
4015 .build_controls = alc_build_controls,
4016 .build_pcms = alc_build_pcms,
4017 .init = alc_init,
4018 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004019 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004020#ifdef SND_HDA_NEEDS_RESUME
4021 .resume = alc_resume,
4022#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004023#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004024 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004025 .check_power_status = alc_check_power_status,
4026#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004027 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004028};
4029
Kailang Yangc027ddc2010-03-19 11:33:06 +01004030/* replace the codec chip_name with the given string */
4031static int alc_codec_rename(struct hda_codec *codec, const char *name)
4032{
4033 kfree(codec->chip_name);
4034 codec->chip_name = kstrdup(name, GFP_KERNEL);
4035 if (!codec->chip_name) {
4036 alc_free(codec);
4037 return -ENOMEM;
4038 }
4039 return 0;
4040}
4041
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004042/*
4043 * Test configuration for debugging
4044 *
4045 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4046 * enum controls.
4047 */
4048#ifdef CONFIG_SND_DEBUG
4049static hda_nid_t alc880_test_dac_nids[4] = {
4050 0x02, 0x03, 0x04, 0x05
4051};
4052
4053static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004054 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004055 .items = {
4056 { "In-1", 0x0 },
4057 { "In-2", 0x1 },
4058 { "In-3", 0x2 },
4059 { "In-4", 0x3 },
4060 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004061 { "Front", 0x5 },
4062 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004063 },
4064};
4065
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004066static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004067 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004068 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004069 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004070 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004071};
4072
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004073static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4074 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004075{
4076 static char *texts[] = {
4077 "N/A", "Line Out", "HP Out",
4078 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4079 };
4080 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4081 uinfo->count = 1;
4082 uinfo->value.enumerated.items = 8;
4083 if (uinfo->value.enumerated.item >= 8)
4084 uinfo->value.enumerated.item = 7;
4085 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4086 return 0;
4087}
4088
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004089static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4090 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004091{
4092 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4093 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4094 unsigned int pin_ctl, item = 0;
4095
4096 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4097 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4098 if (pin_ctl & AC_PINCTL_OUT_EN) {
4099 if (pin_ctl & AC_PINCTL_HP_EN)
4100 item = 2;
4101 else
4102 item = 1;
4103 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4104 switch (pin_ctl & AC_PINCTL_VREFEN) {
4105 case AC_PINCTL_VREF_HIZ: item = 3; break;
4106 case AC_PINCTL_VREF_50: item = 4; break;
4107 case AC_PINCTL_VREF_GRD: item = 5; break;
4108 case AC_PINCTL_VREF_80: item = 6; break;
4109 case AC_PINCTL_VREF_100: item = 7; break;
4110 }
4111 }
4112 ucontrol->value.enumerated.item[0] = item;
4113 return 0;
4114}
4115
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004116static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4117 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004118{
4119 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4120 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4121 static unsigned int ctls[] = {
4122 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4123 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4124 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4125 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4126 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4127 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4128 };
4129 unsigned int old_ctl, new_ctl;
4130
4131 old_ctl = snd_hda_codec_read(codec, nid, 0,
4132 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4133 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4134 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004135 int val;
4136 snd_hda_codec_write_cache(codec, nid, 0,
4137 AC_VERB_SET_PIN_WIDGET_CONTROL,
4138 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004139 val = ucontrol->value.enumerated.item[0] >= 3 ?
4140 HDA_AMP_MUTE : 0;
4141 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4142 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004143 return 1;
4144 }
4145 return 0;
4146}
4147
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004148static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4149 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004150{
4151 static char *texts[] = {
4152 "Front", "Surround", "CLFE", "Side"
4153 };
4154 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4155 uinfo->count = 1;
4156 uinfo->value.enumerated.items = 4;
4157 if (uinfo->value.enumerated.item >= 4)
4158 uinfo->value.enumerated.item = 3;
4159 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4160 return 0;
4161}
4162
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004163static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4164 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004165{
4166 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4167 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4168 unsigned int sel;
4169
4170 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4171 ucontrol->value.enumerated.item[0] = sel & 3;
4172 return 0;
4173}
4174
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004175static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4176 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004177{
4178 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4179 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4180 unsigned int sel;
4181
4182 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4183 if (ucontrol->value.enumerated.item[0] != sel) {
4184 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004185 snd_hda_codec_write_cache(codec, nid, 0,
4186 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004187 return 1;
4188 }
4189 return 0;
4190}
4191
4192#define PIN_CTL_TEST(xname,nid) { \
4193 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4194 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004195 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004196 .info = alc_test_pin_ctl_info, \
4197 .get = alc_test_pin_ctl_get, \
4198 .put = alc_test_pin_ctl_put, \
4199 .private_value = nid \
4200 }
4201
4202#define PIN_SRC_TEST(xname,nid) { \
4203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4204 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004205 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004206 .info = alc_test_pin_src_info, \
4207 .get = alc_test_pin_src_get, \
4208 .put = alc_test_pin_src_put, \
4209 .private_value = nid \
4210 }
4211
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004212static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004213 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4214 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4215 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4216 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4218 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4219 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4220 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004221 PIN_CTL_TEST("Front Pin Mode", 0x14),
4222 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4223 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4224 PIN_CTL_TEST("Side Pin Mode", 0x17),
4225 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4226 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4227 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4228 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4229 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4230 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4231 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4232 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4233 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4234 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4235 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4236 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4237 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4238 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4239 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4240 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4241 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4242 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004243 {
4244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4245 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004246 .info = alc_ch_mode_info,
4247 .get = alc_ch_mode_get,
4248 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004249 },
4250 { } /* end */
4251};
4252
4253static struct hda_verb alc880_test_init_verbs[] = {
4254 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4256 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4257 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4261 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4262 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004263 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4266 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4267 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004268 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4270 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4271 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4272 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004273 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004274 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4275 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4276 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4277 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004278 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4280 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004281 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4282 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4283 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004284 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004285 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4286 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4287 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004289 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004291 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004292 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004293 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004295 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004296 /* Analog input/passthru */
4297 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4298 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4300 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4301 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004302 { }
4303};
4304#endif
4305
Linus Torvalds1da177e2005-04-16 15:20:36 -07004306/*
4307 */
4308
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004309static const char *alc880_models[ALC880_MODEL_LAST] = {
4310 [ALC880_3ST] = "3stack",
4311 [ALC880_TCL_S700] = "tcl",
4312 [ALC880_3ST_DIG] = "3stack-digout",
4313 [ALC880_CLEVO] = "clevo",
4314 [ALC880_5ST] = "5stack",
4315 [ALC880_5ST_DIG] = "5stack-digout",
4316 [ALC880_W810] = "w810",
4317 [ALC880_Z71V] = "z71v",
4318 [ALC880_6ST] = "6stack",
4319 [ALC880_6ST_DIG] = "6stack-digout",
4320 [ALC880_ASUS] = "asus",
4321 [ALC880_ASUS_W1V] = "asus-w1v",
4322 [ALC880_ASUS_DIG] = "asus-dig",
4323 [ALC880_ASUS_DIG2] = "asus-dig2",
4324 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004325 [ALC880_UNIWILL_P53] = "uniwill-p53",
4326 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004327 [ALC880_F1734] = "F1734",
4328 [ALC880_LG] = "lg",
4329 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004330 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004332 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004333#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004334 [ALC880_AUTO] = "auto",
4335};
4336
4337static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004338 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004339 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4340 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4341 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4342 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4343 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4344 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4345 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4346 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004347 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4348 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004349 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4350 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4351 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4352 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4353 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4354 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4355 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4356 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4357 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4358 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004359 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004360 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4361 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4362 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004363 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004364 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004365 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4366 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004367 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4368 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004369 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4370 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4371 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4372 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004373 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4374 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004375 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004376 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004377 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004378 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004379 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4380 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004381 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004382 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004383 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004384 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004385 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004386 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004387 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004388 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004389 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004390 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4391 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004392 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004393 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4394 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4395 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4396 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004397 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4398 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004399 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004400 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004401 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4402 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004403 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4404 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4405 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004406 /* default Intel */
4407 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004408 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4409 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004410 {}
4411};
4412
Takashi Iwai16ded522005-06-10 19:58:24 +02004413/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004414 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004415 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004416static struct alc_config_preset alc880_presets[] = {
4417 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004418 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004419 .init_verbs = { alc880_volume_init_verbs,
4420 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004421 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004422 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004423 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4424 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004425 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004426 .input_mux = &alc880_capture_source,
4427 },
4428 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004429 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004430 .init_verbs = { alc880_volume_init_verbs,
4431 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004432 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004433 .dac_nids = alc880_dac_nids,
4434 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004435 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4436 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004437 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004438 .input_mux = &alc880_capture_source,
4439 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004440 [ALC880_TCL_S700] = {
4441 .mixers = { alc880_tcl_s700_mixer },
4442 .init_verbs = { alc880_volume_init_verbs,
4443 alc880_pin_tcl_S700_init_verbs,
4444 alc880_gpio2_init_verbs },
4445 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4446 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004447 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4448 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004449 .hp_nid = 0x03,
4450 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4451 .channel_mode = alc880_2_jack_modes,
4452 .input_mux = &alc880_capture_source,
4453 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004454 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004455 .mixers = { alc880_three_stack_mixer,
4456 alc880_five_stack_mixer},
4457 .init_verbs = { alc880_volume_init_verbs,
4458 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004459 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4460 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004461 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4462 .channel_mode = alc880_fivestack_modes,
4463 .input_mux = &alc880_capture_source,
4464 },
4465 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004466 .mixers = { alc880_three_stack_mixer,
4467 alc880_five_stack_mixer },
4468 .init_verbs = { alc880_volume_init_verbs,
4469 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004470 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4471 .dac_nids = alc880_dac_nids,
4472 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004473 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4474 .channel_mode = alc880_fivestack_modes,
4475 .input_mux = &alc880_capture_source,
4476 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004477 [ALC880_6ST] = {
4478 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004479 .init_verbs = { alc880_volume_init_verbs,
4480 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004481 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4482 .dac_nids = alc880_6st_dac_nids,
4483 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4484 .channel_mode = alc880_sixstack_modes,
4485 .input_mux = &alc880_6stack_capture_source,
4486 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004487 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004489 .init_verbs = { alc880_volume_init_verbs,
4490 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004491 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4492 .dac_nids = alc880_6st_dac_nids,
4493 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004494 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4495 .channel_mode = alc880_sixstack_modes,
4496 .input_mux = &alc880_6stack_capture_source,
4497 },
4498 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004499 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004500 .init_verbs = { alc880_volume_init_verbs,
4501 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004502 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004503 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4504 .dac_nids = alc880_w810_dac_nids,
4505 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004506 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4507 .channel_mode = alc880_w810_modes,
4508 .input_mux = &alc880_capture_source,
4509 },
4510 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004511 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004512 .init_verbs = { alc880_volume_init_verbs,
4513 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004514 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4515 .dac_nids = alc880_z71v_dac_nids,
4516 .dig_out_nid = ALC880_DIGOUT_NID,
4517 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4519 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004520 .input_mux = &alc880_capture_source,
4521 },
4522 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004523 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004524 .init_verbs = { alc880_volume_init_verbs,
4525 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004526 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4527 .dac_nids = alc880_f1734_dac_nids,
4528 .hp_nid = 0x02,
4529 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4530 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004531 .input_mux = &alc880_f1734_capture_source,
4532 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004533 .setup = alc880_uniwill_p53_setup,
4534 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004535 },
4536 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004537 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004538 .init_verbs = { alc880_volume_init_verbs,
4539 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004540 alc880_gpio1_init_verbs },
4541 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4542 .dac_nids = alc880_asus_dac_nids,
4543 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4544 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004545 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004546 .input_mux = &alc880_capture_source,
4547 },
4548 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004549 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004550 .init_verbs = { alc880_volume_init_verbs,
4551 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004552 alc880_gpio1_init_verbs },
4553 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4554 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004555 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004556 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4557 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004558 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004559 .input_mux = &alc880_capture_source,
4560 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004561 [ALC880_ASUS_DIG2] = {
4562 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004563 .init_verbs = { alc880_volume_init_verbs,
4564 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004565 alc880_gpio2_init_verbs }, /* use GPIO2 */
4566 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4567 .dac_nids = alc880_asus_dac_nids,
4568 .dig_out_nid = ALC880_DIGOUT_NID,
4569 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4570 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004571 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004572 .input_mux = &alc880_capture_source,
4573 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004574 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004576 .init_verbs = { alc880_volume_init_verbs,
4577 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004578 alc880_gpio1_init_verbs },
4579 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4580 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004581 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4583 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004584 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004585 .input_mux = &alc880_capture_source,
4586 },
4587 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004588 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004589 .init_verbs = { alc880_volume_init_verbs,
4590 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004591 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4592 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004593 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4595 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004596 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004597 .input_mux = &alc880_capture_source,
4598 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004599 [ALC880_UNIWILL] = {
4600 .mixers = { alc880_uniwill_mixer },
4601 .init_verbs = { alc880_volume_init_verbs,
4602 alc880_uniwill_init_verbs },
4603 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4604 .dac_nids = alc880_asus_dac_nids,
4605 .dig_out_nid = ALC880_DIGOUT_NID,
4606 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4607 .channel_mode = alc880_threestack_modes,
4608 .need_dac_fix = 1,
4609 .input_mux = &alc880_capture_source,
4610 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004611 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004612 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004613 },
4614 [ALC880_UNIWILL_P53] = {
4615 .mixers = { alc880_uniwill_p53_mixer },
4616 .init_verbs = { alc880_volume_init_verbs,
4617 alc880_uniwill_p53_init_verbs },
4618 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4619 .dac_nids = alc880_asus_dac_nids,
4620 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004621 .channel_mode = alc880_threestack_modes,
4622 .input_mux = &alc880_capture_source,
4623 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004624 .setup = alc880_uniwill_p53_setup,
4625 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004626 },
4627 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004628 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004629 .init_verbs = { alc880_volume_init_verbs,
4630 alc880_uniwill_p53_init_verbs,
4631 alc880_beep_init_verbs },
4632 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4633 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004634 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004635 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4636 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004637 .input_mux = &alc880_capture_source,
4638 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004639 .setup = alc880_uniwill_p53_setup,
4640 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004641 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004642 [ALC880_CLEVO] = {
4643 .mixers = { alc880_three_stack_mixer },
4644 .init_verbs = { alc880_volume_init_verbs,
4645 alc880_pin_clevo_init_verbs },
4646 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4647 .dac_nids = alc880_dac_nids,
4648 .hp_nid = 0x03,
4649 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4650 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004651 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004652 .input_mux = &alc880_capture_source,
4653 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004654 [ALC880_LG] = {
4655 .mixers = { alc880_lg_mixer },
4656 .init_verbs = { alc880_volume_init_verbs,
4657 alc880_lg_init_verbs },
4658 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4659 .dac_nids = alc880_lg_dac_nids,
4660 .dig_out_nid = ALC880_DIGOUT_NID,
4661 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4662 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004663 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004664 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004665 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004666 .setup = alc880_lg_setup,
4667 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004668#ifdef CONFIG_SND_HDA_POWER_SAVE
4669 .loopbacks = alc880_lg_loopbacks,
4670#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004671 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004672 [ALC880_LG_LW] = {
4673 .mixers = { alc880_lg_lw_mixer },
4674 .init_verbs = { alc880_volume_init_verbs,
4675 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004676 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004677 .dac_nids = alc880_dac_nids,
4678 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004679 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4680 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004681 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004682 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004683 .setup = alc880_lg_lw_setup,
4684 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004685 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004686 [ALC880_MEDION_RIM] = {
4687 .mixers = { alc880_medion_rim_mixer },
4688 .init_verbs = { alc880_volume_init_verbs,
4689 alc880_medion_rim_init_verbs,
4690 alc_gpio2_init_verbs },
4691 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4692 .dac_nids = alc880_dac_nids,
4693 .dig_out_nid = ALC880_DIGOUT_NID,
4694 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4695 .channel_mode = alc880_2_jack_modes,
4696 .input_mux = &alc880_medion_rim_capture_source,
4697 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004698 .setup = alc880_medion_rim_setup,
4699 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004700 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004701#ifdef CONFIG_SND_DEBUG
4702 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004703 .mixers = { alc880_test_mixer },
4704 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004705 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4706 .dac_nids = alc880_test_dac_nids,
4707 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004708 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4709 .channel_mode = alc880_test_modes,
4710 .input_mux = &alc880_test_capture_source,
4711 },
4712#endif
4713};
4714
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715/*
4716 * Automatic parse of I/O pins from the BIOS configuration
4717 */
4718
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004719enum {
4720 ALC_CTL_WIDGET_VOL,
4721 ALC_CTL_WIDGET_MUTE,
4722 ALC_CTL_BIND_MUTE,
4723};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004724static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004725 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4726 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004727 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004728};
4729
4730/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004731static int add_control(struct alc_spec *spec, int type, const char *name,
4732 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004733{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004734 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004735
Takashi Iwai603c4012008-07-30 15:01:44 +02004736 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4737 knew = snd_array_new(&spec->kctls);
4738 if (!knew)
4739 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004740 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004741 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004743 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004744 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004745 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004746 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004747 return 0;
4748}
4749
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004750static int add_control_with_pfx(struct alc_spec *spec, int type,
4751 const char *pfx, const char *dir,
4752 const char *sfx, unsigned long val)
4753{
4754 char name[32];
4755 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4756 return add_control(spec, type, name, val);
4757}
4758
4759#define add_pb_vol_ctrl(spec, type, pfx, val) \
4760 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4761#define add_pb_sw_ctrl(spec, type, pfx, val) \
4762 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4763
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4765#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4766#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4767#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4769#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4770#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4771#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4772#define ALC880_PIN_CD_NID 0x1c
4773
4774/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004775static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4776 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004777{
4778 hda_nid_t nid;
4779 int assigned[4];
4780 int i, j;
4781
4782 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004783 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004784
4785 /* check the pins hardwired to audio widget */
4786 for (i = 0; i < cfg->line_outs; i++) {
4787 nid = cfg->line_out_pins[i];
4788 if (alc880_is_fixed_pin(nid)) {
4789 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004790 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004791 assigned[idx] = 1;
4792 }
4793 }
4794 /* left pins can be connect to any audio widget */
4795 for (i = 0; i < cfg->line_outs; i++) {
4796 nid = cfg->line_out_pins[i];
4797 if (alc880_is_fixed_pin(nid))
4798 continue;
4799 /* search for an empty channel */
4800 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004801 if (!assigned[j]) {
4802 spec->multiout.dac_nids[i] =
4803 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004804 assigned[j] = 1;
4805 break;
4806 }
4807 }
4808 }
4809 spec->multiout.num_dacs = cfg->line_outs;
4810 return 0;
4811}
4812
4813/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004814static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4815 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 static const char *chname[4] = {
4818 "Front", "Surround", NULL /*CLFE*/, "Side"
4819 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004820 hda_nid_t nid;
4821 int i, err;
4822
4823 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004824 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004825 continue;
4826 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4827 if (i == 2) {
4828 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004829 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4830 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004831 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4832 HDA_OUTPUT));
4833 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004834 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004835 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4836 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004837 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4838 HDA_OUTPUT));
4839 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004840 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004841 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4842 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004843 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4844 HDA_INPUT));
4845 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004846 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004847 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4848 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004849 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4850 HDA_INPUT));
4851 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004852 return err;
4853 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004854 const char *pfx;
4855 if (cfg->line_outs == 1 &&
4856 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4857 pfx = "Speaker";
4858 else
4859 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004860 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004861 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4862 HDA_OUTPUT));
4863 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004864 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004865 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004866 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4867 HDA_INPUT));
4868 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 return err;
4870 }
4871 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004872 return 0;
4873}
4874
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004875/* add playback controls for speaker and HP outputs */
4876static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4877 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004878{
4879 hda_nid_t nid;
4880 int err;
4881
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004882 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004883 return 0;
4884
4885 if (alc880_is_fixed_pin(pin)) {
4886 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004887 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004888 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004889 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004890 else
4891 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004892 /* control HP volume/switch on the output mixer amp */
4893 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004894 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004895 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4896 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004897 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004898 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004899 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4900 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004901 return err;
4902 } else if (alc880_is_multi_pin(pin)) {
4903 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004904 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004905 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004906 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4907 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004908 return err;
4909 }
4910 return 0;
4911}
4912
4913/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004914static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4915 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004916 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004917{
Kailang Yangdf694da2005-12-05 19:42:22 +01004918 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004919
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004920 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004921 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4922 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004923 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004924 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004925 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4926 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004927 return err;
4928 return 0;
4929}
4930
Takashi Iwai05f5f472009-08-25 13:10:18 +02004931static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004932{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004933 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4934 return (pincap & AC_PINCAP_IN) != 0;
4935}
4936
4937/* create playback/capture controls for input pins */
4938static int alc_auto_create_input_ctls(struct hda_codec *codec,
4939 const struct auto_pin_cfg *cfg,
4940 hda_nid_t mixer,
4941 hda_nid_t cap1, hda_nid_t cap2)
4942{
4943 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004944 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004945 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004946
4947 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004948 hda_nid_t pin;
4949
4950 pin = cfg->input_pins[i];
4951 if (!alc_is_input_pin(codec, pin))
4952 continue;
4953
4954 if (mixer) {
4955 idx = get_connection_index(codec, mixer, pin);
4956 if (idx >= 0) {
4957 err = new_analog_input(spec, pin,
4958 auto_pin_cfg_labels[i],
4959 idx, mixer);
4960 if (err < 0)
4961 return err;
4962 }
4963 }
4964
4965 if (!cap1)
4966 continue;
4967 idx = get_connection_index(codec, cap1, pin);
4968 if (idx < 0 && cap2)
4969 idx = get_connection_index(codec, cap2, pin);
4970 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004971 imux->items[imux->num_items].label =
4972 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004973 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004974 imux->num_items++;
4975 }
4976 }
4977 return 0;
4978}
4979
Takashi Iwai05f5f472009-08-25 13:10:18 +02004980static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4981 const struct auto_pin_cfg *cfg)
4982{
4983 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4984}
4985
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004986static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4987 unsigned int pin_type)
4988{
4989 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4990 pin_type);
4991 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004992 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4993 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004994}
4995
Kailang Yangdf694da2005-12-05 19:42:22 +01004996static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4997 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004998 int dac_idx)
4999{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005000 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001 /* need the manual connection? */
5002 if (alc880_is_multi_pin(nid)) {
5003 struct alc_spec *spec = codec->spec;
5004 int idx = alc880_multi_pin_idx(nid);
5005 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5006 AC_VERB_SET_CONNECT_SEL,
5007 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5008 }
5009}
5010
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005011static int get_pin_type(int line_out_type)
5012{
5013 if (line_out_type == AUTO_PIN_HP_OUT)
5014 return PIN_HP;
5015 else
5016 return PIN_OUT;
5017}
5018
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005019static void alc880_auto_init_multi_out(struct hda_codec *codec)
5020{
5021 struct alc_spec *spec = codec->spec;
5022 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005023
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005024 for (i = 0; i < spec->autocfg.line_outs; i++) {
5025 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005026 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5027 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005028 }
5029}
5030
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005031static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005032{
5033 struct alc_spec *spec = codec->spec;
5034 hda_nid_t pin;
5035
Takashi Iwai82bc9552006-03-21 11:24:42 +01005036 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005037 if (pin) /* connect to front */
5038 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005039 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005040 if (pin) /* connect to front */
5041 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5042}
5043
5044static void alc880_auto_init_analog_input(struct hda_codec *codec)
5045{
5046 struct alc_spec *spec = codec->spec;
5047 int i;
5048
5049 for (i = 0; i < AUTO_PIN_LAST; i++) {
5050 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02005051 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01005052 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005053 if (nid != ALC880_PIN_CD_NID &&
5054 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005055 snd_hda_codec_write(codec, nid, 0,
5056 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005057 AMP_OUT_MUTE);
5058 }
5059 }
5060}
5061
Takashi Iwai7f311a42010-04-09 17:32:23 +02005062static void alc880_auto_init_input_src(struct hda_codec *codec)
5063{
5064 struct alc_spec *spec = codec->spec;
5065 int c;
5066
5067 for (c = 0; c < spec->num_adc_nids; c++) {
5068 unsigned int mux_idx;
5069 const struct hda_input_mux *imux;
5070 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5071 imux = &spec->input_mux[mux_idx];
5072 if (!imux->num_items && mux_idx > 0)
5073 imux = &spec->input_mux[0];
5074 if (imux)
5075 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5076 AC_VERB_SET_CONNECT_SEL,
5077 imux->items[0].index);
5078 }
5079}
5080
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005081/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005082/* return 1 if successful, 0 if the proper config is not found,
5083 * or a negative error code
5084 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005085static int alc880_parse_auto_config(struct hda_codec *codec)
5086{
5087 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005088 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005089 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005090
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005091 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5092 alc880_ignore);
5093 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005096 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005097
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005098 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5099 if (err < 0)
5100 return err;
5101 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5102 if (err < 0)
5103 return err;
5104 err = alc880_auto_create_extra_out(spec,
5105 spec->autocfg.speaker_pins[0],
5106 "Speaker");
5107 if (err < 0)
5108 return err;
5109 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5110 "Headphone");
5111 if (err < 0)
5112 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005113 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005114 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005115 return err;
5116
5117 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5118
Takashi Iwai757899a2010-07-30 10:48:14 +02005119 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005120
Takashi Iwai603c4012008-07-30 15:01:44 +02005121 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005122 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005123
Takashi Iwaid88897e2008-10-31 15:01:37 +01005124 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005125
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005126 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005127 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005128
Kailang Yang6227cdc2010-02-25 08:36:52 +01005129 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005130
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005131 return 1;
5132}
5133
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005134/* additional initialization for auto-configuration model */
5135static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005137 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005138 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005139 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005140 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005141 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005142 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005143 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005144 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005145}
5146
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005147/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5148 * one of two digital mic pins, e.g. on ALC272
5149 */
5150static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005151{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005152 struct alc_spec *spec = codec->spec;
5153 int i;
5154
5155 for (i = 0; i < spec->num_adc_nids; i++) {
5156 hda_nid_t cap = spec->capsrc_nids ?
5157 spec->capsrc_nids[i] : spec->adc_nids[i];
5158 int iidx, eidx;
5159
5160 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5161 if (iidx < 0)
5162 continue;
5163 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5164 if (eidx < 0)
5165 continue;
5166 spec->int_mic.mux_idx = iidx;
5167 spec->ext_mic.mux_idx = eidx;
5168 if (spec->capsrc_nids)
5169 spec->capsrc_nids += i;
5170 spec->adc_nids += i;
5171 spec->num_adc_nids = 1;
5172 return;
5173 }
5174 snd_printd(KERN_INFO "hda_codec: %s: "
5175 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5176 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5177 spec->auto_mic = 0; /* disable auto-mic to be sure */
5178}
5179
Takashi Iwai748cce42010-08-04 07:37:39 +02005180/* select or unmute the given capsrc route */
5181static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5182 int idx)
5183{
5184 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5185 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5186 HDA_AMP_MUTE, 0);
5187 } else {
5188 snd_hda_codec_write_cache(codec, cap, 0,
5189 AC_VERB_SET_CONNECT_SEL, idx);
5190 }
5191}
5192
Takashi Iwai840b64c2010-07-13 22:49:01 +02005193/* set the default connection to that pin */
5194static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5195{
5196 struct alc_spec *spec = codec->spec;
5197 int i;
5198
5199 for (i = 0; i < spec->num_adc_nids; i++) {
5200 hda_nid_t cap = spec->capsrc_nids ?
5201 spec->capsrc_nids[i] : spec->adc_nids[i];
5202 int idx;
5203
5204 idx = get_connection_index(codec, cap, pin);
5205 if (idx < 0)
5206 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005207 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005208 return i; /* return the found index */
5209 }
5210 return -1; /* not found */
5211}
5212
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005213/* choose the ADC/MUX containing the input pin and initialize the setup */
5214static void fixup_single_adc(struct hda_codec *codec)
5215{
5216 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01005217 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005218 int i;
5219
5220 /* search for the input pin; there must be only one */
5221 for (i = 0; i < AUTO_PIN_LAST; i++) {
5222 if (spec->autocfg.input_pins[i]) {
5223 pin = spec->autocfg.input_pins[i];
5224 break;
5225 }
5226 }
5227 if (!pin)
5228 return;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005229 i = init_capsrc_for_pin(codec, pin);
5230 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005231 /* use only this ADC */
5232 if (spec->capsrc_nids)
5233 spec->capsrc_nids += i;
5234 spec->adc_nids += i;
5235 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005236 }
5237}
5238
Takashi Iwai840b64c2010-07-13 22:49:01 +02005239/* initialize dual adcs */
5240static void fixup_dual_adc_switch(struct hda_codec *codec)
5241{
5242 struct alc_spec *spec = codec->spec;
5243 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5244 init_capsrc_for_pin(codec, spec->int_mic.pin);
5245}
5246
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005247static void set_capture_mixer(struct hda_codec *codec)
5248{
5249 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005250 static struct snd_kcontrol_new *caps[2][3] = {
5251 { alc_capture_mixer_nosrc1,
5252 alc_capture_mixer_nosrc2,
5253 alc_capture_mixer_nosrc3 },
5254 { alc_capture_mixer1,
5255 alc_capture_mixer2,
5256 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005257 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005258 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005259 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005260 int num_adcs = spec->num_adc_nids;
5261 if (spec->dual_adc_switch)
5262 fixup_dual_adc_switch(codec);
5263 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005264 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005265 else if (spec->input_mux) {
5266 if (spec->input_mux->num_items > 1)
5267 mux = 1;
5268 else if (spec->input_mux->num_items == 1)
5269 fixup_single_adc(codec);
5270 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005271 if (spec->dual_adc_switch)
5272 num_adcs = 1;
5273 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005274 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005275}
5276
Takashi Iwai66946352010-03-29 17:21:45 +02005277/* fill adc_nids (and capsrc_nids) containing all active input pins */
5278static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5279 int num_nids)
5280{
5281 struct alc_spec *spec = codec->spec;
5282 int n;
5283 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5284
5285 for (n = 0; n < num_nids; n++) {
5286 hda_nid_t adc, cap;
5287 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5288 int nconns, i, j;
5289
5290 adc = nids[n];
5291 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5292 continue;
5293 cap = adc;
5294 nconns = snd_hda_get_connections(codec, cap, conn,
5295 ARRAY_SIZE(conn));
5296 if (nconns == 1) {
5297 cap = conn[0];
5298 nconns = snd_hda_get_connections(codec, cap, conn,
5299 ARRAY_SIZE(conn));
5300 }
5301 if (nconns <= 0)
5302 continue;
5303 if (!fallback_adc) {
5304 fallback_adc = adc;
5305 fallback_cap = cap;
5306 }
5307 for (i = 0; i < AUTO_PIN_LAST; i++) {
5308 hda_nid_t nid = spec->autocfg.input_pins[i];
5309 if (!nid)
5310 continue;
5311 for (j = 0; j < nconns; j++) {
5312 if (conn[j] == nid)
5313 break;
5314 }
5315 if (j >= nconns)
5316 break;
5317 }
5318 if (i >= AUTO_PIN_LAST) {
5319 int num_adcs = spec->num_adc_nids;
5320 spec->private_adc_nids[num_adcs] = adc;
5321 spec->private_capsrc_nids[num_adcs] = cap;
5322 spec->num_adc_nids++;
5323 spec->adc_nids = spec->private_adc_nids;
5324 if (adc != cap)
5325 spec->capsrc_nids = spec->private_capsrc_nids;
5326 }
5327 }
5328 if (!spec->num_adc_nids) {
5329 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005330 " using fallback 0x%x\n",
5331 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005332 spec->private_adc_nids[0] = fallback_adc;
5333 spec->adc_nids = spec->private_adc_nids;
5334 if (fallback_adc != fallback_cap) {
5335 spec->private_capsrc_nids[0] = fallback_cap;
5336 spec->capsrc_nids = spec->private_adc_nids;
5337 }
5338 }
5339}
5340
Takashi Iwai67d634c2009-11-16 15:35:59 +01005341#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005342#define set_beep_amp(spec, nid, idx, dir) \
5343 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005344
5345static struct snd_pci_quirk beep_white_list[] = {
5346 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005347 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005348 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005349 {}
5350};
5351
5352static inline int has_cdefine_beep(struct hda_codec *codec)
5353{
5354 struct alc_spec *spec = codec->spec;
5355 const struct snd_pci_quirk *q;
5356 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5357 if (q)
5358 return q->value;
5359 return spec->cdefine.enable_pcbeep;
5360}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005361#else
5362#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005363#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005364#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005365
5366/*
5367 * OK, here we have finally the patch for ALC880
5368 */
5369
Linus Torvalds1da177e2005-04-16 15:20:36 -07005370static int patch_alc880(struct hda_codec *codec)
5371{
5372 struct alc_spec *spec;
5373 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005374 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005375
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005376 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005377 if (spec == NULL)
5378 return -ENOMEM;
5379
5380 codec->spec = spec;
5381
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005382 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5383 alc880_models,
5384 alc880_cfg_tbl);
5385 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005386 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5387 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005388 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005389 }
5390
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005391 if (board_config == ALC880_AUTO) {
5392 /* automatic parse from the BIOS config */
5393 err = alc880_parse_auto_config(codec);
5394 if (err < 0) {
5395 alc_free(codec);
5396 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005397 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005398 printk(KERN_INFO
5399 "hda_codec: Cannot set up configuration "
5400 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005401 board_config = ALC880_3ST;
5402 }
5403 }
5404
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005405 err = snd_hda_attach_beep_device(codec, 0x1);
5406 if (err < 0) {
5407 alc_free(codec);
5408 return err;
5409 }
5410
Kailang Yangdf694da2005-12-05 19:42:22 +01005411 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005412 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005413
Linus Torvalds1da177e2005-04-16 15:20:36 -07005414 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5415 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005416 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005417
Linus Torvalds1da177e2005-04-16 15:20:36 -07005418 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5419 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5420
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005421 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005422 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005423 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005424 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005425 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005426 if (wcap != AC_WID_AUD_IN) {
5427 spec->adc_nids = alc880_adc_nids_alt;
5428 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005429 } else {
5430 spec->adc_nids = alc880_adc_nids;
5431 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432 }
5433 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005434 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005435 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005436
Takashi Iwai2134ea42008-01-10 16:53:55 +01005437 spec->vmaster_nid = 0x0c;
5438
Linus Torvalds1da177e2005-04-16 15:20:36 -07005439 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005440 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005441 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005442#ifdef CONFIG_SND_HDA_POWER_SAVE
5443 if (!spec->loopback.amplist)
5444 spec->loopback.amplist = alc880_loopbacks;
5445#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005446
5447 return 0;
5448}
5449
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005450
Linus Torvalds1da177e2005-04-16 15:20:36 -07005451/*
5452 * ALC260 support
5453 */
5454
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005455static hda_nid_t alc260_dac_nids[1] = {
5456 /* front */
5457 0x02,
5458};
5459
5460static hda_nid_t alc260_adc_nids[1] = {
5461 /* ADC0 */
5462 0x04,
5463};
5464
Kailang Yangdf694da2005-12-05 19:42:22 +01005465static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005466 /* ADC1 */
5467 0x05,
5468};
5469
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005470/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5471 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5472 */
5473static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005474 /* ADC0, ADC1 */
5475 0x04, 0x05
5476};
5477
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005478#define ALC260_DIGOUT_NID 0x03
5479#define ALC260_DIGIN_NID 0x06
5480
5481static struct hda_input_mux alc260_capture_source = {
5482 .num_items = 4,
5483 .items = {
5484 { "Mic", 0x0 },
5485 { "Front Mic", 0x1 },
5486 { "Line", 0x2 },
5487 { "CD", 0x4 },
5488 },
5489};
5490
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005491/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005492 * headphone jack and the internal CD lines since these are the only pins at
5493 * which audio can appear. For flexibility, also allow the option of
5494 * recording the mixer output on the second ADC (ADC0 doesn't have a
5495 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005496 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005497static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5498 {
5499 .num_items = 3,
5500 .items = {
5501 { "Mic/Line", 0x0 },
5502 { "CD", 0x4 },
5503 { "Headphone", 0x2 },
5504 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005505 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005506 {
5507 .num_items = 4,
5508 .items = {
5509 { "Mic/Line", 0x0 },
5510 { "CD", 0x4 },
5511 { "Headphone", 0x2 },
5512 { "Mixer", 0x5 },
5513 },
5514 },
5515
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005516};
5517
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005518/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5519 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005520 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005521static struct hda_input_mux alc260_acer_capture_sources[2] = {
5522 {
5523 .num_items = 4,
5524 .items = {
5525 { "Mic", 0x0 },
5526 { "Line", 0x2 },
5527 { "CD", 0x4 },
5528 { "Headphone", 0x5 },
5529 },
5530 },
5531 {
5532 .num_items = 5,
5533 .items = {
5534 { "Mic", 0x0 },
5535 { "Line", 0x2 },
5536 { "CD", 0x4 },
5537 { "Headphone", 0x6 },
5538 { "Mixer", 0x5 },
5539 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005540 },
5541};
Michael Schwingencc959482009-02-22 18:58:45 +01005542
5543/* Maxdata Favorit 100XS */
5544static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5545 {
5546 .num_items = 2,
5547 .items = {
5548 { "Line/Mic", 0x0 },
5549 { "CD", 0x4 },
5550 },
5551 },
5552 {
5553 .num_items = 3,
5554 .items = {
5555 { "Line/Mic", 0x0 },
5556 { "CD", 0x4 },
5557 { "Mixer", 0x5 },
5558 },
5559 },
5560};
5561
Linus Torvalds1da177e2005-04-16 15:20:36 -07005562/*
5563 * This is just place-holder, so there's something for alc_build_pcms to look
5564 * at when it calculates the maximum number of channels. ALC260 has no mixer
5565 * element which allows changing the channel mode, so the verb list is
5566 * never used.
5567 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005568static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005569 { 2, NULL },
5570};
5571
Kailang Yangdf694da2005-12-05 19:42:22 +01005572
5573/* Mixer combinations
5574 *
5575 * basic: base_output + input + pc_beep + capture
5576 * HP: base_output + input + capture_alt
5577 * HP_3013: hp_3013 + input + capture
5578 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005579 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005580 */
5581
5582static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005583 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005584 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005585 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5586 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5587 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5588 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5589 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005590};
Kailang Yangdf694da2005-12-05 19:42:22 +01005591
5592static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005593 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5594 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5595 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5596 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5597 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5598 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5599 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5600 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005601 { } /* end */
5602};
5603
Takashi Iwaibec15c32008-01-28 18:16:30 +01005604/* update HP, line and mono out pins according to the master switch */
5605static void alc260_hp_master_update(struct hda_codec *codec,
5606 hda_nid_t hp, hda_nid_t line,
5607 hda_nid_t mono)
5608{
5609 struct alc_spec *spec = codec->spec;
5610 unsigned int val = spec->master_sw ? PIN_HP : 0;
5611 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005612 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005613 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005614 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005615 val);
5616 /* mono (speaker) depending on the HP jack sense */
5617 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005618 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005619 val);
5620}
5621
5622static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5623 struct snd_ctl_elem_value *ucontrol)
5624{
5625 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5626 struct alc_spec *spec = codec->spec;
5627 *ucontrol->value.integer.value = spec->master_sw;
5628 return 0;
5629}
5630
5631static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5632 struct snd_ctl_elem_value *ucontrol)
5633{
5634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5635 struct alc_spec *spec = codec->spec;
5636 int val = !!*ucontrol->value.integer.value;
5637 hda_nid_t hp, line, mono;
5638
5639 if (val == spec->master_sw)
5640 return 0;
5641 spec->master_sw = val;
5642 hp = (kcontrol->private_value >> 16) & 0xff;
5643 line = (kcontrol->private_value >> 8) & 0xff;
5644 mono = kcontrol->private_value & 0xff;
5645 alc260_hp_master_update(codec, hp, line, mono);
5646 return 1;
5647}
5648
5649static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5650 {
5651 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5652 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005653 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005654 .info = snd_ctl_boolean_mono_info,
5655 .get = alc260_hp_master_sw_get,
5656 .put = alc260_hp_master_sw_put,
5657 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5658 },
5659 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5660 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5661 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5662 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5663 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5664 HDA_OUTPUT),
5665 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5666 { } /* end */
5667};
5668
5669static struct hda_verb alc260_hp_unsol_verbs[] = {
5670 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5671 {},
5672};
5673
5674static void alc260_hp_automute(struct hda_codec *codec)
5675{
5676 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005677
Wu Fengguang864f92b2009-11-18 12:38:02 +08005678 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005679 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5680}
5681
5682static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5683{
5684 if ((res >> 26) == ALC880_HP_EVENT)
5685 alc260_hp_automute(codec);
5686}
5687
Kailang Yangdf694da2005-12-05 19:42:22 +01005688static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005689 {
5690 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5691 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005692 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005693 .info = snd_ctl_boolean_mono_info,
5694 .get = alc260_hp_master_sw_get,
5695 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005696 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005697 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005698 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5699 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5700 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5701 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5703 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005704 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5705 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005706 { } /* end */
5707};
5708
Kailang Yang3f878302008-08-26 13:02:23 +02005709static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5710 .ops = &snd_hda_bind_vol,
5711 .values = {
5712 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5713 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5714 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5715 0
5716 },
5717};
5718
5719static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5720 .ops = &snd_hda_bind_sw,
5721 .values = {
5722 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5723 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5724 0
5725 },
5726};
5727
5728static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5729 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5730 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5731 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5732 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5733 { } /* end */
5734};
5735
Takashi Iwaibec15c32008-01-28 18:16:30 +01005736static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5737 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5738 {},
5739};
5740
5741static void alc260_hp_3013_automute(struct hda_codec *codec)
5742{
5743 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005744
Wu Fengguang864f92b2009-11-18 12:38:02 +08005745 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005746 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005747}
5748
5749static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5750 unsigned int res)
5751{
5752 if ((res >> 26) == ALC880_HP_EVENT)
5753 alc260_hp_3013_automute(codec);
5754}
5755
Kailang Yang3f878302008-08-26 13:02:23 +02005756static void alc260_hp_3012_automute(struct hda_codec *codec)
5757{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005758 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005759
Kailang Yang3f878302008-08-26 13:02:23 +02005760 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5761 bits);
5762 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5763 bits);
5764 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5765 bits);
5766}
5767
5768static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5769 unsigned int res)
5770{
5771 if ((res >> 26) == ALC880_HP_EVENT)
5772 alc260_hp_3012_automute(codec);
5773}
5774
5775/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005776 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5777 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005778static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005779 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005780 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005781 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005782 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5783 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5784 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5785 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005786 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005787 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5788 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005789 { } /* end */
5790};
5791
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005792/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5793 * versions of the ALC260 don't act on requests to enable mic bias from NID
5794 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5795 * datasheet doesn't mention this restriction. At this stage it's not clear
5796 * whether this behaviour is intentional or is a hardware bug in chip
5797 * revisions available in early 2006. Therefore for now allow the
5798 * "Headphone Jack Mode" control to span all choices, but if it turns out
5799 * that the lack of mic bias for this NID is intentional we could change the
5800 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5801 *
5802 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5803 * don't appear to make the mic bias available from the "line" jack, even
5804 * though the NID used for this jack (0x14) can supply it. The theory is
5805 * that perhaps Acer have included blocking capacitors between the ALC260
5806 * and the output jack. If this turns out to be the case for all such
5807 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5808 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005809 *
5810 * The C20x Tablet series have a mono internal speaker which is controlled
5811 * via the chip's Mono sum widget and pin complex, so include the necessary
5812 * controls for such models. On models without a "mono speaker" the control
5813 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005814 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005815static struct snd_kcontrol_new alc260_acer_mixer[] = {
5816 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5817 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005818 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005819 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005820 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005821 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005822 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005823 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5824 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5826 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5827 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5828 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5829 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5830 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005831 { } /* end */
5832};
5833
Michael Schwingencc959482009-02-22 18:58:45 +01005834/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5835 */
5836static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5837 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5838 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5839 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5840 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5841 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5842 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5843 { } /* end */
5844};
5845
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005846/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5847 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5848 */
5849static struct snd_kcontrol_new alc260_will_mixer[] = {
5850 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5851 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5853 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5854 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5855 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5856 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5857 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5858 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5859 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005860 { } /* end */
5861};
5862
5863/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5864 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5865 */
5866static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5867 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5868 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5870 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5871 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5872 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5873 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5874 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5875 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5876 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5877 { } /* end */
5878};
5879
Kailang Yangdf694da2005-12-05 19:42:22 +01005880/*
5881 * initialization verbs
5882 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005883static struct hda_verb alc260_init_verbs[] = {
5884 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005885 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005886 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005887 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005888 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005889 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005890 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005891 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005892 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005894 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005895 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005896 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005897 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005898 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005899 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005900 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005901 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5902 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005903 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005904 /* set connection select to line in (default select for this ADC) */
5905 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005906 /* mute capture amp left and right */
5907 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5908 /* set connection select to line in (default select for this ADC) */
5909 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005910 /* set vol=0 Line-Out mixer amp left and right */
5911 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5912 /* unmute pin widget amp left and right (no gain on this amp) */
5913 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5914 /* set vol=0 HP mixer amp left and right */
5915 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5916 /* unmute pin widget amp left and right (no gain on this amp) */
5917 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5918 /* set vol=0 Mono mixer amp left and right */
5919 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5920 /* unmute pin widget amp left and right (no gain on this amp) */
5921 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5922 /* unmute LINE-2 out pin */
5923 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005924 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5925 * Line In 2 = 0x03
5926 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005927 /* mute analog inputs */
5928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005933 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005934 /* mute Front out path */
5935 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5936 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5937 /* mute Headphone out path */
5938 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5940 /* mute Mono out path */
5941 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5942 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005943 { }
5944};
5945
Takashi Iwai474167d2006-05-17 17:17:43 +02005946#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005947static struct hda_verb alc260_hp_init_verbs[] = {
5948 /* Headphone and output */
5949 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5950 /* mono output */
5951 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5952 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5954 /* Mic2 (front panel) pin widget for input and vref at 80% */
5955 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5956 /* Line In pin widget for input */
5957 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5958 /* Line-2 pin widget for output */
5959 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5960 /* CD pin widget for input */
5961 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5962 /* unmute amp left and right */
5963 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5964 /* set connection select to line in (default select for this ADC) */
5965 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5966 /* unmute Line-Out mixer amp left and right (volume = 0) */
5967 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5968 /* mute pin widget amp left and right (no gain on this amp) */
5969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5970 /* unmute HP mixer amp left and right (volume = 0) */
5971 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5972 /* mute pin widget amp left and right (no gain on this amp) */
5973 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005974 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5975 * Line In 2 = 0x03
5976 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005977 /* mute analog inputs */
5978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005983 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5984 /* Unmute Front out path */
5985 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5986 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5987 /* Unmute Headphone out path */
5988 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5990 /* Unmute Mono out path */
5991 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5992 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5993 { }
5994};
Takashi Iwai474167d2006-05-17 17:17:43 +02005995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005996
5997static struct hda_verb alc260_hp_3013_init_verbs[] = {
5998 /* Line out and output */
5999 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6000 /* mono output */
6001 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6002 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6003 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6004 /* Mic2 (front panel) pin widget for input and vref at 80% */
6005 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6006 /* Line In pin widget for input */
6007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6008 /* Headphone pin widget for output */
6009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6010 /* CD pin widget for input */
6011 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6012 /* unmute amp left and right */
6013 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6014 /* set connection select to line in (default select for this ADC) */
6015 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6016 /* unmute Line-Out mixer amp left and right (volume = 0) */
6017 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6018 /* mute pin widget amp left and right (no gain on this amp) */
6019 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6020 /* unmute HP mixer amp left and right (volume = 0) */
6021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6022 /* mute pin widget amp left and right (no gain on this amp) */
6023 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006024 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6025 * Line In 2 = 0x03
6026 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006027 /* mute analog inputs */
6028 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6029 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6030 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006033 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6034 /* Unmute Front out path */
6035 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6036 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6037 /* Unmute Headphone out path */
6038 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6039 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6040 /* Unmute Mono out path */
6041 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6042 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6043 { }
6044};
6045
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006046/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006047 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6048 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006049 */
6050static struct hda_verb alc260_fujitsu_init_verbs[] = {
6051 /* Disable all GPIOs */
6052 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6053 /* Internal speaker is connected to headphone pin */
6054 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6055 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6056 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006057 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6058 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6059 /* Ensure all other unused pins are disabled and muted. */
6060 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6061 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006062 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006063 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006064 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006065 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6066 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6067 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006068
Jonathan Woithef7ace402006-02-28 11:46:14 +01006069 /* Disable digital (SPDIF) pins */
6070 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6071 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006072
Kailang Yangea1fb292008-08-26 12:58:38 +02006073 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006074 * when acting as an output.
6075 */
6076 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6077
6078 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6080 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6081 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6082 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6084 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6085 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6086 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6087 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006088
Jonathan Woithef7ace402006-02-28 11:46:14 +01006089 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6090 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6091 /* Unmute Line1 pin widget output buffer since it starts as an output.
6092 * If the pin mode is changed by the user the pin mode control will
6093 * take care of enabling the pin's input/output buffers as needed.
6094 * Therefore there's no need to enable the input buffer at this
6095 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006096 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006097 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006098 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006099 * mixer ctrl)
6100 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006101 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006102
Jonathan Woithef7ace402006-02-28 11:46:14 +01006103 /* Mute capture amp left and right */
6104 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006105 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006106 * in (on mic1 pin)
6107 */
6108 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006109
Jonathan Woithef7ace402006-02-28 11:46:14 +01006110 /* Do the same for the second ADC: mute capture input amp and
6111 * set ADC connection to line in (on mic1 pin)
6112 */
6113 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6114 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006115
Jonathan Woithef7ace402006-02-28 11:46:14 +01006116 /* Mute all inputs to mixer widget (even unconnected ones) */
6117 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6119 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6120 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6121 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6122 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6123 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6124 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006125
6126 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006127};
6128
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006129/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6130 * similar laptops (adapted from Fujitsu init verbs).
6131 */
6132static struct hda_verb alc260_acer_init_verbs[] = {
6133 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6134 * the headphone jack. Turn this on and rely on the standard mute
6135 * methods whenever the user wants to turn these outputs off.
6136 */
6137 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6138 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6139 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6140 /* Internal speaker/Headphone jack is connected to Line-out pin */
6141 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6142 /* Internal microphone/Mic jack is connected to Mic1 pin */
6143 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6144 /* Line In jack is connected to Line1 pin */
6145 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006146 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6147 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006148 /* Ensure all other unused pins are disabled and muted. */
6149 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6150 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006151 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6152 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6153 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6154 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6155 /* Disable digital (SPDIF) pins */
6156 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6157 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6158
Kailang Yangea1fb292008-08-26 12:58:38 +02006159 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006160 * bus when acting as outputs.
6161 */
6162 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6163 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6164
6165 /* Start with output sum widgets muted and their output gains at min */
6166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6167 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6168 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6169 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6171 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6172 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6173 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6174 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006176 /* Unmute Line-out pin widget amp left and right
6177 * (no equiv mixer ctrl)
6178 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006179 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006180 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6181 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006182 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6183 * inputs. If the pin mode is changed by the user the pin mode control
6184 * will take care of enabling the pin's input/output buffers as needed.
6185 * Therefore there's no need to enable the input buffer at this
6186 * stage.
6187 */
6188 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6189 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6190
6191 /* Mute capture amp left and right */
6192 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6193 /* Set ADC connection select to match default mixer setting - mic
6194 * (on mic1 pin)
6195 */
6196 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6197
6198 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006199 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006200 */
6201 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006202 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006203
6204 /* Mute all inputs to mixer widget (even unconnected ones) */
6205 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6206 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6207 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6208 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6210 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6212 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6213
6214 { }
6215};
6216
Michael Schwingencc959482009-02-22 18:58:45 +01006217/* Initialisation sequence for Maxdata Favorit 100XS
6218 * (adapted from Acer init verbs).
6219 */
6220static struct hda_verb alc260_favorit100_init_verbs[] = {
6221 /* GPIO 0 enables the output jack.
6222 * Turn this on and rely on the standard mute
6223 * methods whenever the user wants to turn these outputs off.
6224 */
6225 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6226 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6227 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6228 /* Line/Mic input jack is connected to Mic1 pin */
6229 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6230 /* Ensure all other unused pins are disabled and muted. */
6231 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6232 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6233 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6234 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6235 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6236 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6239 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6240 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6241 /* Disable digital (SPDIF) pins */
6242 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6243 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6244
6245 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6246 * bus when acting as outputs.
6247 */
6248 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6249 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6250
6251 /* Start with output sum widgets muted and their output gains at min */
6252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6257 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6258 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6260 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6261
6262 /* Unmute Line-out pin widget amp left and right
6263 * (no equiv mixer ctrl)
6264 */
6265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6266 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6267 * inputs. If the pin mode is changed by the user the pin mode control
6268 * will take care of enabling the pin's input/output buffers as needed.
6269 * Therefore there's no need to enable the input buffer at this
6270 * stage.
6271 */
6272 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6273
6274 /* Mute capture amp left and right */
6275 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6276 /* Set ADC connection select to match default mixer setting - mic
6277 * (on mic1 pin)
6278 */
6279 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6280
6281 /* Do similar with the second ADC: mute capture input amp and
6282 * set ADC connection to mic to match ALSA's default state.
6283 */
6284 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6285 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6286
6287 /* Mute all inputs to mixer widget (even unconnected ones) */
6288 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6289 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6290 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6291 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6292 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6293 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6294 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6295 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6296
6297 { }
6298};
6299
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006300static struct hda_verb alc260_will_verbs[] = {
6301 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6302 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6303 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6304 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6305 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6306 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6307 {}
6308};
6309
6310static struct hda_verb alc260_replacer_672v_verbs[] = {
6311 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6312 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6313 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6314
6315 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6316 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6317 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6318
6319 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6320 {}
6321};
6322
6323/* toggle speaker-output according to the hp-jack state */
6324static void alc260_replacer_672v_automute(struct hda_codec *codec)
6325{
6326 unsigned int present;
6327
6328 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006329 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006330 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006331 snd_hda_codec_write_cache(codec, 0x01, 0,
6332 AC_VERB_SET_GPIO_DATA, 1);
6333 snd_hda_codec_write_cache(codec, 0x0f, 0,
6334 AC_VERB_SET_PIN_WIDGET_CONTROL,
6335 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006336 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006337 snd_hda_codec_write_cache(codec, 0x01, 0,
6338 AC_VERB_SET_GPIO_DATA, 0);
6339 snd_hda_codec_write_cache(codec, 0x0f, 0,
6340 AC_VERB_SET_PIN_WIDGET_CONTROL,
6341 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006342 }
6343}
6344
6345static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6346 unsigned int res)
6347{
6348 if ((res >> 26) == ALC880_HP_EVENT)
6349 alc260_replacer_672v_automute(codec);
6350}
6351
Kailang Yang3f878302008-08-26 13:02:23 +02006352static struct hda_verb alc260_hp_dc7600_verbs[] = {
6353 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6354 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6355 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6356 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6357 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6358 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6360 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6361 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6362 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6363 {}
6364};
6365
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006366/* Test configuration for debugging, modelled after the ALC880 test
6367 * configuration.
6368 */
6369#ifdef CONFIG_SND_DEBUG
6370static hda_nid_t alc260_test_dac_nids[1] = {
6371 0x02,
6372};
6373static hda_nid_t alc260_test_adc_nids[2] = {
6374 0x04, 0x05,
6375};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006376/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006377 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006378 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006379 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006380static struct hda_input_mux alc260_test_capture_sources[2] = {
6381 {
6382 .num_items = 7,
6383 .items = {
6384 { "MIC1 pin", 0x0 },
6385 { "MIC2 pin", 0x1 },
6386 { "LINE1 pin", 0x2 },
6387 { "LINE2 pin", 0x3 },
6388 { "CD pin", 0x4 },
6389 { "LINE-OUT pin", 0x5 },
6390 { "HP-OUT pin", 0x6 },
6391 },
6392 },
6393 {
6394 .num_items = 8,
6395 .items = {
6396 { "MIC1 pin", 0x0 },
6397 { "MIC2 pin", 0x1 },
6398 { "LINE1 pin", 0x2 },
6399 { "LINE2 pin", 0x3 },
6400 { "CD pin", 0x4 },
6401 { "Mixer", 0x5 },
6402 { "LINE-OUT pin", 0x6 },
6403 { "HP-OUT pin", 0x7 },
6404 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006405 },
6406};
6407static struct snd_kcontrol_new alc260_test_mixer[] = {
6408 /* Output driver widgets */
6409 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6410 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6411 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6412 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6413 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6414 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6415
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006416 /* Modes for retasking pin widgets
6417 * Note: the ALC260 doesn't seem to act on requests to enable mic
6418 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6419 * mention this restriction. At this stage it's not clear whether
6420 * this behaviour is intentional or is a hardware bug in chip
6421 * revisions available at least up until early 2006. Therefore for
6422 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6423 * choices, but if it turns out that the lack of mic bias for these
6424 * NIDs is intentional we could change their modes from
6425 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6426 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006427 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6428 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6429 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6430 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6431 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6432 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6433
6434 /* Loopback mixer controls */
6435 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6436 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6437 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6438 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6439 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6440 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6441 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6442 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6443 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6444 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006445 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6446 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6447 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6448 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006449
6450 /* Controls for GPIO pins, assuming they are configured as outputs */
6451 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6452 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6453 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6454 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6455
Jonathan Woithe92621f12006-02-28 11:47:47 +01006456 /* Switches to allow the digital IO pins to be enabled. The datasheet
6457 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006458 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006459 */
6460 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6461 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6462
Jonathan Woithef8225f62008-01-08 12:16:54 +01006463 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6464 * this output to turn on an external amplifier.
6465 */
6466 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6467 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6468
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006469 { } /* end */
6470};
6471static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006472 /* Enable all GPIOs as outputs with an initial value of 0 */
6473 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6474 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6475 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6476
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006477 /* Enable retasking pins as output, initially without power amp */
6478 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6479 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6482 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6483 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6484
Jonathan Woithe92621f12006-02-28 11:47:47 +01006485 /* Disable digital (SPDIF) pins initially, but users can enable
6486 * them via a mixer switch. In the case of SPDIF-out, this initverb
6487 * payload also sets the generation to 0, output to be in "consumer"
6488 * PCM format, copyright asserted, no pre-emphasis and no validity
6489 * control.
6490 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006491 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6492 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6493
Kailang Yangea1fb292008-08-26 12:58:38 +02006494 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006495 * OUT1 sum bus when acting as an output.
6496 */
6497 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6498 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6499 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6500 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6501
6502 /* Start with output sum widgets muted and their output gains at min */
6503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6505 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6508 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6511 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6512
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006513 /* Unmute retasking pin widget output buffers since the default
6514 * state appears to be output. As the pin mode is changed by the
6515 * user the pin mode control will take care of enabling the pin's
6516 * input/output buffers as needed.
6517 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006518 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6520 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6521 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6522 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6523 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6524 /* Also unmute the mono-out pin widget */
6525 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6526
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006527 /* Mute capture amp left and right */
6528 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006529 /* Set ADC connection select to match default mixer setting (mic1
6530 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006531 */
6532 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6533
6534 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006535 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006536 */
6537 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6538 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6539
6540 /* Mute all inputs to mixer widget (even unconnected ones) */
6541 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6549
6550 { }
6551};
6552#endif
6553
Takashi Iwai63300792008-01-24 15:31:36 +01006554#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6555#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006556
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006557#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6558#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6559
Kailang Yangdf694da2005-12-05 19:42:22 +01006560/*
6561 * for BIOS auto-configuration
6562 */
6563
6564static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006565 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006566{
6567 hda_nid_t nid_vol;
6568 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006569 int err;
6570
6571 if (nid >= 0x0f && nid < 0x11) {
6572 nid_vol = nid - 0x7;
6573 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6574 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6575 } else if (nid == 0x11) {
6576 nid_vol = nid - 0x7;
6577 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6578 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6579 } else if (nid >= 0x12 && nid <= 0x15) {
6580 nid_vol = 0x08;
6581 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6582 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6583 } else
6584 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006585
Takashi Iwai863b4512008-10-21 17:01:47 +02006586 if (!(*vol_bits & (1 << nid_vol))) {
6587 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006588 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006589 if (err < 0)
6590 return err;
6591 *vol_bits |= (1 << nid_vol);
6592 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006593 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006594 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006595 return err;
6596 return 1;
6597}
6598
6599/* add playback controls from the parsed DAC table */
6600static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6601 const struct auto_pin_cfg *cfg)
6602{
6603 hda_nid_t nid;
6604 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006605 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006606
6607 spec->multiout.num_dacs = 1;
6608 spec->multiout.dac_nids = spec->private_dac_nids;
6609 spec->multiout.dac_nids[0] = 0x02;
6610
6611 nid = cfg->line_out_pins[0];
6612 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006613 const char *pfx;
6614 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6615 pfx = "Master";
6616 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6617 pfx = "Speaker";
6618 else
6619 pfx = "Front";
6620 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006621 if (err < 0)
6622 return err;
6623 }
6624
Takashi Iwai82bc9552006-03-21 11:24:42 +01006625 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006627 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006628 if (err < 0)
6629 return err;
6630 }
6631
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006632 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006633 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006634 err = alc260_add_playback_controls(spec, nid, "Headphone",
6635 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006636 if (err < 0)
6637 return err;
6638 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006639 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006640}
6641
6642/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006643static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006644 const struct auto_pin_cfg *cfg)
6645{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006646 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006647}
6648
6649static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6650 hda_nid_t nid, int pin_type,
6651 int sel_idx)
6652{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006653 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006654 /* need the manual connection? */
6655 if (nid >= 0x12) {
6656 int idx = nid - 0x12;
6657 snd_hda_codec_write(codec, idx + 0x0b, 0,
6658 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006659 }
6660}
6661
6662static void alc260_auto_init_multi_out(struct hda_codec *codec)
6663{
6664 struct alc_spec *spec = codec->spec;
6665 hda_nid_t nid;
6666
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006667 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006668 if (nid) {
6669 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6670 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6671 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006672
Takashi Iwai82bc9552006-03-21 11:24:42 +01006673 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006674 if (nid)
6675 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6676
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006677 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006678 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006679 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006680}
Kailang Yangdf694da2005-12-05 19:42:22 +01006681
6682#define ALC260_PIN_CD_NID 0x16
6683static void alc260_auto_init_analog_input(struct hda_codec *codec)
6684{
6685 struct alc_spec *spec = codec->spec;
6686 int i;
6687
6688 for (i = 0; i < AUTO_PIN_LAST; i++) {
6689 hda_nid_t nid = spec->autocfg.input_pins[i];
6690 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006691 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006692 if (nid != ALC260_PIN_CD_NID &&
6693 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006694 snd_hda_codec_write(codec, nid, 0,
6695 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006696 AMP_OUT_MUTE);
6697 }
6698 }
6699}
6700
Takashi Iwai7f311a42010-04-09 17:32:23 +02006701#define alc260_auto_init_input_src alc880_auto_init_input_src
6702
Kailang Yangdf694da2005-12-05 19:42:22 +01006703/*
6704 * generic initialization of ADC, input mixers and output mixers
6705 */
6706static struct hda_verb alc260_volume_init_verbs[] = {
6707 /*
6708 * Unmute ADC0-1 and set the default input to mic-in
6709 */
6710 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6711 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6712 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6713 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006714
Kailang Yangdf694da2005-12-05 19:42:22 +01006715 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6716 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006717 * Note: PASD motherboards uses the Line In 2 as the input for
6718 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006719 */
6720 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006721 /* mute analog inputs */
6722 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6723 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6724 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6725 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006727
6728 /*
6729 * Set up output mixers (0x08 - 0x0a)
6730 */
6731 /* set vol=0 to output mixers */
6732 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6733 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6734 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6735 /* set up input amps for analog loopback */
6736 /* Amp Indices: DAC = 0, mixer = 1 */
6737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6739 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6741 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6742 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006743
Kailang Yangdf694da2005-12-05 19:42:22 +01006744 { }
6745};
6746
6747static int alc260_parse_auto_config(struct hda_codec *codec)
6748{
6749 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006750 int err;
6751 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6752
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006753 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6754 alc260_ignore);
6755 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006756 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006757 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6758 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006759 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006760 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006761 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006762 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006763 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006764 return err;
6765
6766 spec->multiout.max_channels = 2;
6767
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006768 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006769 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006770 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006771 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006772
Takashi Iwaid88897e2008-10-31 15:01:37 +01006773 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006774
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006775 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006776 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006777
Kailang Yang6227cdc2010-02-25 08:36:52 +01006778 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006779
Kailang Yangdf694da2005-12-05 19:42:22 +01006780 return 1;
6781}
6782
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006783/* additional initialization for auto-configuration model */
6784static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006785{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006786 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006787 alc260_auto_init_multi_out(codec);
6788 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006789 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006790 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006791 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006792 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006793}
6794
Takashi Iwaicb53c622007-08-10 17:21:45 +02006795#ifdef CONFIG_SND_HDA_POWER_SAVE
6796static struct hda_amp_list alc260_loopbacks[] = {
6797 { 0x07, HDA_INPUT, 0 },
6798 { 0x07, HDA_INPUT, 1 },
6799 { 0x07, HDA_INPUT, 2 },
6800 { 0x07, HDA_INPUT, 3 },
6801 { 0x07, HDA_INPUT, 4 },
6802 { } /* end */
6803};
6804#endif
6805
Kailang Yangdf694da2005-12-05 19:42:22 +01006806/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006807 * Pin config fixes
6808 */
6809enum {
6810 PINFIX_HP_DC5750,
6811};
6812
6813static struct alc_pincfg alc260_hp_dc5750_pinfix[] = {
6814 { 0x11, 0x90130110 }, /* speaker */
6815 { }
6816};
6817
6818static const struct alc_fixup alc260_fixups[] = {
6819 [PINFIX_HP_DC5750] = {
6820 .pins = alc260_hp_dc5750_pinfix
6821 },
6822};
6823
6824static struct snd_pci_quirk alc260_fixup_tbl[] = {
6825 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6826 {}
6827};
6828
6829/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006830 * ALC260 configurations
6831 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006832static const char *alc260_models[ALC260_MODEL_LAST] = {
6833 [ALC260_BASIC] = "basic",
6834 [ALC260_HP] = "hp",
6835 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006836 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006837 [ALC260_FUJITSU_S702X] = "fujitsu",
6838 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006839 [ALC260_WILL] = "will",
6840 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006841 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006842#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006843 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006844#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006845 [ALC260_AUTO] = "auto",
6846};
6847
6848static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006849 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006850 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006851 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006852 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006853 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006854 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006855 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006856 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006857 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006858 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6859 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6860 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6861 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6862 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6863 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6864 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6865 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6866 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006867 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006868 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006869 {}
6870};
6871
Kailang Yangdf694da2005-12-05 19:42:22 +01006872static struct alc_config_preset alc260_presets[] = {
6873 [ALC260_BASIC] = {
6874 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006875 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006876 .init_verbs = { alc260_init_verbs },
6877 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6878 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006879 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006880 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006881 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6882 .channel_mode = alc260_modes,
6883 .input_mux = &alc260_capture_source,
6884 },
6885 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006886 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006887 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006888 .init_verbs = { alc260_init_verbs,
6889 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006890 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6891 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006892 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6893 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006894 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6895 .channel_mode = alc260_modes,
6896 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006897 .unsol_event = alc260_hp_unsol_event,
6898 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 },
Kailang Yang3f878302008-08-26 13:02:23 +02006900 [ALC260_HP_DC7600] = {
6901 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006902 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006903 .init_verbs = { alc260_init_verbs,
6904 alc260_hp_dc7600_verbs },
6905 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6906 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006907 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6908 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006909 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6910 .channel_mode = alc260_modes,
6911 .input_mux = &alc260_capture_source,
6912 .unsol_event = alc260_hp_3012_unsol_event,
6913 .init_hook = alc260_hp_3012_automute,
6914 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006915 [ALC260_HP_3013] = {
6916 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006917 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006918 .init_verbs = { alc260_hp_3013_init_verbs,
6919 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006920 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6921 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006922 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6923 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006924 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6925 .channel_mode = alc260_modes,
6926 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006927 .unsol_event = alc260_hp_3013_unsol_event,
6928 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006929 },
6930 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006931 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006932 .init_verbs = { alc260_fujitsu_init_verbs },
6933 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6934 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006935 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6936 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006937 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6938 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006939 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6940 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006941 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006942 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006943 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006944 .init_verbs = { alc260_acer_init_verbs },
6945 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6946 .dac_nids = alc260_dac_nids,
6947 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6948 .adc_nids = alc260_dual_adc_nids,
6949 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6950 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006951 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6952 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006953 },
Michael Schwingencc959482009-02-22 18:58:45 +01006954 [ALC260_FAVORIT100] = {
6955 .mixers = { alc260_favorit100_mixer },
6956 .init_verbs = { alc260_favorit100_init_verbs },
6957 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6958 .dac_nids = alc260_dac_nids,
6959 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6960 .adc_nids = alc260_dual_adc_nids,
6961 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6962 .channel_mode = alc260_modes,
6963 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6964 .input_mux = alc260_favorit100_capture_sources,
6965 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006966 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006967 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006968 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6969 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6970 .dac_nids = alc260_dac_nids,
6971 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6972 .adc_nids = alc260_adc_nids,
6973 .dig_out_nid = ALC260_DIGOUT_NID,
6974 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6975 .channel_mode = alc260_modes,
6976 .input_mux = &alc260_capture_source,
6977 },
6978 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006979 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006980 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6981 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6982 .dac_nids = alc260_dac_nids,
6983 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6984 .adc_nids = alc260_adc_nids,
6985 .dig_out_nid = ALC260_DIGOUT_NID,
6986 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6987 .channel_mode = alc260_modes,
6988 .input_mux = &alc260_capture_source,
6989 .unsol_event = alc260_replacer_672v_unsol_event,
6990 .init_hook = alc260_replacer_672v_automute,
6991 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006992#ifdef CONFIG_SND_DEBUG
6993 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006994 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006995 .init_verbs = { alc260_test_init_verbs },
6996 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6997 .dac_nids = alc260_test_dac_nids,
6998 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6999 .adc_nids = alc260_test_adc_nids,
7000 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7001 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007002 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7003 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007004 },
7005#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007006};
7007
Linus Torvalds1da177e2005-04-16 15:20:36 -07007008static int patch_alc260(struct hda_codec *codec)
7009{
7010 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007011 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007012
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007013 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007014 if (spec == NULL)
7015 return -ENOMEM;
7016
7017 codec->spec = spec;
7018
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007019 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7020 alc260_models,
7021 alc260_cfg_tbl);
7022 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007023 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007024 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007026 }
7027
Takashi Iwaifc091762010-08-04 23:53:36 +02007028 if (board_config == ALC260_AUTO)
7029 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7030
Kailang Yangdf694da2005-12-05 19:42:22 +01007031 if (board_config == ALC260_AUTO) {
7032 /* automatic parse from the BIOS config */
7033 err = alc260_parse_auto_config(codec);
7034 if (err < 0) {
7035 alc_free(codec);
7036 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007037 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007038 printk(KERN_INFO
7039 "hda_codec: Cannot set up configuration "
7040 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007041 board_config = ALC260_BASIC;
7042 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007043 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007044
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007045 err = snd_hda_attach_beep_device(codec, 0x1);
7046 if (err < 0) {
7047 alc_free(codec);
7048 return err;
7049 }
7050
Kailang Yangdf694da2005-12-05 19:42:22 +01007051 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007052 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007053
Linus Torvalds1da177e2005-04-16 15:20:36 -07007054 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7055 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307056 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007057
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007058 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7059 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7060
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007061 if (!spec->adc_nids && spec->input_mux) {
7062 /* check whether NID 0x04 is valid */
7063 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007064 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007065 /* get type */
7066 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7067 spec->adc_nids = alc260_adc_nids_alt;
7068 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7069 } else {
7070 spec->adc_nids = alc260_adc_nids;
7071 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7072 }
7073 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007074 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007075 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007076
Takashi Iwaifc091762010-08-04 23:53:36 +02007077 if (board_config == ALC260_AUTO)
7078 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7079
Takashi Iwai2134ea42008-01-10 16:53:55 +01007080 spec->vmaster_nid = 0x08;
7081
Linus Torvalds1da177e2005-04-16 15:20:36 -07007082 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007083 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007084 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007085#ifdef CONFIG_SND_HDA_POWER_SAVE
7086 if (!spec->loopback.amplist)
7087 spec->loopback.amplist = alc260_loopbacks;
7088#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007089
7090 return 0;
7091}
7092
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007093
Linus Torvalds1da177e2005-04-16 15:20:36 -07007094/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007095 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007096 *
7097 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7098 * configuration. Each pin widget can choose any input DACs and a mixer.
7099 * Each ADC is connected from a mixer of all inputs. This makes possible
7100 * 6-channel independent captures.
7101 *
7102 * In addition, an independent DAC for the multi-playback (not used in this
7103 * driver yet).
7104 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007105#define ALC882_DIGOUT_NID 0x06
7106#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007107#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7108#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7109#define ALC1200_DIGOUT_NID 0x10
7110
Linus Torvalds1da177e2005-04-16 15:20:36 -07007111
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007112static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007113 { 8, NULL }
7114};
7115
Takashi Iwai4953550a2009-06-30 15:28:30 +02007116/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007117static hda_nid_t alc882_dac_nids[4] = {
7118 /* front, rear, clfe, rear_surr */
7119 0x02, 0x03, 0x04, 0x05
7120};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007121#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007122
Takashi Iwai4953550a2009-06-30 15:28:30 +02007123/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007124#define alc882_adc_nids alc880_adc_nids
7125#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007126#define alc883_adc_nids alc882_adc_nids_alt
7127static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7128static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7129#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007130
Takashi Iwaie1406342008-02-11 18:32:32 +01007131static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7132static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007133#define alc883_capsrc_nids alc882_capsrc_nids_alt
7134static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7135#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007136
Linus Torvalds1da177e2005-04-16 15:20:36 -07007137/* input MUX */
7138/* FIXME: should be a matrix-type input source selection */
7139
7140static struct hda_input_mux alc882_capture_source = {
7141 .num_items = 4,
7142 .items = {
7143 { "Mic", 0x0 },
7144 { "Front Mic", 0x1 },
7145 { "Line", 0x2 },
7146 { "CD", 0x4 },
7147 },
7148};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007149
Takashi Iwai4953550a2009-06-30 15:28:30 +02007150#define alc883_capture_source alc882_capture_source
7151
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007152static struct hda_input_mux alc889_capture_source = {
7153 .num_items = 3,
7154 .items = {
7155 { "Front Mic", 0x0 },
7156 { "Mic", 0x3 },
7157 { "Line", 0x2 },
7158 },
7159};
7160
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007161static struct hda_input_mux mb5_capture_source = {
7162 .num_items = 3,
7163 .items = {
7164 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307165 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007166 { "CD", 0x4 },
7167 },
7168};
7169
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007170static struct hda_input_mux macmini3_capture_source = {
7171 .num_items = 2,
7172 .items = {
7173 { "Line", 0x2 },
7174 { "CD", 0x4 },
7175 },
7176};
7177
Takashi Iwai4953550a2009-06-30 15:28:30 +02007178static struct hda_input_mux alc883_3stack_6ch_intel = {
7179 .num_items = 4,
7180 .items = {
7181 { "Mic", 0x1 },
7182 { "Front Mic", 0x0 },
7183 { "Line", 0x2 },
7184 { "CD", 0x4 },
7185 },
7186};
7187
7188static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7189 .num_items = 2,
7190 .items = {
7191 { "Mic", 0x1 },
7192 { "Line", 0x2 },
7193 },
7194};
7195
7196static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7197 .num_items = 4,
7198 .items = {
7199 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007200 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007201 { "Line", 0x2 },
7202 { "CD", 0x4 },
7203 },
7204};
7205
7206static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7207 .num_items = 2,
7208 .items = {
7209 { "Mic", 0x0 },
7210 { "Int Mic", 0x1 },
7211 },
7212};
7213
7214static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7215 .num_items = 3,
7216 .items = {
7217 { "Mic", 0x0 },
7218 { "Front Mic", 0x1 },
7219 { "Line", 0x4 },
7220 },
7221};
7222
7223static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7224 .num_items = 2,
7225 .items = {
7226 { "Mic", 0x0 },
7227 { "Line", 0x2 },
7228 },
7229};
7230
7231static struct hda_input_mux alc889A_mb31_capture_source = {
7232 .num_items = 2,
7233 .items = {
7234 { "Mic", 0x0 },
7235 /* Front Mic (0x01) unused */
7236 { "Line", 0x2 },
7237 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007238 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007239 },
7240};
7241
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007242static struct hda_input_mux alc889A_imac91_capture_source = {
7243 .num_items = 2,
7244 .items = {
7245 { "Mic", 0x01 },
7246 { "Line", 0x2 }, /* Not sure! */
7247 },
7248};
7249
Takashi Iwai4953550a2009-06-30 15:28:30 +02007250/*
7251 * 2ch mode
7252 */
7253static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7254 { 2, NULL }
7255};
7256
Kailang Yangdf694da2005-12-05 19:42:22 +01007257/*
Kailang Yang272a5272007-05-14 11:00:38 +02007258 * 2ch mode
7259 */
7260static struct hda_verb alc882_3ST_ch2_init[] = {
7261 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7262 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7263 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7264 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7265 { } /* end */
7266};
7267
7268/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007269 * 4ch mode
7270 */
7271static struct hda_verb alc882_3ST_ch4_init[] = {
7272 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7273 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7274 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7275 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7276 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7277 { } /* end */
7278};
7279
7280/*
Kailang Yang272a5272007-05-14 11:00:38 +02007281 * 6ch mode
7282 */
7283static struct hda_verb alc882_3ST_ch6_init[] = {
7284 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7285 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7286 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7287 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7288 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7289 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7290 { } /* end */
7291};
7292
Takashi Iwai4953550a2009-06-30 15:28:30 +02007293static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007294 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007295 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007296 { 6, alc882_3ST_ch6_init },
7297};
7298
Takashi Iwai4953550a2009-06-30 15:28:30 +02007299#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7300
Kailang Yang272a5272007-05-14 11:00:38 +02007301/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307302 * 2ch mode
7303 */
7304static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7305 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7306 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7307 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7308 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7309 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7310 { } /* end */
7311};
7312
7313/*
7314 * 4ch mode
7315 */
7316static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7317 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7318 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7319 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7320 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7321 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7322 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7323 { } /* end */
7324};
7325
7326/*
7327 * 6ch mode
7328 */
7329static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7330 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7331 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7332 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7333 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7334 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7335 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7336 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7337 { } /* end */
7338};
7339
7340static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7341 { 2, alc883_3ST_ch2_clevo_init },
7342 { 4, alc883_3ST_ch4_clevo_init },
7343 { 6, alc883_3ST_ch6_clevo_init },
7344};
7345
7346
7347/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007348 * 6ch mode
7349 */
7350static struct hda_verb alc882_sixstack_ch6_init[] = {
7351 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7352 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7353 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7354 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7355 { } /* end */
7356};
7357
7358/*
7359 * 8ch mode
7360 */
7361static struct hda_verb alc882_sixstack_ch8_init[] = {
7362 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7363 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7364 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7365 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7366 { } /* end */
7367};
7368
7369static struct hda_channel_mode alc882_sixstack_modes[2] = {
7370 { 6, alc882_sixstack_ch6_init },
7371 { 8, alc882_sixstack_ch8_init },
7372};
7373
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007374
7375/* Macbook Air 2,1 */
7376
7377static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7378 { 2, NULL },
7379};
7380
Takashi Iwai87350ad2007-08-16 18:19:38 +02007381/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007382 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007383 */
7384
7385/*
7386 * 2ch mode
7387 */
7388static struct hda_verb alc885_mbp_ch2_init[] = {
7389 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7390 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7392 { } /* end */
7393};
7394
7395/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007396 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007397 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007398static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007399 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7400 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7401 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7402 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7403 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7404 { } /* end */
7405};
7406
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007407static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007408 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007409 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007410};
7411
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007412/*
7413 * 2ch
7414 * Speakers/Woofer/HP = Front
7415 * LineIn = Input
7416 */
7417static struct hda_verb alc885_mb5_ch2_init[] = {
7418 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7419 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7420 { } /* end */
7421};
7422
7423/*
7424 * 6ch mode
7425 * Speakers/HP = Front
7426 * Woofer = LFE
7427 * LineIn = Surround
7428 */
7429static struct hda_verb alc885_mb5_ch6_init[] = {
7430 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7431 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7432 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7433 { } /* end */
7434};
7435
7436static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7437 { 2, alc885_mb5_ch2_init },
7438 { 6, alc885_mb5_ch6_init },
7439};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007440
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007441#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007442
7443/*
7444 * 2ch mode
7445 */
7446static struct hda_verb alc883_4ST_ch2_init[] = {
7447 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7448 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7449 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7450 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7451 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7452 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7453 { } /* end */
7454};
7455
7456/*
7457 * 4ch mode
7458 */
7459static struct hda_verb alc883_4ST_ch4_init[] = {
7460 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7461 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7462 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7463 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7464 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7465 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7466 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7467 { } /* end */
7468};
7469
7470/*
7471 * 6ch mode
7472 */
7473static struct hda_verb alc883_4ST_ch6_init[] = {
7474 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7475 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7476 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7477 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7478 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7479 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7480 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7481 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7482 { } /* end */
7483};
7484
7485/*
7486 * 8ch mode
7487 */
7488static struct hda_verb alc883_4ST_ch8_init[] = {
7489 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7490 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7491 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7492 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7493 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7494 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7495 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7496 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7497 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7498 { } /* end */
7499};
7500
7501static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7502 { 2, alc883_4ST_ch2_init },
7503 { 4, alc883_4ST_ch4_init },
7504 { 6, alc883_4ST_ch6_init },
7505 { 8, alc883_4ST_ch8_init },
7506};
7507
7508
7509/*
7510 * 2ch mode
7511 */
7512static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7513 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7514 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7515 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7516 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7517 { } /* end */
7518};
7519
7520/*
7521 * 4ch mode
7522 */
7523static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7524 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7525 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7526 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7528 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7529 { } /* end */
7530};
7531
7532/*
7533 * 6ch mode
7534 */
7535static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7536 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7537 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7538 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7539 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7540 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7541 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7542 { } /* end */
7543};
7544
7545static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7546 { 2, alc883_3ST_ch2_intel_init },
7547 { 4, alc883_3ST_ch4_intel_init },
7548 { 6, alc883_3ST_ch6_intel_init },
7549};
7550
7551/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007552 * 2ch mode
7553 */
7554static struct hda_verb alc889_ch2_intel_init[] = {
7555 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7556 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7557 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7558 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7559 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7560 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7561 { } /* end */
7562};
7563
7564/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007565 * 6ch mode
7566 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007567static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007568 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7569 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7570 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7571 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7572 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007573 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7574 { } /* end */
7575};
7576
7577/*
7578 * 8ch mode
7579 */
7580static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007581 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7582 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7583 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7584 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7585 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007586 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7587 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007588 { } /* end */
7589};
7590
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007591static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7592 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007593 { 6, alc889_ch6_intel_init },
7594 { 8, alc889_ch8_intel_init },
7595};
7596
7597/*
7598 * 6ch mode
7599 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007600static struct hda_verb alc883_sixstack_ch6_init[] = {
7601 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7602 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7603 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7605 { } /* end */
7606};
7607
7608/*
7609 * 8ch mode
7610 */
7611static struct hda_verb alc883_sixstack_ch8_init[] = {
7612 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7613 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7614 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7615 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7616 { } /* end */
7617};
7618
7619static struct hda_channel_mode alc883_sixstack_modes[2] = {
7620 { 6, alc883_sixstack_ch6_init },
7621 { 8, alc883_sixstack_ch8_init },
7622};
7623
7624
Linus Torvalds1da177e2005-04-16 15:20:36 -07007625/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7626 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7627 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007628static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007629 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007630 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007631 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007632 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007633 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7634 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007635 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7636 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007637 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007638 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007639 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7640 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7641 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7642 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7643 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7644 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007645 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007646 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7647 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007648 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007649 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007650 { } /* end */
7651};
7652
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007653/* Macbook Air 2,1 same control for HP and internal Speaker */
7654
7655static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7656 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7657 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7658 { }
7659};
7660
7661
Takashi Iwai87350ad2007-08-16 18:19:38 +02007662static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007663 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7664 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7665 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7666 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7667 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007668 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7669 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7671 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007672 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007673 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7674 { } /* end */
7675};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007676
7677static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007678 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7679 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7680 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7681 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7682 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7683 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7685 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307686 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7687 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007688 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7689 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7690 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7691 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7692 { } /* end */
7693};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007694
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007695static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7697 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7698 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7699 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7700 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7701 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7703 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7705 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7706 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7707 { } /* end */
7708};
7709
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007710static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007711 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7712 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007713 { } /* end */
7714};
7715
7716
Kailang Yangbdd148a2007-05-08 15:19:08 +02007717static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7718 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7719 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7720 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7721 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7722 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7723 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7726 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007727 { } /* end */
7728};
7729
Kailang Yang272a5272007-05-14 11:00:38 +02007730static struct snd_kcontrol_new alc882_targa_mixer[] = {
7731 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7732 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7733 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7734 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7735 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7736 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7737 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7738 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7739 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007740 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007741 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7742 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007743 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007744 { } /* end */
7745};
7746
7747/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7748 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7749 */
7750static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7751 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7752 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7753 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7754 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7755 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7756 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7757 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7758 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7759 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7760 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7761 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7762 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007763 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007764 { } /* end */
7765};
7766
Takashi Iwai914759b2007-09-06 14:52:04 +02007767static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7768 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7769 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007778 { } /* end */
7779};
7780
Kailang Yangdf694da2005-12-05 19:42:22 +01007781static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7782 {
7783 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7784 .name = "Channel Mode",
7785 .info = alc_ch_mode_info,
7786 .get = alc_ch_mode_get,
7787 .put = alc_ch_mode_put,
7788 },
7789 { } /* end */
7790};
7791
Takashi Iwai4953550a2009-06-30 15:28:30 +02007792static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007793 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007796 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007797 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7798 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007799 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007800 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7801 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007802 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007803 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007805
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007806 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007807 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007808 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007809 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007810 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007811 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007812 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007813 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007814 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007815 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007816 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007817 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007818 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007819 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007820 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007821 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007822 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7825 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7828 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7831 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7832 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7833 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7834 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007835 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007836 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007837
7838 /* FIXME: use matrix-type input source selection */
7839 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007840 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007842 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007843 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007844 /* ADC2: mute amp left and right */
7845 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007846 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007847 /* ADC3: mute amp left and right */
7848 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007849 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007850
7851 { }
7852};
7853
Takashi Iwai4953550a2009-06-30 15:28:30 +02007854static struct hda_verb alc882_adc1_init_verbs[] = {
7855 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7856 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7857 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7858 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7860 /* ADC1: mute amp left and right */
7861 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7862 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7863 { }
7864};
7865
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007866static struct hda_verb alc882_eapd_verbs[] = {
7867 /* change to EAPD mode */
7868 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007869 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007870 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007871};
7872
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007873static struct hda_verb alc889_eapd_verbs[] = {
7874 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7875 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7876 { }
7877};
7878
Wu Fengguang6732bd02009-07-30 09:19:14 +02007879static struct hda_verb alc_hp15_unsol_verbs[] = {
7880 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7881 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7882 {}
7883};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007884
7885static struct hda_verb alc885_init_verbs[] = {
7886 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007887 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7888 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007889 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007890 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007892 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7894 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007895 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007896 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7897 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007898
7899 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007900 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007901 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7902 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7903 /* Front Pin: output 0 (0x0c) */
7904 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7905 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7906 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7907 /* Rear Pin: output 1 (0x0d) */
7908 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7909 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7910 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7911 /* CLFE Pin: output 2 (0x0e) */
7912 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7913 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7914 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7915 /* Side Pin: output 3 (0x0f) */
7916 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7917 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7918 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7919 /* Mic (rear) pin: input vref at 80% */
7920 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7921 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7922 /* Front Mic pin: input vref at 80% */
7923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7924 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7925 /* Line In pin: input */
7926 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7927 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7928
7929 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7930 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007931 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007932 /* Input mixer2 */
7933 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007934 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007936 /* ADC2: mute amp left and right */
7937 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7938 /* ADC3: mute amp left and right */
7939 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7940
7941 { }
7942};
7943
7944static struct hda_verb alc885_init_input_verbs[] = {
7945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7948 { }
7949};
7950
7951
7952/* Unmute Selector 24h and set the default input to front mic */
7953static struct hda_verb alc889_init_input_verbs[] = {
7954 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7955 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7956 { }
7957};
7958
7959
Takashi Iwai4953550a2009-06-30 15:28:30 +02007960#define alc883_init_verbs alc882_base_init_verbs
7961
Tobin Davis9102cd12006-12-15 10:02:12 +01007962/* Mac Pro test */
7963static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7965 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7966 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7967 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7968 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007969 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007970 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7971 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007972 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007973 { } /* end */
7974};
7975
7976static struct hda_verb alc882_macpro_init_verbs[] = {
7977 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7978 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7979 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7980 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7981 /* Front Pin: output 0 (0x0c) */
7982 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7983 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7984 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7985 /* Front Mic pin: input vref at 80% */
7986 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7987 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7988 /* Speaker: output */
7989 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7990 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7991 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7992 /* Headphone output (output 0 - 0x0c) */
7993 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7994 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7995 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7996
7997 /* FIXME: use matrix-type input source selection */
7998 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7999 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8000 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8001 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8002 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8003 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8004 /* Input mixer2 */
8005 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8006 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8007 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8008 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8009 /* Input mixer3 */
8010 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8011 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8012 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8014 /* ADC1: mute amp left and right */
8015 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8016 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8017 /* ADC2: mute amp left and right */
8018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8019 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8020 /* ADC3: mute amp left and right */
8021 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8022 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8023
8024 { }
8025};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008026
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008027/* Macbook 5,1 */
8028static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008029 /* DACs */
8030 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8031 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8032 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8033 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008034 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008035 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8036 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8037 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008038 /* Surround mixer */
8039 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8040 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8041 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8042 /* LFE mixer */
8043 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8044 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8045 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8046 /* HP mixer */
8047 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8048 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8049 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8050 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008051 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8052 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008053 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8054 /* LFE Pin (0x0e) */
8055 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8056 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8057 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8058 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008059 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8060 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008061 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308062 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008063 /* Front Mic pin: input vref at 80% */
8064 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8065 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8066 /* Line In pin */
8067 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8068 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8069
Alex Murrayb8f171e2010-06-14 12:08:43 +09308070 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008073 { }
8074};
8075
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008076/* Macmini 3,1 */
8077static struct hda_verb alc885_macmini3_init_verbs[] = {
8078 /* DACs */
8079 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8080 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8081 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8082 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8083 /* Front mixer */
8084 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8087 /* Surround mixer */
8088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8089 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8090 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8091 /* LFE mixer */
8092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8093 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8094 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8095 /* HP mixer */
8096 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8097 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8098 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8099 /* Front Pin (0x0c) */
8100 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8101 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8102 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8103 /* LFE Pin (0x0e) */
8104 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8105 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8106 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8107 /* HP Pin (0x0f) */
8108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8109 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8110 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8111 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8112 /* Line In pin */
8113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8115
8116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8119 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8120 { }
8121};
8122
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008123
8124static struct hda_verb alc885_mba21_init_verbs[] = {
8125 /*Internal and HP Speaker Mixer*/
8126 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8127 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8128 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8129 /*Internal Speaker Pin (0x0c)*/
8130 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8131 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8132 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8133 /* HP Pin: output 0 (0x0e) */
8134 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8135 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8136 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8137 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8138 /* Line in (is hp when jack connected)*/
8139 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8140 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8141
8142 { }
8143 };
8144
8145
Takashi Iwai87350ad2007-08-16 18:19:38 +02008146/* Macbook Pro rev3 */
8147static struct hda_verb alc885_mbp3_init_verbs[] = {
8148 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8149 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8152 /* Rear mixer */
8153 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8155 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008156 /* HP mixer */
8157 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8158 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8159 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008160 /* Front Pin: output 0 (0x0c) */
8161 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8162 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8163 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008164 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008166 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8167 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8169 /* Mic (rear) pin: input vref at 80% */
8170 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8171 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8172 /* Front Mic pin: input vref at 80% */
8173 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8174 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8175 /* Line In pin: use output 1 when in LineOut mode */
8176 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8177 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8178 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8179
8180 /* FIXME: use matrix-type input source selection */
8181 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8182 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8183 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8184 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8187 /* Input mixer2 */
8188 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8189 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8190 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8192 /* Input mixer3 */
8193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8197 /* ADC1: mute amp left and right */
8198 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8199 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8200 /* ADC2: mute amp left and right */
8201 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8202 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8203 /* ADC3: mute amp left and right */
8204 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8205 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8206
8207 { }
8208};
8209
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008210/* iMac 9,1 */
8211static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008212 /* Internal Speaker Pin (0x0c) */
8213 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8214 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8215 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8216 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8217 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8218 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8219 /* HP Pin: Rear */
8220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8222 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8223 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8224 /* Line in Rear */
8225 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8226 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8227 /* Front Mic pin: input vref at 80% */
8228 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8229 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008230 /* Rear mixer */
8231 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8232 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8233 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008234 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8235 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8236 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8237 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8238 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008239 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8240 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8242 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008243 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008244 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8245 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8246 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8247 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008248 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008249 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8250 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8251 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8252 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008253 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008254 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8255 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008256 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008257 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8258 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008259 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8261 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008262 { }
8263};
8264
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008265/* iMac 24 mixer. */
8266static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8267 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8268 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8269 { } /* end */
8270};
8271
8272/* iMac 24 init verbs. */
8273static struct hda_verb alc885_imac24_init_verbs[] = {
8274 /* Internal speakers: output 0 (0x0c) */
8275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8277 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8278 /* Internal speakers: output 0 (0x0c) */
8279 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8280 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8281 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8282 /* Headphone: output 0 (0x0c) */
8283 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8284 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8286 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8287 /* Front Mic: input vref at 80% */
8288 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8289 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8290 { }
8291};
8292
8293/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008294static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008295{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008296 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008297
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008298 spec->autocfg.hp_pins[0] = 0x14;
8299 spec->autocfg.speaker_pins[0] = 0x18;
8300 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008301}
8302
Takashi Iwai9d54f082010-02-22 08:34:40 +01008303#define alc885_mb5_setup alc885_imac24_setup
8304#define alc885_macmini3_setup alc885_imac24_setup
8305
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008306/* Macbook Air 2,1 */
8307static void alc885_mba21_setup(struct hda_codec *codec)
8308{
8309 struct alc_spec *spec = codec->spec;
8310
8311 spec->autocfg.hp_pins[0] = 0x14;
8312 spec->autocfg.speaker_pins[0] = 0x18;
8313}
8314
8315
8316
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008317static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008318{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008319 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008320
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008321 spec->autocfg.hp_pins[0] = 0x15;
8322 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008323}
8324
Takashi Iwai9d54f082010-02-22 08:34:40 +01008325static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308326{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008327 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308328
Takashi Iwai9d54f082010-02-22 08:34:40 +01008329 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008330 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008331 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008332}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008333
Kailang Yang272a5272007-05-14 11:00:38 +02008334static struct hda_verb alc882_targa_verbs[] = {
8335 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8336 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8337
8338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8339 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008340
Kailang Yang272a5272007-05-14 11:00:38 +02008341 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8342 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8343 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8344
8345 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008346 { } /* end */
8347};
8348
8349/* toggle speaker-output according to the hp-jack state */
8350static void alc882_targa_automute(struct hda_codec *codec)
8351{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008352 struct alc_spec *spec = codec->spec;
8353 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008354 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008355 spec->jack_present ? 1 : 3);
8356}
8357
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008358static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008359{
8360 struct alc_spec *spec = codec->spec;
8361
8362 spec->autocfg.hp_pins[0] = 0x14;
8363 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008364}
8365
8366static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8367{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008368 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008369 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008370}
8371
8372static struct hda_verb alc882_asus_a7j_verbs[] = {
8373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8375
8376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8378 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008379
Kailang Yang272a5272007-05-14 11:00:38 +02008380 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8381 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8382 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8383
8384 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8385 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8386 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8387 { } /* end */
8388};
8389
Takashi Iwai914759b2007-09-06 14:52:04 +02008390static struct hda_verb alc882_asus_a7m_verbs[] = {
8391 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8392 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8393
8394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8396 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008397
Takashi Iwai914759b2007-09-06 14:52:04 +02008398 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8399 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8400 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8401
8402 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8403 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8404 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8405 { } /* end */
8406};
8407
Tobin Davis9102cd12006-12-15 10:02:12 +01008408static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8409{
8410 unsigned int gpiostate, gpiomask, gpiodir;
8411
8412 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8413 AC_VERB_GET_GPIO_DATA, 0);
8414
8415 if (!muted)
8416 gpiostate |= (1 << pin);
8417 else
8418 gpiostate &= ~(1 << pin);
8419
8420 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8421 AC_VERB_GET_GPIO_MASK, 0);
8422 gpiomask |= (1 << pin);
8423
8424 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8425 AC_VERB_GET_GPIO_DIRECTION, 0);
8426 gpiodir |= (1 << pin);
8427
8428
8429 snd_hda_codec_write(codec, codec->afg, 0,
8430 AC_VERB_SET_GPIO_MASK, gpiomask);
8431 snd_hda_codec_write(codec, codec->afg, 0,
8432 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8433
8434 msleep(1);
8435
8436 snd_hda_codec_write(codec, codec->afg, 0,
8437 AC_VERB_SET_GPIO_DATA, gpiostate);
8438}
8439
Takashi Iwai7debbe52007-08-16 15:01:03 +02008440/* set up GPIO at initialization */
8441static void alc885_macpro_init_hook(struct hda_codec *codec)
8442{
8443 alc882_gpio_mute(codec, 0, 0);
8444 alc882_gpio_mute(codec, 1, 0);
8445}
8446
8447/* set up GPIO and update auto-muting at initialization */
8448static void alc885_imac24_init_hook(struct hda_codec *codec)
8449{
8450 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008451 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008452}
8453
Kailang Yangdf694da2005-12-05 19:42:22 +01008454/*
8455 * generic initialization of ADC, input mixers and output mixers
8456 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008457static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008458 /*
8459 * Unmute ADC0-2 and set the default input to mic-in
8460 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008461 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8462 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8463 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8464 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8465
Kailang Yangdf694da2005-12-05 19:42:22 +01008466 /*
8467 * Set up output mixers (0x0c - 0x0f)
8468 */
8469 /* set vol=0 to output mixers */
8470 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8471 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8472 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8473 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8474 /* set up input amps for analog loopback */
8475 /* Amp Indices: DAC = 0, mixer = 1 */
8476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8478 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8479 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8480 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8481 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8483 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8484 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8485 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8486
8487 /* FIXME: use matrix-type input source selection */
8488 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008489 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008490 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008491 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008492 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008493 { }
8494};
8495
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008496/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8497static struct hda_verb alc889A_mb31_ch2_init[] = {
8498 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8499 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8500 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8501 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8502 { } /* end */
8503};
8504
8505/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8506static struct hda_verb alc889A_mb31_ch4_init[] = {
8507 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8509 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8510 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8511 { } /* end */
8512};
8513
8514/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8515static struct hda_verb alc889A_mb31_ch5_init[] = {
8516 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8518 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8519 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8520 { } /* end */
8521};
8522
8523/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8524static struct hda_verb alc889A_mb31_ch6_init[] = {
8525 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8527 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8528 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8529 { } /* end */
8530};
8531
8532static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8533 { 2, alc889A_mb31_ch2_init },
8534 { 4, alc889A_mb31_ch4_init },
8535 { 5, alc889A_mb31_ch5_init },
8536 { 6, alc889A_mb31_ch6_init },
8537};
8538
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008539static struct hda_verb alc883_medion_eapd_verbs[] = {
8540 /* eanable EAPD on medion laptop */
8541 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8542 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8543 { }
8544};
8545
Takashi Iwai4953550a2009-06-30 15:28:30 +02008546#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008547
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008548static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8549 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8550 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8551 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8552 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8553 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8554 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8555 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8557 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8558 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8559 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8560 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008562 { } /* end */
8563};
8564
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008565static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008566 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8567 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8568 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8569 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8570 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8571 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8573 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8574 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8575 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008576 { } /* end */
8577};
8578
Jiang zhefb97dc62008-03-06 11:07:11 +01008579static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8580 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8581 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8582 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8583 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8585 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8586 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8587 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8588 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8589 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008590 { } /* end */
8591};
8592
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008593static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8594 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8595 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8596 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8597 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8598 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8599 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8600 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8601 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008602 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008603 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8604 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008605 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008607 { } /* end */
8608};
8609
8610static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8611 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8612 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8613 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8614 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8615 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8616 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8617 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8618 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8619 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8620 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8621 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8622 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8623 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8624 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008625 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8627 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008628 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008629 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008630 { } /* end */
8631};
8632
Jiang zhe17bba1b2008-06-04 12:11:07 +02008633static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8634 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8635 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8636 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8637 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8638 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8639 HDA_OUTPUT),
8640 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8641 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8642 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8645 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8646 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8647 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8648 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8649 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8650 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8651 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8652 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8653 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008654 { } /* end */
8655};
8656
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008657static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8658 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8659 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8660 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8661 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8662 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8663 HDA_OUTPUT),
8664 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8665 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8666 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8667 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8668 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8669 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8670 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8671 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8673 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8675 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8676 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8677 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8678 { } /* end */
8679};
8680
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008681static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008682 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008683 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008684 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008685 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008686 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8687 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008688 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8689 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008690 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8691 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8692 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8693 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8694 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008696 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8698 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008699 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008701 { } /* end */
8702};
8703
Sasha Alexandrc2592492009-06-16 14:52:54 -04008704static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008705 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008706 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008707 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008708 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008709 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8710 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8711 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8712 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8713 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8714 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8715 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8716 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8717 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8718 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008720 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008721 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008722 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008723};
Kailang Yangccc656c2006-10-17 12:32:26 +02008724
Sasha Alexandrc2592492009-06-16 14:52:54 -04008725static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008726 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008727 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008728 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008729 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008730 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8731 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8732 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008733 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008734 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008735 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8736 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8737 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008738 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008739};
Kailang Yangccc656c2006-10-17 12:32:26 +02008740
Takashi Iwaib99dba32009-09-17 18:23:00 +02008741static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8742 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8743 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8744 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8745 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8746 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8747 { } /* end */
8748};
8749
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008750static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8751 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8752 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008753 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8754 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008755 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8756 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8757 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8758 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008759 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008760};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008761
Kailang Yang272a5272007-05-14 11:00:38 +02008762static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8763 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8764 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8765 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8766 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8767 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008770 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8771 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008772 { } /* end */
8773};
8774
8775static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8776 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8777 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8778 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8779 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8780 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8781 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8782 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8783 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8784 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008785 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008786};
Kailang Yang272a5272007-05-14 11:00:38 +02008787
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008788static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8789 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8790 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8791 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8792 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8793 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8794 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8795 { } /* end */
8796};
8797
8798static struct hda_verb alc883_medion_wim2160_verbs[] = {
8799 /* Unmute front mixer */
8800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8802
8803 /* Set speaker pin to front mixer */
8804 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8805
8806 /* Init headphone pin */
8807 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8808 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8809 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8810 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8811
8812 { } /* end */
8813};
8814
8815/* toggle speaker-output according to the hp-jack state */
8816static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8817{
8818 struct alc_spec *spec = codec->spec;
8819
8820 spec->autocfg.hp_pins[0] = 0x1a;
8821 spec->autocfg.speaker_pins[0] = 0x15;
8822}
8823
Tobin Davis2880a862007-08-07 11:50:26 +02008824static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008825 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8826 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008827 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008828 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8829 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008830 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8831 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008833 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008834};
Tobin Davis2880a862007-08-07 11:50:26 +02008835
Tony Vroond2fd4b02009-06-21 00:40:10 +01008836static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8837 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008838 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008841 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8842 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8843 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8844 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8845 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8846 { } /* end */
8847};
8848
Kailang Yange2757d52008-08-26 13:17:46 +02008849static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8850 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8851 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8852 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8853 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8854 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8855 0x0d, 1, 0x0, HDA_OUTPUT),
8856 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8857 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8858 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8859 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8860 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8867 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8869 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8870 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008871 { } /* end */
8872};
8873
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008874static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8875 /* Output mixers */
8876 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8877 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8878 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8879 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8880 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8881 HDA_OUTPUT),
8882 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8883 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8884 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8885 /* Output switches */
8886 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8887 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8888 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8889 /* Boost mixers */
8890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8891 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8892 /* Input mixers */
8893 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8894 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8895 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8896 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8897 { } /* end */
8898};
8899
Guido Günther3e1647c2009-06-05 00:47:26 +02008900static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8902 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8903 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8904 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8905 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8906 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8907 { } /* end */
8908};
8909
Kailang Yange2757d52008-08-26 13:17:46 +02008910static struct hda_bind_ctls alc883_bind_cap_vol = {
8911 .ops = &snd_hda_bind_vol,
8912 .values = {
8913 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8914 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8915 0
8916 },
8917};
8918
8919static struct hda_bind_ctls alc883_bind_cap_switch = {
8920 .ops = &snd_hda_bind_sw,
8921 .values = {
8922 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8923 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8924 0
8925 },
8926};
8927
8928static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8935 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008937 { } /* end */
8938};
8939
8940static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008941 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8942 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8943 {
8944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8945 /* .name = "Capture Source", */
8946 .name = "Input Source",
8947 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008948 .info = alc_mux_enum_info,
8949 .get = alc_mux_enum_get,
8950 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008951 },
8952 { } /* end */
8953};
8954
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008955static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8956 {
8957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8958 .name = "Channel Mode",
8959 .info = alc_ch_mode_info,
8960 .get = alc_ch_mode_get,
8961 .put = alc_ch_mode_put,
8962 },
8963 { } /* end */
8964};
8965
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008966/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008967static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008968{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008969 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008970
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008971 spec->autocfg.hp_pins[0] = 0x15;
8972 spec->autocfg.speaker_pins[0] = 0x14;
8973 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008974}
8975
8976/* auto-toggle front mic */
8977/*
8978static void alc883_mitac_mic_automute(struct hda_codec *codec)
8979{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008980 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008981
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008982 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8983}
8984*/
8985
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008986static struct hda_verb alc883_mitac_verbs[] = {
8987 /* HP */
8988 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8990 /* Subwoofer */
8991 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8992 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8993
8994 /* enable unsolicited event */
8995 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8996 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8997
8998 { } /* end */
8999};
9000
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309001static struct hda_verb alc883_clevo_m540r_verbs[] = {
9002 /* HP */
9003 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9005 /* Int speaker */
9006 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9007
9008 /* enable unsolicited event */
9009 /*
9010 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9011 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9012 */
9013
9014 { } /* end */
9015};
9016
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009017static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009018 /* HP */
9019 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9020 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9021 /* Int speaker */
9022 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9024
9025 /* enable unsolicited event */
9026 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009027 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009028
9029 { } /* end */
9030};
9031
Jiang zhefb97dc62008-03-06 11:07:11 +01009032static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9033 /* HP */
9034 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9035 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9036 /* Subwoofer */
9037 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9039
9040 /* enable unsolicited event */
9041 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9042
9043 { } /* end */
9044};
9045
Sasha Alexandrc2592492009-06-16 14:52:54 -04009046static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009047 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9049
9050 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9051 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009052
David Heidelberger64a8be72009-06-08 16:15:18 +02009053/* Connect Line-Out side jack (SPDIF) to Side */
9054 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9055 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9056 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9057/* Connect Mic jack to CLFE */
9058 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9059 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9060 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9061/* Connect Line-in jack to Surround */
9062 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9063 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9064 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9065/* Connect HP out jack to Front */
9066 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9067 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9068 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009069
9070 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009071
9072 { } /* end */
9073};
9074
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009075static struct hda_verb alc883_lenovo_101e_verbs[] = {
9076 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9077 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9078 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9079 { } /* end */
9080};
9081
Kailang Yang272a5272007-05-14 11:00:38 +02009082static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9083 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9084 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9085 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9086 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9087 { } /* end */
9088};
9089
9090static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9091 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9092 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9093 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9094 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9095 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9096 { } /* end */
9097};
9098
Kailang Yang189609a2007-08-20 11:31:23 +02009099static struct hda_verb alc883_haier_w66_verbs[] = {
9100 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9101 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9102
9103 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9104
9105 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9106 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9107 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9109 { } /* end */
9110};
9111
Kailang Yange2757d52008-08-26 13:17:46 +02009112static struct hda_verb alc888_lenovo_sky_verbs[] = {
9113 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9115 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9116 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9117 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9118 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9119 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9120 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9121 { } /* end */
9122};
9123
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009124static struct hda_verb alc888_6st_dell_verbs[] = {
9125 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9126 { }
9127};
9128
Guido Günther3e1647c2009-06-05 00:47:26 +02009129static struct hda_verb alc883_vaiott_verbs[] = {
9130 /* HP */
9131 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9133
9134 /* enable unsolicited event */
9135 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9136
9137 { } /* end */
9138};
9139
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009140static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009141{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009142 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009143
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009144 spec->autocfg.hp_pins[0] = 0x1b;
9145 spec->autocfg.speaker_pins[0] = 0x14;
9146 spec->autocfg.speaker_pins[1] = 0x16;
9147 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009148}
9149
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009150static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009151 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009152 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9153 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009154 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009155 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009156};
9157
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009158/*
9159 * 2ch mode
9160 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009161static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009162 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9163 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9164 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9165 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009166 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009167};
9168
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009169/*
9170 * 4ch mode
9171 */
9172static struct hda_verb alc888_3st_hp_4ch_init[] = {
9173 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9174 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9175 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9176 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9177 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9178 { } /* end */
9179};
9180
9181/*
9182 * 6ch mode
9183 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009184static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009185 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9186 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009187 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009188 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9189 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009190 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9191 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009192};
9193
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009194static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009195 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009196 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009197 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009198};
9199
Kailang Yang272a5272007-05-14 11:00:38 +02009200/* toggle front-jack and RCA according to the hp-jack state */
9201static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9202{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009203 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009204
Takashi Iwai47fd8302007-08-10 17:11:07 +02009205 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9206 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9207 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9208 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009209}
9210
9211/* toggle RCA according to the front-jack state */
9212static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9213{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009214 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009215
Takashi Iwai47fd8302007-08-10 17:11:07 +02009216 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9217 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009218}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009219
Kailang Yang272a5272007-05-14 11:00:38 +02009220static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9221 unsigned int res)
9222{
9223 if ((res >> 26) == ALC880_HP_EVENT)
9224 alc888_lenovo_ms7195_front_automute(codec);
9225 if ((res >> 26) == ALC880_FRONT_EVENT)
9226 alc888_lenovo_ms7195_rca_automute(codec);
9227}
9228
9229static struct hda_verb alc883_medion_md2_verbs[] = {
9230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9232
9233 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9234
9235 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9236 { } /* end */
9237};
9238
9239/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009240static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009241{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009242 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009243
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009244 spec->autocfg.hp_pins[0] = 0x14;
9245 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009246}
9247
Kailang Yangccc656c2006-10-17 12:32:26 +02009248/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009249#define alc883_targa_init_hook alc882_targa_init_hook
9250#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009251
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009252static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9253{
9254 unsigned int present;
9255
Takashi Iwaid56757a2009-11-18 08:00:14 +01009256 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009257 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9258 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9259}
9260
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009261static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009262{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009263 struct alc_spec *spec = codec->spec;
9264
9265 spec->autocfg.hp_pins[0] = 0x15;
9266 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009267}
9268
9269static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9270{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009271 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009272 alc883_clevo_m720_mic_automute(codec);
9273}
9274
9275static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009276 unsigned int res)
9277{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009278 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009279 case ALC880_MIC_EVENT:
9280 alc883_clevo_m720_mic_automute(codec);
9281 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009282 default:
9283 alc_automute_amp_unsol_event(codec, res);
9284 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009285 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009286}
9287
Jiang zhefb97dc62008-03-06 11:07:11 +01009288/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009289static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009290{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009291 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009292
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009293 spec->autocfg.hp_pins[0] = 0x14;
9294 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009295}
9296
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009297static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009298{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009299 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009300
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009301 spec->autocfg.hp_pins[0] = 0x1b;
9302 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009303}
9304
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009305static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9306{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009307 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009308
Takashi Iwai47fd8302007-08-10 17:11:07 +02009309 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9310 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009311}
9312
9313static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9314{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009315 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009316
Takashi Iwai47fd8302007-08-10 17:11:07 +02009317 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9318 HDA_AMP_MUTE, bits);
9319 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9320 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009321}
9322
9323static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9324 unsigned int res)
9325{
9326 if ((res >> 26) == ALC880_HP_EVENT)
9327 alc883_lenovo_101e_all_automute(codec);
9328 if ((res >> 26) == ALC880_FRONT_EVENT)
9329 alc883_lenovo_101e_ispeaker_automute(codec);
9330}
9331
Takashi Iwai676a9b52007-08-16 15:23:35 +02009332/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009333static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009334{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009335 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009336
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009337 spec->autocfg.hp_pins[0] = 0x14;
9338 spec->autocfg.speaker_pins[0] = 0x15;
9339 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009340}
9341
Kailang Yangd1a991a2007-08-15 16:21:59 +02009342static struct hda_verb alc883_acer_eapd_verbs[] = {
9343 /* HP Pin: output 0 (0x0c) */
9344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9345 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9346 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9347 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009348 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9349 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009350 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009351 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9352 /* eanable EAPD on medion laptop */
9353 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9354 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009355 /* enable unsolicited event */
9356 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009357 { }
9358};
9359
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009360static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9361 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9362 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9363 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9364 { } /* end */
9365};
9366
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009367static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009368{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009369 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009370
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009371 spec->autocfg.hp_pins[0] = 0x1b;
9372 spec->autocfg.speaker_pins[0] = 0x14;
9373 spec->autocfg.speaker_pins[1] = 0x15;
9374 spec->autocfg.speaker_pins[2] = 0x16;
9375 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009376}
9377
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009378static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009379{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009380 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009381
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009382 spec->autocfg.hp_pins[0] = 0x1b;
9383 spec->autocfg.speaker_pins[0] = 0x14;
9384 spec->autocfg.speaker_pins[1] = 0x15;
9385 spec->autocfg.speaker_pins[2] = 0x16;
9386 spec->autocfg.speaker_pins[3] = 0x17;
9387 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009388}
9389
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009390static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009391{
9392 struct alc_spec *spec = codec->spec;
9393
9394 spec->autocfg.hp_pins[0] = 0x15;
9395 spec->autocfg.speaker_pins[0] = 0x14;
9396 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009397}
9398
Kailang Yange2757d52008-08-26 13:17:46 +02009399static struct hda_verb alc888_asus_m90v_verbs[] = {
9400 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9401 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9402 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9403 /* enable unsolicited event */
9404 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9405 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9406 { } /* end */
9407};
9408
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009409static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009410{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009411 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009412
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009413 spec->autocfg.hp_pins[0] = 0x1b;
9414 spec->autocfg.speaker_pins[0] = 0x14;
9415 spec->autocfg.speaker_pins[1] = 0x15;
9416 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009417 spec->ext_mic.pin = 0x18;
9418 spec->int_mic.pin = 0x19;
9419 spec->ext_mic.mux_idx = 0;
9420 spec->int_mic.mux_idx = 1;
9421 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009422}
9423
9424static struct hda_verb alc888_asus_eee1601_verbs[] = {
9425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9426 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9428 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9430 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9431 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9432 /* enable unsolicited event */
9433 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9434 { } /* end */
9435};
9436
Kailang Yange2757d52008-08-26 13:17:46 +02009437static void alc883_eee1601_inithook(struct hda_codec *codec)
9438{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009439 struct alc_spec *spec = codec->spec;
9440
9441 spec->autocfg.hp_pins[0] = 0x14;
9442 spec->autocfg.speaker_pins[0] = 0x1b;
9443 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009444}
9445
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009446static struct hda_verb alc889A_mb31_verbs[] = {
9447 /* Init rear pin (used as headphone output) */
9448 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9449 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9450 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9451 /* Init line pin (used as output in 4ch and 6ch mode) */
9452 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9453 /* Init line 2 pin (used as headphone out by default) */
9454 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9455 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9456 { } /* end */
9457};
9458
9459/* Mute speakers according to the headphone jack state */
9460static void alc889A_mb31_automute(struct hda_codec *codec)
9461{
9462 unsigned int present;
9463
9464 /* Mute only in 2ch or 4ch mode */
9465 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9466 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009467 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9470 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9471 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9472 }
9473}
9474
9475static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9476{
9477 if ((res >> 26) == ALC880_HP_EVENT)
9478 alc889A_mb31_automute(codec);
9479}
9480
Takashi Iwai4953550a2009-06-30 15:28:30 +02009481
Takashi Iwaicb53c622007-08-10 17:21:45 +02009482#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009483#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009484#endif
9485
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009486/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009487#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9488#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9489#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9490#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9491
9492static hda_nid_t alc883_slave_dig_outs[] = {
9493 ALC1200_DIGOUT_NID, 0,
9494};
9495
9496static hda_nid_t alc1200_slave_dig_outs[] = {
9497 ALC883_DIGOUT_NID, 0,
9498};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009499
9500/*
9501 * configuration and preset
9502 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009503static const char *alc882_models[ALC882_MODEL_LAST] = {
9504 [ALC882_3ST_DIG] = "3stack-dig",
9505 [ALC882_6ST_DIG] = "6stack-dig",
9506 [ALC882_ARIMA] = "arima",
9507 [ALC882_W2JC] = "w2jc",
9508 [ALC882_TARGA] = "targa",
9509 [ALC882_ASUS_A7J] = "asus-a7j",
9510 [ALC882_ASUS_A7M] = "asus-a7m",
9511 [ALC885_MACPRO] = "macpro",
9512 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009513 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009514 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009515 [ALC885_MBP3] = "mbp3",
9516 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009517 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009518 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009519 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9520 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009521 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009522 [ALC883_TARGA_DIG] = "targa-dig",
9523 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009524 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009525 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009526 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009527 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009528 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009529 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009530 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009531 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009532 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009533 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009534 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009535 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009536 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9537 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009538 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009539 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009540 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009541 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009542 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309543 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009544 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009545 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009546 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009547 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009548 [ALC889A_INTEL] = "intel-alc889a",
9549 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009550 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009551 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009552 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009553 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009554};
9555
Takashi Iwai4953550a2009-06-30 15:28:30 +02009556static struct snd_pci_quirk alc882_cfg_tbl[] = {
9557 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9558
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009559 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009560 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009561 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009562 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9563 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009564 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009565 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9566 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009567 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009568 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009569 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9570 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009571 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9572 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009573 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9574 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009575 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009576 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009577 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009578 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009579 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9580 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009581 /* default Acer -- disabled as it causes more problems.
9582 * model=auto should work fine now
9583 */
9584 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009585
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009586 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009587
Tobin Davisfebe3372007-06-12 11:27:46 +02009588 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009589 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9590 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009591 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009592 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009593 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009594
9595 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9596 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9597 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009598 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009599 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9600 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9601 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009602 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009603 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009604 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009605 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009606
9607 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009608 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009609 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009610 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009611 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9612 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009613 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009614 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009615 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9616
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009617 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9618 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9619 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009620 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009621 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009622 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009623 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009624 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009625 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9626 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9627 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9628 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9629 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9630 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009631 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009632 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9633 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9634 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009635 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009636 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009637 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9638 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009639 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009640 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009641 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009642 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009643 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009644 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009645 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009646 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009647 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009648
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009649 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009650 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009651 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9652 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309653 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009654 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009655 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009656 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009657 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009658 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009659 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009660 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009661 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009662 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009663 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009664 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9665 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009666 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009667 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009668 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009669 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009670 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009671
Jiang zhe17bba1b2008-06-04 12:11:07 +02009672 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9673 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009674 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009675 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9676 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9677 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009678 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009679
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009680 {}
9681};
9682
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683/* codec SSID table for Intel Mac */
9684static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9685 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9686 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9687 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9688 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9689 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9690 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9691 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009692 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009693 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009694 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009695 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009696 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9697 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9698 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009699 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009700 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009701 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009702 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9703 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009704 */
9705 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009706 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009707 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009708 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009709};
9710
Takashi Iwai4953550a2009-06-30 15:28:30 +02009711static struct alc_config_preset alc882_presets[] = {
9712 [ALC882_3ST_DIG] = {
9713 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009714 .init_verbs = { alc882_base_init_verbs,
9715 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009716 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9717 .dac_nids = alc882_dac_nids,
9718 .dig_out_nid = ALC882_DIGOUT_NID,
9719 .dig_in_nid = ALC882_DIGIN_NID,
9720 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9721 .channel_mode = alc882_ch_modes,
9722 .need_dac_fix = 1,
9723 .input_mux = &alc882_capture_source,
9724 },
9725 [ALC882_6ST_DIG] = {
9726 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009727 .init_verbs = { alc882_base_init_verbs,
9728 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009729 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9730 .dac_nids = alc882_dac_nids,
9731 .dig_out_nid = ALC882_DIGOUT_NID,
9732 .dig_in_nid = ALC882_DIGIN_NID,
9733 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9734 .channel_mode = alc882_sixstack_modes,
9735 .input_mux = &alc882_capture_source,
9736 },
9737 [ALC882_ARIMA] = {
9738 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009739 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9740 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9742 .dac_nids = alc882_dac_nids,
9743 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9744 .channel_mode = alc882_sixstack_modes,
9745 .input_mux = &alc882_capture_source,
9746 },
9747 [ALC882_W2JC] = {
9748 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009749 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9750 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009751 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9752 .dac_nids = alc882_dac_nids,
9753 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9754 .channel_mode = alc880_threestack_modes,
9755 .need_dac_fix = 1,
9756 .input_mux = &alc882_capture_source,
9757 .dig_out_nid = ALC882_DIGOUT_NID,
9758 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009759 [ALC885_MBA21] = {
9760 .mixers = { alc885_mba21_mixer },
9761 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9762 .num_dacs = 2,
9763 .dac_nids = alc882_dac_nids,
9764 .channel_mode = alc885_mba21_ch_modes,
9765 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9766 .input_mux = &alc882_capture_source,
9767 .unsol_event = alc_automute_amp_unsol_event,
9768 .setup = alc885_mba21_setup,
9769 .init_hook = alc_automute_amp,
9770 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009771 [ALC885_MBP3] = {
9772 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9773 .init_verbs = { alc885_mbp3_init_verbs,
9774 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009775 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009776 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009777 .hp_nid = 0x04,
9778 .channel_mode = alc885_mbp_4ch_modes,
9779 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009780 .input_mux = &alc882_capture_source,
9781 .dig_out_nid = ALC882_DIGOUT_NID,
9782 .dig_in_nid = ALC882_DIGIN_NID,
9783 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009784 .setup = alc885_mbp3_setup,
9785 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009786 },
9787 [ALC885_MB5] = {
9788 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9789 .init_verbs = { alc885_mb5_init_verbs,
9790 alc880_gpio1_init_verbs },
9791 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9792 .dac_nids = alc882_dac_nids,
9793 .channel_mode = alc885_mb5_6ch_modes,
9794 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9795 .input_mux = &mb5_capture_source,
9796 .dig_out_nid = ALC882_DIGOUT_NID,
9797 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009798 .unsol_event = alc_automute_amp_unsol_event,
9799 .setup = alc885_mb5_setup,
9800 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009801 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009802 [ALC885_MACMINI3] = {
9803 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9804 .init_verbs = { alc885_macmini3_init_verbs,
9805 alc880_gpio1_init_verbs },
9806 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9807 .dac_nids = alc882_dac_nids,
9808 .channel_mode = alc885_macmini3_6ch_modes,
9809 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9810 .input_mux = &macmini3_capture_source,
9811 .dig_out_nid = ALC882_DIGOUT_NID,
9812 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009813 .unsol_event = alc_automute_amp_unsol_event,
9814 .setup = alc885_macmini3_setup,
9815 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009816 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009817 [ALC885_MACPRO] = {
9818 .mixers = { alc882_macpro_mixer },
9819 .init_verbs = { alc882_macpro_init_verbs },
9820 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9821 .dac_nids = alc882_dac_nids,
9822 .dig_out_nid = ALC882_DIGOUT_NID,
9823 .dig_in_nid = ALC882_DIGIN_NID,
9824 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9825 .channel_mode = alc882_ch_modes,
9826 .input_mux = &alc882_capture_source,
9827 .init_hook = alc885_macpro_init_hook,
9828 },
9829 [ALC885_IMAC24] = {
9830 .mixers = { alc885_imac24_mixer },
9831 .init_verbs = { alc885_imac24_init_verbs },
9832 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9833 .dac_nids = alc882_dac_nids,
9834 .dig_out_nid = ALC882_DIGOUT_NID,
9835 .dig_in_nid = ALC882_DIGIN_NID,
9836 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9837 .channel_mode = alc882_ch_modes,
9838 .input_mux = &alc882_capture_source,
9839 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009840 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009841 .init_hook = alc885_imac24_init_hook,
9842 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009843 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009844 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009845 .init_verbs = { alc885_imac91_init_verbs,
9846 alc880_gpio1_init_verbs },
9847 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9848 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009849 .channel_mode = alc885_mba21_ch_modes,
9850 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9851 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009852 .dig_out_nid = ALC882_DIGOUT_NID,
9853 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009854 .unsol_event = alc_automute_amp_unsol_event,
9855 .setup = alc885_imac91_setup,
9856 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009857 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858 [ALC882_TARGA] = {
9859 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009860 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009861 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009862 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9863 .dac_nids = alc882_dac_nids,
9864 .dig_out_nid = ALC882_DIGOUT_NID,
9865 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9866 .adc_nids = alc882_adc_nids,
9867 .capsrc_nids = alc882_capsrc_nids,
9868 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9869 .channel_mode = alc882_3ST_6ch_modes,
9870 .need_dac_fix = 1,
9871 .input_mux = &alc882_capture_source,
9872 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009873 .setup = alc882_targa_setup,
9874 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009875 },
9876 [ALC882_ASUS_A7J] = {
9877 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009878 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9879 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009880 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9881 .dac_nids = alc882_dac_nids,
9882 .dig_out_nid = ALC882_DIGOUT_NID,
9883 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9884 .adc_nids = alc882_adc_nids,
9885 .capsrc_nids = alc882_capsrc_nids,
9886 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9887 .channel_mode = alc882_3ST_6ch_modes,
9888 .need_dac_fix = 1,
9889 .input_mux = &alc882_capture_source,
9890 },
9891 [ALC882_ASUS_A7M] = {
9892 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009893 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9894 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009895 alc882_asus_a7m_verbs },
9896 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9897 .dac_nids = alc882_dac_nids,
9898 .dig_out_nid = ALC882_DIGOUT_NID,
9899 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9900 .channel_mode = alc880_threestack_modes,
9901 .need_dac_fix = 1,
9902 .input_mux = &alc882_capture_source,
9903 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009904 [ALC883_3ST_2ch_DIG] = {
9905 .mixers = { alc883_3ST_2ch_mixer },
9906 .init_verbs = { alc883_init_verbs },
9907 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9908 .dac_nids = alc883_dac_nids,
9909 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009910 .dig_in_nid = ALC883_DIGIN_NID,
9911 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9912 .channel_mode = alc883_3ST_2ch_modes,
9913 .input_mux = &alc883_capture_source,
9914 },
9915 [ALC883_3ST_6ch_DIG] = {
9916 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9917 .init_verbs = { alc883_init_verbs },
9918 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9919 .dac_nids = alc883_dac_nids,
9920 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009921 .dig_in_nid = ALC883_DIGIN_NID,
9922 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9923 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009924 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009925 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009926 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009927 [ALC883_3ST_6ch] = {
9928 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9929 .init_verbs = { alc883_init_verbs },
9930 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9931 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009932 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9933 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009934 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009935 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009936 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009937 [ALC883_3ST_6ch_INTEL] = {
9938 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9939 .init_verbs = { alc883_init_verbs },
9940 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9941 .dac_nids = alc883_dac_nids,
9942 .dig_out_nid = ALC883_DIGOUT_NID,
9943 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009944 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009945 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9946 .channel_mode = alc883_3ST_6ch_intel_modes,
9947 .need_dac_fix = 1,
9948 .input_mux = &alc883_3stack_6ch_intel,
9949 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009950 [ALC889A_INTEL] = {
9951 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009952 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9953 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009954 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9955 .dac_nids = alc883_dac_nids,
9956 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9957 .adc_nids = alc889_adc_nids,
9958 .dig_out_nid = ALC883_DIGOUT_NID,
9959 .dig_in_nid = ALC883_DIGIN_NID,
9960 .slave_dig_outs = alc883_slave_dig_outs,
9961 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9962 .channel_mode = alc889_8ch_intel_modes,
9963 .capsrc_nids = alc889_capsrc_nids,
9964 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009965 .setup = alc889_automute_setup,
9966 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009967 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009968 .need_dac_fix = 1,
9969 },
9970 [ALC889_INTEL] = {
9971 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9972 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009973 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009974 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9975 .dac_nids = alc883_dac_nids,
9976 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9977 .adc_nids = alc889_adc_nids,
9978 .dig_out_nid = ALC883_DIGOUT_NID,
9979 .dig_in_nid = ALC883_DIGIN_NID,
9980 .slave_dig_outs = alc883_slave_dig_outs,
9981 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9982 .channel_mode = alc889_8ch_intel_modes,
9983 .capsrc_nids = alc889_capsrc_nids,
9984 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009985 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009986 .init_hook = alc889_intel_init_hook,
9987 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009988 .need_dac_fix = 1,
9989 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009990 [ALC883_6ST_DIG] = {
9991 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9992 .init_verbs = { alc883_init_verbs },
9993 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9994 .dac_nids = alc883_dac_nids,
9995 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009996 .dig_in_nid = ALC883_DIGIN_NID,
9997 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9998 .channel_mode = alc883_sixstack_modes,
9999 .input_mux = &alc883_capture_source,
10000 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010001 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010002 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010003 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10004 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010005 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10006 .dac_nids = alc883_dac_nids,
10007 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010008 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10009 .channel_mode = alc883_3ST_6ch_modes,
10010 .need_dac_fix = 1,
10011 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010012 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010013 .setup = alc882_targa_setup,
10014 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010015 },
10016 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010017 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010018 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10019 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010020 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10021 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010022 .adc_nids = alc883_adc_nids_alt,
10023 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010024 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010025 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010026 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10027 .channel_mode = alc883_3ST_2ch_modes,
10028 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010029 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010030 .setup = alc882_targa_setup,
10031 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010032 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010033 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010034 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10035 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010036 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010037 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010038 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10039 .dac_nids = alc883_dac_nids,
10040 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10041 .adc_nids = alc883_adc_nids_rev,
10042 .capsrc_nids = alc883_capsrc_nids_rev,
10043 .dig_out_nid = ALC883_DIGOUT_NID,
10044 .dig_in_nid = ALC883_DIGIN_NID,
10045 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10046 .channel_mode = alc883_4ST_8ch_modes,
10047 .need_dac_fix = 1,
10048 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010049 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010050 .setup = alc882_targa_setup,
10051 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010052 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010053 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010054 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010055 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10056 * and the headphone jack. Turn this on and rely on the
10057 * standard mute methods whenever the user wants to turn
10058 * these outputs off.
10059 */
10060 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10061 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10062 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010063 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10064 .channel_mode = alc883_3ST_2ch_modes,
10065 .input_mux = &alc883_capture_source,
10066 },
Tobin Davis2880a862007-08-07 11:50:26 +020010067 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010068 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010069 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010070 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10071 .dac_nids = alc883_dac_nids,
10072 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010073 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10074 .channel_mode = alc883_3ST_2ch_modes,
10075 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010076 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010077 .setup = alc883_acer_aspire_setup,
10078 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010079 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010080 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010081 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010082 alc883_chmode_mixer },
10083 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10084 alc888_acer_aspire_4930g_verbs },
10085 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10086 .dac_nids = alc883_dac_nids,
10087 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10088 .adc_nids = alc883_adc_nids_rev,
10089 .capsrc_nids = alc883_capsrc_nids_rev,
10090 .dig_out_nid = ALC883_DIGOUT_NID,
10091 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10092 .channel_mode = alc883_3ST_6ch_modes,
10093 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010094 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010095 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010096 ARRAY_SIZE(alc888_2_capture_sources),
10097 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010098 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010099 .setup = alc888_acer_aspire_4930g_setup,
10100 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010101 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010102 [ALC888_ACER_ASPIRE_6530G] = {
10103 .mixers = { alc888_acer_aspire_6530_mixer },
10104 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10105 alc888_acer_aspire_6530g_verbs },
10106 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10107 .dac_nids = alc883_dac_nids,
10108 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10109 .adc_nids = alc883_adc_nids_rev,
10110 .capsrc_nids = alc883_capsrc_nids_rev,
10111 .dig_out_nid = ALC883_DIGOUT_NID,
10112 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10113 .channel_mode = alc883_3ST_2ch_modes,
10114 .num_mux_defs =
10115 ARRAY_SIZE(alc888_2_capture_sources),
10116 .input_mux = alc888_acer_aspire_6530_sources,
10117 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010118 .setup = alc888_acer_aspire_6530g_setup,
10119 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010120 },
Hector Martin3b315d72009-06-02 10:54:19 +020010121 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010122 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010123 alc883_chmode_mixer },
10124 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010125 alc889_acer_aspire_8930g_verbs,
10126 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010127 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10128 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010129 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10130 .adc_nids = alc889_adc_nids,
10131 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010132 .dig_out_nid = ALC883_DIGOUT_NID,
10133 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10134 .channel_mode = alc883_3ST_6ch_modes,
10135 .need_dac_fix = 1,
10136 .const_channel_count = 6,
10137 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010138 ARRAY_SIZE(alc889_capture_sources),
10139 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010140 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010141 .setup = alc889_acer_aspire_8930g_setup,
10142 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010143#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010144 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010145#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010146 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010147 [ALC888_ACER_ASPIRE_7730G] = {
10148 .mixers = { alc883_3ST_6ch_mixer,
10149 alc883_chmode_mixer },
10150 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10151 alc888_acer_aspire_7730G_verbs },
10152 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10153 .dac_nids = alc883_dac_nids,
10154 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10155 .adc_nids = alc883_adc_nids_rev,
10156 .capsrc_nids = alc883_capsrc_nids_rev,
10157 .dig_out_nid = ALC883_DIGOUT_NID,
10158 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10159 .channel_mode = alc883_3ST_6ch_modes,
10160 .need_dac_fix = 1,
10161 .const_channel_count = 6,
10162 .input_mux = &alc883_capture_source,
10163 .unsol_event = alc_automute_amp_unsol_event,
10164 .setup = alc888_acer_aspire_6530g_setup,
10165 .init_hook = alc_automute_amp,
10166 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010167 [ALC883_MEDION] = {
10168 .mixers = { alc883_fivestack_mixer,
10169 alc883_chmode_mixer },
10170 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010171 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010172 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10173 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010174 .adc_nids = alc883_adc_nids_alt,
10175 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010176 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010177 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10178 .channel_mode = alc883_sixstack_modes,
10179 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010180 },
Kailang Yang272a5272007-05-14 11:00:38 +020010181 [ALC883_MEDION_MD2] = {
10182 .mixers = { alc883_medion_md2_mixer},
10183 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10184 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10185 .dac_nids = alc883_dac_nids,
10186 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010187 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10188 .channel_mode = alc883_3ST_2ch_modes,
10189 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010190 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010191 .setup = alc883_medion_md2_setup,
10192 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010193 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010194 [ALC883_MEDION_WIM2160] = {
10195 .mixers = { alc883_medion_wim2160_mixer },
10196 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10197 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10198 .dac_nids = alc883_dac_nids,
10199 .dig_out_nid = ALC883_DIGOUT_NID,
10200 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10201 .adc_nids = alc883_adc_nids,
10202 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10203 .channel_mode = alc883_3ST_2ch_modes,
10204 .input_mux = &alc883_capture_source,
10205 .unsol_event = alc_automute_amp_unsol_event,
10206 .setup = alc883_medion_wim2160_setup,
10207 .init_hook = alc_automute_amp,
10208 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010209 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010210 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010211 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10213 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010214 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10215 .channel_mode = alc883_3ST_2ch_modes,
10216 .input_mux = &alc883_capture_source,
10217 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010218 [ALC883_CLEVO_M540R] = {
10219 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10220 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10221 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10222 .dac_nids = alc883_dac_nids,
10223 .dig_out_nid = ALC883_DIGOUT_NID,
10224 .dig_in_nid = ALC883_DIGIN_NID,
10225 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10226 .channel_mode = alc883_3ST_6ch_clevo_modes,
10227 .need_dac_fix = 1,
10228 .input_mux = &alc883_capture_source,
10229 /* This machine has the hardware HP auto-muting, thus
10230 * we need no software mute via unsol event
10231 */
10232 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010233 [ALC883_CLEVO_M720] = {
10234 .mixers = { alc883_clevo_m720_mixer },
10235 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010236 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10237 .dac_nids = alc883_dac_nids,
10238 .dig_out_nid = ALC883_DIGOUT_NID,
10239 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10240 .channel_mode = alc883_3ST_2ch_modes,
10241 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010242 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010243 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010244 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010245 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010246 [ALC883_LENOVO_101E_2ch] = {
10247 .mixers = { alc883_lenovo_101e_2ch_mixer},
10248 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10249 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10250 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010251 .adc_nids = alc883_adc_nids_alt,
10252 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010253 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010254 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10255 .channel_mode = alc883_3ST_2ch_modes,
10256 .input_mux = &alc883_lenovo_101e_capture_source,
10257 .unsol_event = alc883_lenovo_101e_unsol_event,
10258 .init_hook = alc883_lenovo_101e_all_automute,
10259 },
Kailang Yang272a5272007-05-14 11:00:38 +020010260 [ALC883_LENOVO_NB0763] = {
10261 .mixers = { alc883_lenovo_nb0763_mixer },
10262 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10263 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10264 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010265 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10266 .channel_mode = alc883_3ST_2ch_modes,
10267 .need_dac_fix = 1,
10268 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010269 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010270 .setup = alc883_medion_md2_setup,
10271 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010272 },
10273 [ALC888_LENOVO_MS7195_DIG] = {
10274 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10275 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10276 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10277 .dac_nids = alc883_dac_nids,
10278 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010279 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10280 .channel_mode = alc883_3ST_6ch_modes,
10281 .need_dac_fix = 1,
10282 .input_mux = &alc883_capture_source,
10283 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10284 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010285 },
10286 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010287 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010288 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10289 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10290 .dac_nids = alc883_dac_nids,
10291 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010292 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10293 .channel_mode = alc883_3ST_2ch_modes,
10294 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010295 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010296 .setup = alc883_haier_w66_setup,
10297 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010298 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010299 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010300 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010301 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010302 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10303 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010304 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10305 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010306 .need_dac_fix = 1,
10307 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010308 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010309 .setup = alc888_3st_hp_setup,
10310 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010311 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010312 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010313 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010314 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10316 .dac_nids = alc883_dac_nids,
10317 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010318 .dig_in_nid = ALC883_DIGIN_NID,
10319 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10320 .channel_mode = alc883_sixstack_modes,
10321 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010322 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010323 .setup = alc888_6st_dell_setup,
10324 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010325 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010326 [ALC883_MITAC] = {
10327 .mixers = { alc883_mitac_mixer },
10328 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10330 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010331 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10332 .channel_mode = alc883_3ST_2ch_modes,
10333 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010334 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010335 .setup = alc883_mitac_setup,
10336 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010337 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010338 [ALC883_FUJITSU_PI2515] = {
10339 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10340 .init_verbs = { alc883_init_verbs,
10341 alc883_2ch_fujitsu_pi2515_verbs},
10342 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10343 .dac_nids = alc883_dac_nids,
10344 .dig_out_nid = ALC883_DIGOUT_NID,
10345 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10346 .channel_mode = alc883_3ST_2ch_modes,
10347 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010348 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010349 .setup = alc883_2ch_fujitsu_pi2515_setup,
10350 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010351 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010352 [ALC888_FUJITSU_XA3530] = {
10353 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10354 .init_verbs = { alc883_init_verbs,
10355 alc888_fujitsu_xa3530_verbs },
10356 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10357 .dac_nids = alc883_dac_nids,
10358 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10359 .adc_nids = alc883_adc_nids_rev,
10360 .capsrc_nids = alc883_capsrc_nids_rev,
10361 .dig_out_nid = ALC883_DIGOUT_NID,
10362 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10363 .channel_mode = alc888_4ST_8ch_intel_modes,
10364 .num_mux_defs =
10365 ARRAY_SIZE(alc888_2_capture_sources),
10366 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010367 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010368 .setup = alc888_fujitsu_xa3530_setup,
10369 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010370 },
Kailang Yange2757d52008-08-26 13:17:46 +020010371 [ALC888_LENOVO_SKY] = {
10372 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10373 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10374 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10375 .dac_nids = alc883_dac_nids,
10376 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010377 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10378 .channel_mode = alc883_sixstack_modes,
10379 .need_dac_fix = 1,
10380 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010381 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010382 .setup = alc888_lenovo_sky_setup,
10383 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010384 },
10385 [ALC888_ASUS_M90V] = {
10386 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10387 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10388 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10389 .dac_nids = alc883_dac_nids,
10390 .dig_out_nid = ALC883_DIGOUT_NID,
10391 .dig_in_nid = ALC883_DIGIN_NID,
10392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10393 .channel_mode = alc883_3ST_6ch_modes,
10394 .need_dac_fix = 1,
10395 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010396 .unsol_event = alc_sku_unsol_event,
10397 .setup = alc883_mode2_setup,
10398 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010399 },
10400 [ALC888_ASUS_EEE1601] = {
10401 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010402 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010403 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10404 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10405 .dac_nids = alc883_dac_nids,
10406 .dig_out_nid = ALC883_DIGOUT_NID,
10407 .dig_in_nid = ALC883_DIGIN_NID,
10408 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10409 .channel_mode = alc883_3ST_2ch_modes,
10410 .need_dac_fix = 1,
10411 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010412 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010413 .init_hook = alc883_eee1601_inithook,
10414 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010415 [ALC1200_ASUS_P5Q] = {
10416 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10417 .init_verbs = { alc883_init_verbs },
10418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10419 .dac_nids = alc883_dac_nids,
10420 .dig_out_nid = ALC1200_DIGOUT_NID,
10421 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010422 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010423 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10424 .channel_mode = alc883_sixstack_modes,
10425 .input_mux = &alc883_capture_source,
10426 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010427 [ALC889A_MB31] = {
10428 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10429 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10430 alc880_gpio1_init_verbs },
10431 .adc_nids = alc883_adc_nids,
10432 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010433 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010434 .dac_nids = alc883_dac_nids,
10435 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10436 .channel_mode = alc889A_mb31_6ch_modes,
10437 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10438 .input_mux = &alc889A_mb31_capture_source,
10439 .dig_out_nid = ALC883_DIGOUT_NID,
10440 .unsol_event = alc889A_mb31_unsol_event,
10441 .init_hook = alc889A_mb31_automute,
10442 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010443 [ALC883_SONY_VAIO_TT] = {
10444 .mixers = { alc883_vaiott_mixer },
10445 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10446 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10447 .dac_nids = alc883_dac_nids,
10448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10449 .channel_mode = alc883_3ST_2ch_modes,
10450 .input_mux = &alc883_capture_source,
10451 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010452 .setup = alc883_vaiott_setup,
10453 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010454 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010455};
10456
10457
10458/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010459 * Pin config fixes
10460 */
10461enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010462 PINFIX_ABIT_AW9D_MAX,
10463 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010464};
10465
10466static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10467 { 0x15, 0x01080104 }, /* side */
10468 { 0x16, 0x01011012 }, /* rear */
10469 { 0x17, 0x01016011 }, /* clfe */
10470 { }
10471};
10472
Takashi Iwai954a29c2010-07-30 10:55:44 +020010473static const struct hda_verb pb_m5210_verbs[] = {
10474 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10475 {}
10476};
10477
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010478static const struct alc_fixup alc882_fixups[] = {
10479 [PINFIX_ABIT_AW9D_MAX] = {
10480 .pins = alc882_abit_aw9d_pinfix
10481 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010482 [PINFIX_PB_M5210] = {
10483 .verbs = pb_m5210_verbs
10484 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010485};
10486
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010487static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010488 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010489 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10490 {}
10491};
10492
10493/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010494 * BIOS auto configuration
10495 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010496static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10497 const struct auto_pin_cfg *cfg)
10498{
10499 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10500}
10501
Takashi Iwai4953550a2009-06-30 15:28:30 +020010502static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010503 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010504 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010505{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010506 int idx;
10507
Takashi Iwai489008c2010-04-07 09:06:00 +020010508 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010509 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010510
Takashi Iwai489008c2010-04-07 09:06:00 +020010511 if (dac == 0x25)
10512 idx = 4;
10513 else if (dac >= 0x02 && dac <= 0x05)
10514 idx = dac - 2;
10515 else
10516 return;
10517 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010518}
10519
Takashi Iwai4953550a2009-06-30 15:28:30 +020010520static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521{
10522 struct alc_spec *spec = codec->spec;
10523 int i;
10524
10525 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010526 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010527 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010528 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010529 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010530 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010531 }
10532}
10533
Takashi Iwai4953550a2009-06-30 15:28:30 +020010534static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010535{
10536 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010537 hda_nid_t pin, dac;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010538
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010539 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010540 if (pin) {
10541 dac = spec->multiout.hp_nid;
10542 if (!dac)
10543 dac = spec->multiout.dac_nids[0]; /* to front */
10544 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10545 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010546 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010547 if (pin) {
10548 dac = spec->multiout.extra_out_nid[0];
10549 if (!dac)
10550 dac = spec->multiout.dac_nids[0]; /* to front */
10551 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10552 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010553}
10554
Takashi Iwai4953550a2009-06-30 15:28:30 +020010555static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010556{
10557 struct alc_spec *spec = codec->spec;
10558 int i;
10559
10560 for (i = 0; i < AUTO_PIN_LAST; i++) {
10561 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010562 if (!nid)
10563 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010564 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010565 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10566 snd_hda_codec_write(codec, nid, 0,
10567 AC_VERB_SET_AMP_GAIN_MUTE,
10568 AMP_OUT_MUTE);
10569 }
10570}
10571
10572static void alc882_auto_init_input_src(struct hda_codec *codec)
10573{
10574 struct alc_spec *spec = codec->spec;
10575 int c;
10576
10577 for (c = 0; c < spec->num_adc_nids; c++) {
10578 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10579 hda_nid_t nid = spec->capsrc_nids[c];
10580 unsigned int mux_idx;
10581 const struct hda_input_mux *imux;
10582 int conns, mute, idx, item;
10583
10584 conns = snd_hda_get_connections(codec, nid, conn_list,
10585 ARRAY_SIZE(conn_list));
10586 if (conns < 0)
10587 continue;
10588 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10589 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010590 if (!imux->num_items && mux_idx > 0)
10591 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010592 for (idx = 0; idx < conns; idx++) {
10593 /* if the current connection is the selected one,
10594 * unmute it as default - otherwise mute it
10595 */
10596 mute = AMP_IN_MUTE(idx);
10597 for (item = 0; item < imux->num_items; item++) {
10598 if (imux->items[item].index == idx) {
10599 if (spec->cur_mux[c] == item)
10600 mute = AMP_IN_UNMUTE(idx);
10601 break;
10602 }
10603 }
10604 /* check if we have a selector or mixer
10605 * we could check for the widget type instead, but
10606 * just check for Amp-In presence (in case of mixer
10607 * without amp-in there is something wrong, this
10608 * function shouldn't be used or capsrc nid is wrong)
10609 */
10610 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010611 snd_hda_codec_write(codec, nid, 0,
10612 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010613 mute);
10614 else if (mute != AMP_IN_MUTE(idx))
10615 snd_hda_codec_write(codec, nid, 0,
10616 AC_VERB_SET_CONNECT_SEL,
10617 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010618 }
10619 }
10620}
10621
Takashi Iwai4953550a2009-06-30 15:28:30 +020010622/* add mic boosts if needed */
10623static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010624{
10625 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010626 int err;
10627 hda_nid_t nid;
10628
10629 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10630 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10631 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10632 "Mic Boost",
10633 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10634 if (err < 0)
10635 return err;
10636 }
10637 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10638 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10639 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10640 "Front Mic Boost",
10641 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10642 if (err < 0)
10643 return err;
10644 }
10645 return 0;
10646}
10647
10648/* almost identical with ALC880 parser... */
10649static int alc882_parse_auto_config(struct hda_codec *codec)
10650{
10651 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010652 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010653 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010654
Takashi Iwai05f5f472009-08-25 13:10:18 +020010655 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10656 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010657 if (err < 0)
10658 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010659 if (!spec->autocfg.line_outs)
10660 return 0; /* can't find valid BIOS pin config */
10661
10662 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10663 if (err < 0)
10664 return err;
10665 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10666 if (err < 0)
10667 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010668 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10669 "Headphone");
10670 if (err < 0)
10671 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010672 err = alc880_auto_create_extra_out(spec,
10673 spec->autocfg.speaker_pins[0],
10674 "Speaker");
10675 if (err < 0)
10676 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010677 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10678 if (err < 0)
10679 return err;
10680
10681 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10682
Takashi Iwai757899a2010-07-30 10:48:14 +020010683 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010684
10685 if (spec->kctls.list)
10686 add_mixer(spec, spec->kctls.list);
10687
10688 add_verb(spec, alc883_auto_init_verbs);
10689 /* if ADC 0x07 is available, initialize it, too */
10690 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10691 add_verb(spec, alc882_adc1_init_verbs);
10692
10693 spec->num_mux_defs = 1;
10694 spec->input_mux = &spec->private_imux[0];
10695
Kailang Yang6227cdc2010-02-25 08:36:52 +010010696 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010697
10698 err = alc_auto_add_mic_boost(codec);
10699 if (err < 0)
10700 return err;
10701
Takashi Iwai776e1842007-08-29 15:07:11 +020010702 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010703}
10704
10705/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010706static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010707{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010708 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010709 alc882_auto_init_multi_out(codec);
10710 alc882_auto_init_hp_out(codec);
10711 alc882_auto_init_analog_input(codec);
10712 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010713 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010714 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010715 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010716}
10717
Takashi Iwai4953550a2009-06-30 15:28:30 +020010718static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010719{
10720 struct alc_spec *spec;
10721 int err, board_config;
10722
10723 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10724 if (spec == NULL)
10725 return -ENOMEM;
10726
10727 codec->spec = spec;
10728
Kailang Yangda00c242010-03-19 11:23:45 +010010729 alc_auto_parse_customize_define(codec);
10730
Takashi Iwai4953550a2009-06-30 15:28:30 +020010731 switch (codec->vendor_id) {
10732 case 0x10ec0882:
10733 case 0x10ec0885:
10734 break;
10735 default:
10736 /* ALC883 and variants */
10737 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10738 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010739 }
10740
Takashi Iwai4953550a2009-06-30 15:28:30 +020010741 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10742 alc882_models,
10743 alc882_cfg_tbl);
10744
10745 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10746 board_config = snd_hda_check_board_codec_sid_config(codec,
10747 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10748
10749 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010750 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010751 codec->chip_name);
10752 board_config = ALC882_AUTO;
10753 }
10754
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010755 if (board_config == ALC882_AUTO)
10756 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010757
10758 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010759 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010760 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010761 if (err < 0) {
10762 alc_free(codec);
10763 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010764 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010765 printk(KERN_INFO
10766 "hda_codec: Cannot set up configuration "
10767 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010768 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010769 }
10770 }
10771
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010772 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010773 err = snd_hda_attach_beep_device(codec, 0x1);
10774 if (err < 0) {
10775 alc_free(codec);
10776 return err;
10777 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010778 }
10779
Takashi Iwai4953550a2009-06-30 15:28:30 +020010780 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010781 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010782
Takashi Iwai4953550a2009-06-30 15:28:30 +020010783 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10784 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10785 /* FIXME: setup DAC5 */
10786 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10787 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10788
10789 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10790 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10791
Takashi Iwai4953550a2009-06-30 15:28:30 +020010792 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010793 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010794 spec->num_adc_nids = 0;
10795 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010796 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010797 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010798 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010799 hda_nid_t nid = alc882_adc_nids[i];
10800 unsigned int wcap = get_wcaps(codec, nid);
10801 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010802 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010803 if (wcap != AC_WID_AUD_IN)
10804 continue;
10805 spec->private_adc_nids[spec->num_adc_nids] = nid;
10806 err = snd_hda_get_connections(codec, nid, &cap, 1);
10807 if (err < 0)
10808 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010809 err = snd_hda_get_connections(codec, cap, items,
10810 ARRAY_SIZE(items));
10811 if (err < 0)
10812 continue;
10813 for (j = 0; j < imux->num_items; j++)
10814 if (imux->items[j].index >= err)
10815 break;
10816 if (j < imux->num_items)
10817 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010818 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10819 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010820 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010821 spec->adc_nids = spec->private_adc_nids;
10822 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010823 }
10824
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010825 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010826
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010827 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010828 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010829
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010830 if (board_config == ALC882_AUTO)
10831 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10832
Takashi Iwai2134ea42008-01-10 16:53:55 +010010833 spec->vmaster_nid = 0x0c;
10834
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010835 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010836 if (board_config == ALC882_AUTO)
10837 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010838#ifdef CONFIG_SND_HDA_POWER_SAVE
10839 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010840 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010841#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010842
10843 return 0;
10844}
10845
Takashi Iwai4953550a2009-06-30 15:28:30 +020010846
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010847/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010848 * ALC262 support
10849 */
10850
10851#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10852#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10853
10854#define alc262_dac_nids alc260_dac_nids
10855#define alc262_adc_nids alc882_adc_nids
10856#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010857#define alc262_capsrc_nids alc882_capsrc_nids
10858#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010859
10860#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010861#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010862
Kailang Yang4e555fe2008-08-26 13:05:55 +020010863static hda_nid_t alc262_dmic_adc_nids[1] = {
10864 /* ADC0 */
10865 0x09
10866};
10867
10868static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10869
Kailang Yangdf694da2005-12-05 19:42:22 +010010870static struct snd_kcontrol_new alc262_base_mixer[] = {
10871 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10872 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10873 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10874 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10875 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10876 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010880 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10881 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010882 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010883 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10885 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10886 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010887 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010888};
10889
Takashi Iwaice875f02008-01-28 18:17:43 +010010890/* update HP, line and mono-out pins according to the master switch */
10891static void alc262_hp_master_update(struct hda_codec *codec)
10892{
10893 struct alc_spec *spec = codec->spec;
10894 int val = spec->master_sw;
10895
10896 /* HP & line-out */
10897 snd_hda_codec_write_cache(codec, 0x1b, 0,
10898 AC_VERB_SET_PIN_WIDGET_CONTROL,
10899 val ? PIN_HP : 0);
10900 snd_hda_codec_write_cache(codec, 0x15, 0,
10901 AC_VERB_SET_PIN_WIDGET_CONTROL,
10902 val ? PIN_HP : 0);
10903 /* mono (speaker) depending on the HP jack sense */
10904 val = val && !spec->jack_present;
10905 snd_hda_codec_write_cache(codec, 0x16, 0,
10906 AC_VERB_SET_PIN_WIDGET_CONTROL,
10907 val ? PIN_OUT : 0);
10908}
10909
10910static void alc262_hp_bpc_automute(struct hda_codec *codec)
10911{
10912 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010913
10914 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010915 alc262_hp_master_update(codec);
10916}
10917
10918static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10919{
10920 if ((res >> 26) != ALC880_HP_EVENT)
10921 return;
10922 alc262_hp_bpc_automute(codec);
10923}
10924
10925static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10926{
10927 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010928
10929 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010930 alc262_hp_master_update(codec);
10931}
10932
10933static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10934 unsigned int res)
10935{
10936 if ((res >> 26) != ALC880_HP_EVENT)
10937 return;
10938 alc262_hp_wildwest_automute(codec);
10939}
10940
Takashi Iwaib72519b2009-05-08 14:31:55 +020010941#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010942
10943static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10944 struct snd_ctl_elem_value *ucontrol)
10945{
10946 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10947 struct alc_spec *spec = codec->spec;
10948 int val = !!*ucontrol->value.integer.value;
10949
10950 if (val == spec->master_sw)
10951 return 0;
10952 spec->master_sw = val;
10953 alc262_hp_master_update(codec);
10954 return 1;
10955}
10956
Takashi Iwaib72519b2009-05-08 14:31:55 +020010957#define ALC262_HP_MASTER_SWITCH \
10958 { \
10959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10960 .name = "Master Playback Switch", \
10961 .info = snd_ctl_boolean_mono_info, \
10962 .get = alc262_hp_master_sw_get, \
10963 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010964 }, \
10965 { \
10966 .iface = NID_MAPPING, \
10967 .name = "Master Playback Switch", \
10968 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010969 }
10970
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010971
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010972static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010973 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010974 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10975 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010977 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10978 HDA_OUTPUT),
10979 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10980 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10982 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010983 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010984 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10985 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010986 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010987 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10988 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10989 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10990 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010991 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10992 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10993 { } /* end */
10994};
10995
Kailang Yangcd7509a2007-01-26 18:33:17 +010010996static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010997 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010998 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10999 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11000 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011002 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11003 HDA_OUTPUT),
11004 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11005 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011006 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011008 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011009 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11010 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11011 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11012 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011013 { } /* end */
11014};
11015
11016static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11017 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11018 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011019 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011020 { } /* end */
11021};
11022
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011023/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011024static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011025{
11026 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011027
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011028 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011029 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011030}
11031
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011032static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011033 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11034 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011035 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11036 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11038 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11039 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11040 { } /* end */
11041};
11042
11043static struct hda_verb alc262_hp_t5735_verbs[] = {
11044 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11045 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11046
11047 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11048 { }
11049};
11050
Kailang Yang8c427222008-01-10 13:03:59 +010011051static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011052 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11053 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011054 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11055 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011056 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11057 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11058 { } /* end */
11059};
11060
11061static struct hda_verb alc262_hp_rp5700_verbs[] = {
11062 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11063 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11065 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11066 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11067 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11069 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11071 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11072 {}
11073};
11074
11075static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11076 .num_items = 1,
11077 .items = {
11078 { "Line", 0x1 },
11079 },
11080};
11081
Takashi Iwai42171c12009-05-08 14:11:43 +020011082/* bind hp and internal speaker mute (with plug check) as master switch */
11083static void alc262_hippo_master_update(struct hda_codec *codec)
11084{
11085 struct alc_spec *spec = codec->spec;
11086 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11087 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11088 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11089 unsigned int mute;
11090
11091 /* HP */
11092 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11093 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11094 HDA_AMP_MUTE, mute);
11095 /* mute internal speaker per jack sense */
11096 if (spec->jack_present)
11097 mute = HDA_AMP_MUTE;
11098 if (line_nid)
11099 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11100 HDA_AMP_MUTE, mute);
11101 if (speaker_nid && speaker_nid != line_nid)
11102 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11103 HDA_AMP_MUTE, mute);
11104}
11105
11106#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11107
11108static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11109 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011110{
11111 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011112 struct alc_spec *spec = codec->spec;
11113 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011114
Takashi Iwai42171c12009-05-08 14:11:43 +020011115 if (val == spec->master_sw)
11116 return 0;
11117 spec->master_sw = val;
11118 alc262_hippo_master_update(codec);
11119 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011120}
Takashi Iwai5b319542007-07-26 11:49:22 +020011121
Takashi Iwai42171c12009-05-08 14:11:43 +020011122#define ALC262_HIPPO_MASTER_SWITCH \
11123 { \
11124 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11125 .name = "Master Playback Switch", \
11126 .info = snd_ctl_boolean_mono_info, \
11127 .get = alc262_hippo_master_sw_get, \
11128 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011129 }, \
11130 { \
11131 .iface = NID_MAPPING, \
11132 .name = "Master Playback Switch", \
11133 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11134 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011135 }
11136
11137static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11138 ALC262_HIPPO_MASTER_SWITCH,
11139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11140 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11141 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11146 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11147 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11148 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11149 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11150 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11151 { } /* end */
11152};
11153
11154static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11155 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11156 ALC262_HIPPO_MASTER_SWITCH,
11157 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11158 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11159 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11160 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11162 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11164 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11165 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11166 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11167 { } /* end */
11168};
11169
11170/* mute/unmute internal speaker according to the hp jack and mute state */
11171static void alc262_hippo_automute(struct hda_codec *codec)
11172{
11173 struct alc_spec *spec = codec->spec;
11174 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011175
Wu Fengguang864f92b2009-11-18 12:38:02 +080011176 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011177 alc262_hippo_master_update(codec);
11178}
11179
11180static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11181{
11182 if ((res >> 26) != ALC880_HP_EVENT)
11183 return;
11184 alc262_hippo_automute(codec);
11185}
11186
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011187static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011188{
11189 struct alc_spec *spec = codec->spec;
11190
11191 spec->autocfg.hp_pins[0] = 0x15;
11192 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011193}
11194
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011195static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011196{
11197 struct alc_spec *spec = codec->spec;
11198
11199 spec->autocfg.hp_pins[0] = 0x1b;
11200 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011201}
11202
11203
Kailang Yang272a5272007-05-14 11:00:38 +020011204static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011205 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011206 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11208 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11209 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11210 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11211 { } /* end */
11212};
11213
Kailang Yang83c34212007-07-05 11:43:05 +020011214static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011215 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11216 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11220 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11221 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11222 { } /* end */
11223};
Kailang Yang272a5272007-05-14 11:00:38 +020011224
Tony Vroonba340e82009-02-02 19:01:30 +000011225static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11226 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11227 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11228 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11229 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11230 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11231 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11233 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11234 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11235 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11236 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11237 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11238 { } /* end */
11239};
11240
11241static struct hda_verb alc262_tyan_verbs[] = {
11242 /* Headphone automute */
11243 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11244 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11245 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11246
11247 /* P11 AUX_IN, white 4-pin connector */
11248 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11249 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11250 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11251 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11252
11253 {}
11254};
11255
11256/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011257static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011258{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011259 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011260
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011261 spec->autocfg.hp_pins[0] = 0x1b;
11262 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011263}
11264
Tony Vroonba340e82009-02-02 19:01:30 +000011265
Kailang Yangdf694da2005-12-05 19:42:22 +010011266#define alc262_capture_mixer alc882_capture_mixer
11267#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11268
11269/*
11270 * generic initialization of ADC, input mixers and output mixers
11271 */
11272static struct hda_verb alc262_init_verbs[] = {
11273 /*
11274 * Unmute ADC0-2 and set the default input to mic-in
11275 */
11276 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11278 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11279 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11280 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11281 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11282
Takashi Iwaicb53c622007-08-10 17:21:45 +020011283 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011284 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011285 * Note: PASD motherboards uses the Line In 2 as the input for
11286 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011287 */
11288 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011289 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11290 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11291 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11292 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11293 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011294
11295 /*
11296 * Set up output mixers (0x0c - 0x0e)
11297 */
11298 /* set vol=0 to output mixers */
11299 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11300 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11301 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11302 /* set up input amps for analog loopback */
11303 /* Amp Indices: DAC = 0, mixer = 1 */
11304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11305 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11306 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11307 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11308 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11309 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11310
11311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11312 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11313 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11314 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11315 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11316 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11317
11318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11319 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11320 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11321 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11322 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011323
Kailang Yangdf694da2005-12-05 19:42:22 +010011324 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11325 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011326
Kailang Yangdf694da2005-12-05 19:42:22 +010011327 /* FIXME: use matrix-type input source selection */
11328 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11329 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11330 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11331 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11332 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11333 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11334 /* Input mixer2 */
11335 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11336 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11337 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11338 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11339 /* Input mixer3 */
11340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011344
11345 { }
11346};
11347
Kailang Yang4e555fe2008-08-26 13:05:55 +020011348static struct hda_verb alc262_eapd_verbs[] = {
11349 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11350 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11351 { }
11352};
11353
Kailang Yangccc656c2006-10-17 12:32:26 +020011354static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11355 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11356 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11357 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11358
11359 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11360 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11361 {}
11362};
11363
Kailang Yang272a5272007-05-14 11:00:38 +020011364static struct hda_verb alc262_sony_unsol_verbs[] = {
11365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11366 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11367 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11368
11369 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11370 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011371 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011372};
11373
Kailang Yang4e555fe2008-08-26 13:05:55 +020011374static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11375 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11376 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11378 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11379 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011380 { } /* end */
11381};
11382
11383static struct hda_verb alc262_toshiba_s06_verbs[] = {
11384 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11385 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11387 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11388 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11389 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11390 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11391 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11392 {}
11393};
11394
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011395static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011396{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011397 struct alc_spec *spec = codec->spec;
11398
11399 spec->autocfg.hp_pins[0] = 0x15;
11400 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011401 spec->ext_mic.pin = 0x18;
11402 spec->ext_mic.mux_idx = 0;
11403 spec->int_mic.pin = 0x12;
11404 spec->int_mic.mux_idx = 9;
11405 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011406}
11407
Takashi Iwai834be882006-03-01 14:16:17 +010011408/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011409 * nec model
11410 * 0x15 = headphone
11411 * 0x16 = internal speaker
11412 * 0x18 = external mic
11413 */
11414
11415static struct snd_kcontrol_new alc262_nec_mixer[] = {
11416 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11417 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11418
11419 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11420 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11422
11423 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11424 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11425 { } /* end */
11426};
11427
11428static struct hda_verb alc262_nec_verbs[] = {
11429 /* Unmute Speaker */
11430 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11431
11432 /* Headphone */
11433 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11434 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11435
11436 /* External mic to headphone */
11437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11438 /* External mic to speaker */
11439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11440 {}
11441};
11442
11443/*
Takashi Iwai834be882006-03-01 14:16:17 +010011444 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011445 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11446 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011447 */
11448
11449#define ALC_HP_EVENT 0x37
11450
11451static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11452 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11453 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011454 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11455 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011456 {}
11457};
11458
Jiang zhe0e31daf2008-03-20 12:12:39 +010011459static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11460 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11461 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11462 {}
11463};
11464
Daniel T Chene2595322009-12-19 18:19:02 -050011465static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11466 /* Front Mic pin: input vref at 50% */
11467 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11468 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11469 {}
11470};
11471
Takashi Iwai834be882006-03-01 14:16:17 +010011472static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011473 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011474 .items = {
11475 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011476 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011477 { "CD", 0x4 },
11478 },
11479};
11480
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011481static struct hda_input_mux alc262_HP_capture_source = {
11482 .num_items = 5,
11483 .items = {
11484 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011485 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011486 { "Line", 0x2 },
11487 { "CD", 0x4 },
11488 { "AUX IN", 0x6 },
11489 },
11490};
11491
zhejiangaccbe492007-08-31 12:36:05 +020011492static struct hda_input_mux alc262_HP_D7000_capture_source = {
11493 .num_items = 4,
11494 .items = {
11495 { "Mic", 0x0 },
11496 { "Front Mic", 0x2 },
11497 { "Line", 0x1 },
11498 { "CD", 0x4 },
11499 },
11500};
11501
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011502/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011503static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11504{
11505 struct alc_spec *spec = codec->spec;
11506 unsigned int mute;
11507
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011508 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011509 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11510 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011511 spec->sense_updated = 1;
11512 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011513 /* unmute internal speaker only if both HPs are unplugged and
11514 * master switch is on
11515 */
11516 if (spec->jack_present)
11517 mute = HDA_AMP_MUTE;
11518 else
Takashi Iwai834be882006-03-01 14:16:17 +010011519 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011520 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11521 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011522}
11523
11524/* unsolicited event for HP jack sensing */
11525static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11526 unsigned int res)
11527{
11528 if ((res >> 26) != ALC_HP_EVENT)
11529 return;
11530 alc262_fujitsu_automute(codec, 1);
11531}
11532
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011533static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11534{
11535 alc262_fujitsu_automute(codec, 1);
11536}
11537
Takashi Iwai834be882006-03-01 14:16:17 +010011538/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011539static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11540 .ops = &snd_hda_bind_vol,
11541 .values = {
11542 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11543 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11544 0
11545 },
11546};
Takashi Iwai834be882006-03-01 14:16:17 +010011547
Jiang zhe0e31daf2008-03-20 12:12:39 +010011548/* mute/unmute internal speaker according to the hp jack and mute state */
11549static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11550{
11551 struct alc_spec *spec = codec->spec;
11552 unsigned int mute;
11553
11554 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011555 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011556 spec->sense_updated = 1;
11557 }
11558 if (spec->jack_present) {
11559 /* mute internal speaker */
11560 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11561 HDA_AMP_MUTE, HDA_AMP_MUTE);
11562 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11563 HDA_AMP_MUTE, HDA_AMP_MUTE);
11564 } else {
11565 /* unmute internal speaker if necessary */
11566 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11567 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11568 HDA_AMP_MUTE, mute);
11569 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11570 HDA_AMP_MUTE, mute);
11571 }
11572}
11573
11574/* unsolicited event for HP jack sensing */
11575static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11576 unsigned int res)
11577{
11578 if ((res >> 26) != ALC_HP_EVENT)
11579 return;
11580 alc262_lenovo_3000_automute(codec, 1);
11581}
11582
Takashi Iwai8de56b72009-07-24 16:51:47 +020011583static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11584 int dir, int idx, long *valp)
11585{
11586 int i, change = 0;
11587
11588 for (i = 0; i < 2; i++, valp++)
11589 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11590 HDA_AMP_MUTE,
11591 *valp ? 0 : HDA_AMP_MUTE);
11592 return change;
11593}
11594
Takashi Iwai834be882006-03-01 14:16:17 +010011595/* bind hp and internal speaker mute (with plug check) */
11596static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11597 struct snd_ctl_elem_value *ucontrol)
11598{
11599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11600 long *valp = ucontrol->value.integer.value;
11601 int change;
11602
Takashi Iwai8de56b72009-07-24 16:51:47 +020011603 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11604 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011605 if (change)
11606 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011607 return change;
11608}
11609
11610static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011611 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011612 {
11613 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11614 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011615 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011616 .info = snd_hda_mixer_amp_switch_info,
11617 .get = snd_hda_mixer_amp_switch_get,
11618 .put = alc262_fujitsu_master_sw_put,
11619 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11620 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011621 {
11622 .iface = NID_MAPPING,
11623 .name = "Master Playback Switch",
11624 .private_value = 0x1b,
11625 },
Takashi Iwai834be882006-03-01 14:16:17 +010011626 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11627 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11628 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11629 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11630 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011631 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11632 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11633 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011634 { } /* end */
11635};
11636
Jiang zhe0e31daf2008-03-20 12:12:39 +010011637/* bind hp and internal speaker mute (with plug check) */
11638static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11639 struct snd_ctl_elem_value *ucontrol)
11640{
11641 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11642 long *valp = ucontrol->value.integer.value;
11643 int change;
11644
Takashi Iwai8de56b72009-07-24 16:51:47 +020011645 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011646 if (change)
11647 alc262_lenovo_3000_automute(codec, 0);
11648 return change;
11649}
11650
11651static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11652 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11653 {
11654 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11655 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011656 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011657 .info = snd_hda_mixer_amp_switch_info,
11658 .get = snd_hda_mixer_amp_switch_get,
11659 .put = alc262_lenovo_3000_master_sw_put,
11660 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11661 },
11662 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11663 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11664 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11665 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11666 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11667 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11668 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11669 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11670 { } /* end */
11671};
11672
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011673static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11674 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011675 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011676 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11677 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11678 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11679 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11680 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11681 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11682 { } /* end */
11683};
11684
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011685/* additional init verbs for Benq laptops */
11686static struct hda_verb alc262_EAPD_verbs[] = {
11687 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11688 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11689 {}
11690};
11691
Kailang Yang83c34212007-07-05 11:43:05 +020011692static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11693 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11694 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11695
11696 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11697 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11698 {}
11699};
11700
Tobin Davisf651b502007-10-26 12:40:47 +020011701/* Samsung Q1 Ultra Vista model setup */
11702static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011703 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11704 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11707 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011708 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011709 { } /* end */
11710};
11711
11712static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011713 /* output mixer */
11714 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11715 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11716 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11717 /* speaker */
11718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11719 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11720 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11721 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11722 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011723 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11726 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11727 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11728 /* internal mic */
11729 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11731 /* ADC, choose mic */
11732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11733 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11734 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11735 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11736 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11737 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11738 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11739 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11740 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11741 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011742 {}
11743};
11744
Tobin Davisf651b502007-10-26 12:40:47 +020011745/* mute/unmute internal speaker according to the hp jack and mute state */
11746static void alc262_ultra_automute(struct hda_codec *codec)
11747{
11748 struct alc_spec *spec = codec->spec;
11749 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011750
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011751 mute = 0;
11752 /* auto-mute only when HP is used as HP */
11753 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011754 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011755 if (spec->jack_present)
11756 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011757 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011758 /* mute/unmute internal speaker */
11759 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11760 HDA_AMP_MUTE, mute);
11761 /* mute/unmute HP */
11762 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11763 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011764}
11765
11766/* unsolicited event for HP jack sensing */
11767static void alc262_ultra_unsol_event(struct hda_codec *codec,
11768 unsigned int res)
11769{
11770 if ((res >> 26) != ALC880_HP_EVENT)
11771 return;
11772 alc262_ultra_automute(codec);
11773}
11774
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011775static struct hda_input_mux alc262_ultra_capture_source = {
11776 .num_items = 2,
11777 .items = {
11778 { "Mic", 0x1 },
11779 { "Headphone", 0x7 },
11780 },
11781};
11782
11783static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11784 struct snd_ctl_elem_value *ucontrol)
11785{
11786 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11787 struct alc_spec *spec = codec->spec;
11788 int ret;
11789
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011790 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011791 if (!ret)
11792 return 0;
11793 /* reprogram the HP pin as mic or HP according to the input source */
11794 snd_hda_codec_write_cache(codec, 0x15, 0,
11795 AC_VERB_SET_PIN_WIDGET_CONTROL,
11796 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11797 alc262_ultra_automute(codec); /* mute/unmute HP */
11798 return ret;
11799}
11800
11801static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11802 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11803 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11804 {
11805 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11806 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011807 .info = alc_mux_enum_info,
11808 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011809 .put = alc262_ultra_mux_enum_put,
11810 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011811 {
11812 .iface = NID_MAPPING,
11813 .name = "Capture Source",
11814 .private_value = 0x15,
11815 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011816 { } /* end */
11817};
11818
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011819/* We use two mixers depending on the output pin; 0x16 is a mono output
11820 * and thus it's bound with a different mixer.
11821 * This function returns which mixer amp should be used.
11822 */
11823static int alc262_check_volbit(hda_nid_t nid)
11824{
11825 if (!nid)
11826 return 0;
11827 else if (nid == 0x16)
11828 return 2;
11829 else
11830 return 1;
11831}
11832
11833static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11834 const char *pfx, int *vbits)
11835{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011836 unsigned long val;
11837 int vbit;
11838
11839 vbit = alc262_check_volbit(nid);
11840 if (!vbit)
11841 return 0;
11842 if (*vbits & vbit) /* a volume control for this mixer already there */
11843 return 0;
11844 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011845 if (vbit == 2)
11846 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11847 else
11848 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011849 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011850}
11851
11852static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11853 const char *pfx)
11854{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011855 unsigned long val;
11856
11857 if (!nid)
11858 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011859 if (nid == 0x16)
11860 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11861 else
11862 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011863 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011864}
11865
Kailang Yangdf694da2005-12-05 19:42:22 +010011866/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011867static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11868 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011869{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011870 const char *pfx;
11871 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011872 int err;
11873
11874 spec->multiout.num_dacs = 1; /* only use one dac */
11875 spec->multiout.dac_nids = spec->private_dac_nids;
11876 spec->multiout.dac_nids[0] = 2;
11877
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011878 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11879 pfx = "Master";
11880 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11881 pfx = "Speaker";
11882 else
11883 pfx = "Front";
11884 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11885 if (err < 0)
11886 return err;
11887 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11888 if (err < 0)
11889 return err;
11890 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11891 if (err < 0)
11892 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011893
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011894 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11895 alc262_check_volbit(cfg->speaker_pins[0]) |
11896 alc262_check_volbit(cfg->hp_pins[0]);
11897 if (vbits == 1 || vbits == 2)
11898 pfx = "Master"; /* only one mixer is used */
11899 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11900 pfx = "Speaker";
11901 else
11902 pfx = "Front";
11903 vbits = 0;
11904 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11905 if (err < 0)
11906 return err;
11907 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11908 &vbits);
11909 if (err < 0)
11910 return err;
11911 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11912 &vbits);
11913 if (err < 0)
11914 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011915 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011916}
11917
Takashi Iwai05f5f472009-08-25 13:10:18 +020011918#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011919 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011920
11921/*
11922 * generic initialization of ADC, input mixers and output mixers
11923 */
11924static struct hda_verb alc262_volume_init_verbs[] = {
11925 /*
11926 * Unmute ADC0-2 and set the default input to mic-in
11927 */
11928 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11930 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11931 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11932 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11933 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11934
Takashi Iwaicb53c622007-08-10 17:21:45 +020011935 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011936 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011937 * Note: PASD motherboards uses the Line In 2 as the input for
11938 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011939 */
11940 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011946
11947 /*
11948 * Set up output mixers (0x0c - 0x0f)
11949 */
11950 /* set vol=0 to output mixers */
11951 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11952 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11953 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011954
Kailang Yangdf694da2005-12-05 19:42:22 +010011955 /* set up input amps for analog loopback */
11956 /* Amp Indices: DAC = 0, mixer = 1 */
11957 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11959 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11961 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11963
11964 /* FIXME: use matrix-type input source selection */
11965 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11966 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11967 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11968 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11969 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11970 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11971 /* Input mixer2 */
11972 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11973 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11974 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11976 /* Input mixer3 */
11977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11979 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11980 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11981
11982 { }
11983};
11984
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011985static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11986 /*
11987 * Unmute ADC0-2 and set the default input to mic-in
11988 */
11989 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11990 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11991 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11992 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11993 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11994 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11995
Takashi Iwaicb53c622007-08-10 17:21:45 +020011996 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011997 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011998 * Note: PASD motherboards uses the Line In 2 as the input for
11999 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012000 */
12001 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012009
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012010 /*
12011 * Set up output mixers (0x0c - 0x0e)
12012 */
12013 /* set vol=0 to output mixers */
12014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12015 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12016 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12017
12018 /* set up input amps for analog loopback */
12019 /* Amp Indices: DAC = 0, mixer = 1 */
12020 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12022 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12023 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12024 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12025 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12026
Takashi Iwaice875f02008-01-28 18:17:43 +010012027 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12029 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12030
12031 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12032 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12033
12034 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12035 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12036
12037 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12038 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12039 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12040 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12041 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12042
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012044 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12045 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012046 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012047 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12048 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12049
12050
12051 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012052 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12053 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012054 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012055 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12056 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12057 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12059 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12060 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12061 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12062 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012063 /* Input mixer2 */
12064 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012065 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12066 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12067 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12068 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012073 /* Input mixer3 */
12074 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012075 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12076 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12077 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12078 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12080 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12081 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12082 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012083
Takashi Iwaice875f02008-01-28 18:17:43 +010012084 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12085
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012086 { }
12087};
12088
Kailang Yangcd7509a2007-01-26 18:33:17 +010012089static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12090 /*
12091 * Unmute ADC0-2 and set the default input to mic-in
12092 */
12093 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12094 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12095 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12096 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12097 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12098 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12099
Takashi Iwaicb53c622007-08-10 17:21:45 +020012100 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012101 * mixer widget
12102 * Note: PASD motherboards uses the Line In 2 as the input for front
12103 * panel mic (mic 2)
12104 */
12105 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012106 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12107 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012114 /*
12115 * Set up output mixers (0x0c - 0x0e)
12116 */
12117 /* set vol=0 to output mixers */
12118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12121
12122 /* set up input amps for analog loopback */
12123 /* Amp Indices: DAC = 0, mixer = 1 */
12124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12127 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12130
12131
12132 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12134 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12135 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12138 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12139
12140 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12141 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12142
12143 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12144 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12145
12146 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12147 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12148 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12149 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12150 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12151 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12152
12153 /* FIXME: use matrix-type input source selection */
12154 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12155 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12156 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12157 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12158 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12159 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12160 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12161 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12162 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12163 /* Input mixer2 */
12164 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12166 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12168 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12169 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12171 /* Input mixer3 */
12172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12174 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12175 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12176 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12177 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12178 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12179
Takashi Iwaice875f02008-01-28 18:17:43 +010012180 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12181
Kailang Yangcd7509a2007-01-26 18:33:17 +010012182 { }
12183};
12184
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012185static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12186
12187 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12188 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12189 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12190
12191 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12194 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12195
12196 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12197 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12199 {}
12200};
12201
12202
Takashi Iwaicb53c622007-08-10 17:21:45 +020012203#ifdef CONFIG_SND_HDA_POWER_SAVE
12204#define alc262_loopbacks alc880_loopbacks
12205#endif
12206
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012207/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012208#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12209#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12210#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12211#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12212
12213/*
12214 * BIOS auto configuration
12215 */
12216static int alc262_parse_auto_config(struct hda_codec *codec)
12217{
12218 struct alc_spec *spec = codec->spec;
12219 int err;
12220 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12221
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012222 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12223 alc262_ignore);
12224 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012225 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012226 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012227 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012228 spec->multiout.max_channels = 2;
12229 spec->no_analog = 1;
12230 goto dig_only;
12231 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012232 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012233 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012234 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12235 if (err < 0)
12236 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012237 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012238 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012239 return err;
12240
12241 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12242
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012243 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012244 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012245
Takashi Iwai603c4012008-07-30 15:01:44 +020012246 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012247 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012248
Takashi Iwaid88897e2008-10-31 15:01:37 +010012249 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012250 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012251 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012252
Takashi Iwai776e1842007-08-29 15:07:11 +020012253 err = alc_auto_add_mic_boost(codec);
12254 if (err < 0)
12255 return err;
12256
Kailang Yang6227cdc2010-02-25 08:36:52 +010012257 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012258
Kailang Yangdf694da2005-12-05 19:42:22 +010012259 return 1;
12260}
12261
12262#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12263#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12264#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012265#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012266
12267
12268/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012269static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012270{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012271 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012272 alc262_auto_init_multi_out(codec);
12273 alc262_auto_init_hp_out(codec);
12274 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012275 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012276 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012277 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012278 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012279}
12280
12281/*
12282 * configuration and preset
12283 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012284static const char *alc262_models[ALC262_MODEL_LAST] = {
12285 [ALC262_BASIC] = "basic",
12286 [ALC262_HIPPO] = "hippo",
12287 [ALC262_HIPPO_1] = "hippo_1",
12288 [ALC262_FUJITSU] = "fujitsu",
12289 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012290 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012291 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012292 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012293 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012294 [ALC262_BENQ_T31] = "benq-t31",
12295 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012296 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012297 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012298 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012299 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012300 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012301 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012302 [ALC262_AUTO] = "auto",
12303};
12304
12305static struct snd_pci_quirk alc262_cfg_tbl[] = {
12306 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012307 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012308 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12309 ALC262_HP_BPC),
12310 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12311 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012312 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12313 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012314 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012315 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012316 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012317 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012318 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012319 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012320 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012321 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012322 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12323 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12324 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012325 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12326 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012327 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012328 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012329 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012330 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012331 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012332 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012333 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012334 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012335#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012336 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12337 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012338#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012339 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012340 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012341 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012342 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012343 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012344 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012345 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12346 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012347 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012348 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012349 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012350 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012351 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012352 {}
12353};
12354
12355static struct alc_config_preset alc262_presets[] = {
12356 [ALC262_BASIC] = {
12357 .mixers = { alc262_base_mixer },
12358 .init_verbs = { alc262_init_verbs },
12359 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12360 .dac_nids = alc262_dac_nids,
12361 .hp_nid = 0x03,
12362 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12363 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012364 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012365 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012366 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012367 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012368 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012369 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12370 .dac_nids = alc262_dac_nids,
12371 .hp_nid = 0x03,
12372 .dig_out_nid = ALC262_DIGOUT_NID,
12373 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12374 .channel_mode = alc262_modes,
12375 .input_mux = &alc262_capture_source,
12376 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012377 .setup = alc262_hippo_setup,
12378 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012379 },
12380 [ALC262_HIPPO_1] = {
12381 .mixers = { alc262_hippo1_mixer },
12382 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12383 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12384 .dac_nids = alc262_dac_nids,
12385 .hp_nid = 0x02,
12386 .dig_out_nid = ALC262_DIGOUT_NID,
12387 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12388 .channel_mode = alc262_modes,
12389 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012390 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012391 .setup = alc262_hippo1_setup,
12392 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012393 },
Takashi Iwai834be882006-03-01 14:16:17 +010012394 [ALC262_FUJITSU] = {
12395 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012396 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12397 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012398 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12399 .dac_nids = alc262_dac_nids,
12400 .hp_nid = 0x03,
12401 .dig_out_nid = ALC262_DIGOUT_NID,
12402 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12403 .channel_mode = alc262_modes,
12404 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012405 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012406 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012407 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012408 [ALC262_HP_BPC] = {
12409 .mixers = { alc262_HP_BPC_mixer },
12410 .init_verbs = { alc262_HP_BPC_init_verbs },
12411 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12412 .dac_nids = alc262_dac_nids,
12413 .hp_nid = 0x03,
12414 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12415 .channel_mode = alc262_modes,
12416 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012417 .unsol_event = alc262_hp_bpc_unsol_event,
12418 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012419 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012420 [ALC262_HP_BPC_D7000_WF] = {
12421 .mixers = { alc262_HP_BPC_WildWest_mixer },
12422 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12423 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12424 .dac_nids = alc262_dac_nids,
12425 .hp_nid = 0x03,
12426 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12427 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012428 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012429 .unsol_event = alc262_hp_wildwest_unsol_event,
12430 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012431 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012432 [ALC262_HP_BPC_D7000_WL] = {
12433 .mixers = { alc262_HP_BPC_WildWest_mixer,
12434 alc262_HP_BPC_WildWest_option_mixer },
12435 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12436 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12437 .dac_nids = alc262_dac_nids,
12438 .hp_nid = 0x03,
12439 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12440 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012441 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012442 .unsol_event = alc262_hp_wildwest_unsol_event,
12443 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012444 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012445 [ALC262_HP_TC_T5735] = {
12446 .mixers = { alc262_hp_t5735_mixer },
12447 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12448 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12449 .dac_nids = alc262_dac_nids,
12450 .hp_nid = 0x03,
12451 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12452 .channel_mode = alc262_modes,
12453 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012454 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012455 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012456 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012457 },
12458 [ALC262_HP_RP5700] = {
12459 .mixers = { alc262_hp_rp5700_mixer },
12460 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12461 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12462 .dac_nids = alc262_dac_nids,
12463 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12464 .channel_mode = alc262_modes,
12465 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012466 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012467 [ALC262_BENQ_ED8] = {
12468 .mixers = { alc262_base_mixer },
12469 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12470 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12471 .dac_nids = alc262_dac_nids,
12472 .hp_nid = 0x03,
12473 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12474 .channel_mode = alc262_modes,
12475 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012476 },
Kailang Yang272a5272007-05-14 11:00:38 +020012477 [ALC262_SONY_ASSAMD] = {
12478 .mixers = { alc262_sony_mixer },
12479 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12480 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12481 .dac_nids = alc262_dac_nids,
12482 .hp_nid = 0x02,
12483 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12484 .channel_mode = alc262_modes,
12485 .input_mux = &alc262_capture_source,
12486 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012487 .setup = alc262_hippo_setup,
12488 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012489 },
12490 [ALC262_BENQ_T31] = {
12491 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012492 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12493 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012494 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12495 .dac_nids = alc262_dac_nids,
12496 .hp_nid = 0x03,
12497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12498 .channel_mode = alc262_modes,
12499 .input_mux = &alc262_capture_source,
12500 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012501 .setup = alc262_hippo_setup,
12502 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012503 },
Tobin Davisf651b502007-10-26 12:40:47 +020012504 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012505 .mixers = { alc262_ultra_mixer },
12506 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012507 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012508 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12509 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012510 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12511 .channel_mode = alc262_modes,
12512 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012513 .adc_nids = alc262_adc_nids, /* ADC0 */
12514 .capsrc_nids = alc262_capsrc_nids,
12515 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012516 .unsol_event = alc262_ultra_unsol_event,
12517 .init_hook = alc262_ultra_automute,
12518 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012519 [ALC262_LENOVO_3000] = {
12520 .mixers = { alc262_lenovo_3000_mixer },
12521 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012522 alc262_lenovo_3000_unsol_verbs,
12523 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012524 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12525 .dac_nids = alc262_dac_nids,
12526 .hp_nid = 0x03,
12527 .dig_out_nid = ALC262_DIGOUT_NID,
12528 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12529 .channel_mode = alc262_modes,
12530 .input_mux = &alc262_fujitsu_capture_source,
12531 .unsol_event = alc262_lenovo_3000_unsol_event,
12532 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012533 [ALC262_NEC] = {
12534 .mixers = { alc262_nec_mixer },
12535 .init_verbs = { alc262_nec_verbs },
12536 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12537 .dac_nids = alc262_dac_nids,
12538 .hp_nid = 0x03,
12539 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12540 .channel_mode = alc262_modes,
12541 .input_mux = &alc262_capture_source,
12542 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012543 [ALC262_TOSHIBA_S06] = {
12544 .mixers = { alc262_toshiba_s06_mixer },
12545 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12546 alc262_eapd_verbs },
12547 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12548 .capsrc_nids = alc262_dmic_capsrc_nids,
12549 .dac_nids = alc262_dac_nids,
12550 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012551 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012552 .dig_out_nid = ALC262_DIGOUT_NID,
12553 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12554 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012555 .unsol_event = alc_sku_unsol_event,
12556 .setup = alc262_toshiba_s06_setup,
12557 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012558 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012559 [ALC262_TOSHIBA_RX1] = {
12560 .mixers = { alc262_toshiba_rx1_mixer },
12561 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12562 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12563 .dac_nids = alc262_dac_nids,
12564 .hp_nid = 0x03,
12565 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12566 .channel_mode = alc262_modes,
12567 .input_mux = &alc262_capture_source,
12568 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012569 .setup = alc262_hippo_setup,
12570 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012571 },
Tony Vroonba340e82009-02-02 19:01:30 +000012572 [ALC262_TYAN] = {
12573 .mixers = { alc262_tyan_mixer },
12574 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12575 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12576 .dac_nids = alc262_dac_nids,
12577 .hp_nid = 0x02,
12578 .dig_out_nid = ALC262_DIGOUT_NID,
12579 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12580 .channel_mode = alc262_modes,
12581 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012582 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012583 .setup = alc262_tyan_setup,
12584 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012585 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012586};
12587
12588static int patch_alc262(struct hda_codec *codec)
12589{
12590 struct alc_spec *spec;
12591 int board_config;
12592 int err;
12593
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012594 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012595 if (spec == NULL)
12596 return -ENOMEM;
12597
12598 codec->spec = spec;
12599#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012600 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12601 * under-run
12602 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012603 {
12604 int tmp;
12605 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12606 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12607 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12608 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12609 }
12610#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012611 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012612
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012613 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12614
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012615 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12616 alc262_models,
12617 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012618
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012619 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012620 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12621 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012622 board_config = ALC262_AUTO;
12623 }
12624
12625 if (board_config == ALC262_AUTO) {
12626 /* automatic parse from the BIOS config */
12627 err = alc262_parse_auto_config(codec);
12628 if (err < 0) {
12629 alc_free(codec);
12630 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012631 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012632 printk(KERN_INFO
12633 "hda_codec: Cannot set up configuration "
12634 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012635 board_config = ALC262_BASIC;
12636 }
12637 }
12638
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012639 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012640 err = snd_hda_attach_beep_device(codec, 0x1);
12641 if (err < 0) {
12642 alc_free(codec);
12643 return err;
12644 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012645 }
12646
Kailang Yangdf694da2005-12-05 19:42:22 +010012647 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012648 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012649
Kailang Yangdf694da2005-12-05 19:42:22 +010012650 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12651 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012652
Kailang Yangdf694da2005-12-05 19:42:22 +010012653 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12654 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12655
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012656 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012657 int i;
12658 /* check whether the digital-mic has to be supported */
12659 for (i = 0; i < spec->input_mux->num_items; i++) {
12660 if (spec->input_mux->items[i].index >= 9)
12661 break;
12662 }
12663 if (i < spec->input_mux->num_items) {
12664 /* use only ADC0 */
12665 spec->adc_nids = alc262_dmic_adc_nids;
12666 spec->num_adc_nids = 1;
12667 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012668 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012669 /* all analog inputs */
12670 /* check whether NID 0x07 is valid */
12671 unsigned int wcap = get_wcaps(codec, 0x07);
12672
12673 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012674 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012675 if (wcap != AC_WID_AUD_IN) {
12676 spec->adc_nids = alc262_adc_nids_alt;
12677 spec->num_adc_nids =
12678 ARRAY_SIZE(alc262_adc_nids_alt);
12679 spec->capsrc_nids = alc262_capsrc_nids_alt;
12680 } else {
12681 spec->adc_nids = alc262_adc_nids;
12682 spec->num_adc_nids =
12683 ARRAY_SIZE(alc262_adc_nids);
12684 spec->capsrc_nids = alc262_capsrc_nids;
12685 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012686 }
12687 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012688 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012689 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012690 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012691 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012692
Takashi Iwai2134ea42008-01-10 16:53:55 +010012693 spec->vmaster_nid = 0x0c;
12694
Kailang Yangdf694da2005-12-05 19:42:22 +010012695 codec->patch_ops = alc_patch_ops;
12696 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012697 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012698#ifdef CONFIG_SND_HDA_POWER_SAVE
12699 if (!spec->loopback.amplist)
12700 spec->loopback.amplist = alc262_loopbacks;
12701#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012702
Kailang Yangdf694da2005-12-05 19:42:22 +010012703 return 0;
12704}
12705
Kailang Yangdf694da2005-12-05 19:42:22 +010012706/*
Kailang Yanga361d842007-06-05 12:30:55 +020012707 * ALC268 channel source setting (2 channel)
12708 */
12709#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12710#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012711
Kailang Yanga361d842007-06-05 12:30:55 +020012712static hda_nid_t alc268_dac_nids[2] = {
12713 /* front, hp */
12714 0x02, 0x03
12715};
12716
12717static hda_nid_t alc268_adc_nids[2] = {
12718 /* ADC0-1 */
12719 0x08, 0x07
12720};
12721
12722static hda_nid_t alc268_adc_nids_alt[1] = {
12723 /* ADC0 */
12724 0x08
12725};
12726
Takashi Iwaie1406342008-02-11 18:32:32 +010012727static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12728
Kailang Yanga361d842007-06-05 12:30:55 +020012729static struct snd_kcontrol_new alc268_base_mixer[] = {
12730 /* output mixer control */
12731 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12732 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12733 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12734 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012735 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12736 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12737 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012738 { }
12739};
12740
Takashi Iwai42171c12009-05-08 14:11:43 +020012741static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12742 /* output mixer control */
12743 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12744 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12745 ALC262_HIPPO_MASTER_SWITCH,
12746 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12747 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12749 { }
12750};
12751
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012752/* bind Beep switches of both NID 0x0f and 0x10 */
12753static struct hda_bind_ctls alc268_bind_beep_sw = {
12754 .ops = &snd_hda_bind_sw,
12755 .values = {
12756 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12757 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12758 0
12759 },
12760};
12761
12762static struct snd_kcontrol_new alc268_beep_mixer[] = {
12763 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12764 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12765 { }
12766};
12767
Kailang Yangd1a991a2007-08-15 16:21:59 +020012768static struct hda_verb alc268_eapd_verbs[] = {
12769 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12770 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12771 { }
12772};
12773
Takashi Iwaid2738092007-08-16 14:59:45 +020012774/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012775static struct hda_verb alc268_toshiba_verbs[] = {
12776 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12777 { } /* end */
12778};
12779
12780/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012781/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012782static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12783 .ops = &snd_hda_bind_vol,
12784 .values = {
12785 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12786 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12787 0
12788 },
12789};
12790
Takashi Iwai889c4392007-08-23 18:56:52 +020012791/* mute/unmute internal speaker according to the hp jack and mute state */
12792static void alc268_acer_automute(struct hda_codec *codec, int force)
12793{
12794 struct alc_spec *spec = codec->spec;
12795 unsigned int mute;
12796
12797 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012798 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012799 spec->sense_updated = 1;
12800 }
12801 if (spec->jack_present)
12802 mute = HDA_AMP_MUTE; /* mute internal speaker */
12803 else /* unmute internal speaker if necessary */
12804 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12805 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12806 HDA_AMP_MUTE, mute);
12807}
12808
12809
12810/* bind hp and internal speaker mute (with plug check) */
12811static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12812 struct snd_ctl_elem_value *ucontrol)
12813{
12814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12815 long *valp = ucontrol->value.integer.value;
12816 int change;
12817
Takashi Iwai8de56b72009-07-24 16:51:47 +020012818 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012819 if (change)
12820 alc268_acer_automute(codec, 0);
12821 return change;
12822}
Takashi Iwaid2738092007-08-16 14:59:45 +020012823
Kailang Yang8ef355d2008-08-26 13:10:22 +020012824static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12825 /* output mixer control */
12826 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12827 {
12828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12829 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012830 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012831 .info = snd_hda_mixer_amp_switch_info,
12832 .get = snd_hda_mixer_amp_switch_get,
12833 .put = alc268_acer_master_sw_put,
12834 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12835 },
12836 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12837 { }
12838};
12839
Takashi Iwaid2738092007-08-16 14:59:45 +020012840static struct snd_kcontrol_new alc268_acer_mixer[] = {
12841 /* output mixer control */
12842 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12843 {
12844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12845 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012846 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012847 .info = snd_hda_mixer_amp_switch_info,
12848 .get = snd_hda_mixer_amp_switch_get,
12849 .put = alc268_acer_master_sw_put,
12850 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12851 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12853 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12854 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012855 { }
12856};
12857
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012858static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12859 /* output mixer control */
12860 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12861 {
12862 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12863 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012864 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012865 .info = snd_hda_mixer_amp_switch_info,
12866 .get = snd_hda_mixer_amp_switch_get,
12867 .put = alc268_acer_master_sw_put,
12868 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12869 },
12870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12871 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12872 { }
12873};
12874
Kailang Yang8ef355d2008-08-26 13:10:22 +020012875static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12876 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12878 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12879 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12880 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12881 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12882 { }
12883};
12884
Takashi Iwaid2738092007-08-16 14:59:45 +020012885static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012886 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12887 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012888 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12889 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012890 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12891 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012892 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12893 { }
12894};
12895
12896/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012897#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012898#define alc268_toshiba_setup alc262_hippo_setup
12899#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012900
12901static void alc268_acer_unsol_event(struct hda_codec *codec,
12902 unsigned int res)
12903{
Takashi Iwai889c4392007-08-23 18:56:52 +020012904 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012905 return;
12906 alc268_acer_automute(codec, 1);
12907}
12908
Takashi Iwai889c4392007-08-23 18:56:52 +020012909static void alc268_acer_init_hook(struct hda_codec *codec)
12910{
12911 alc268_acer_automute(codec, 1);
12912}
12913
Kailang Yang8ef355d2008-08-26 13:10:22 +020012914/* toggle speaker-output according to the hp-jack state */
12915static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12916{
12917 unsigned int present;
12918 unsigned char bits;
12919
Wu Fengguang864f92b2009-11-18 12:38:02 +080012920 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012921 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012922 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012923 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012924 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020012925 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012926}
12927
Kailang Yang8ef355d2008-08-26 13:10:22 +020012928static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12929 unsigned int res)
12930{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012931 switch (res >> 26) {
12932 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012933 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012934 break;
12935 case ALC880_MIC_EVENT:
12936 alc_mic_automute(codec);
12937 break;
12938 }
12939}
12940
12941static void alc268_acer_lc_setup(struct hda_codec *codec)
12942{
12943 struct alc_spec *spec = codec->spec;
12944 spec->ext_mic.pin = 0x18;
12945 spec->ext_mic.mux_idx = 0;
12946 spec->int_mic.pin = 0x12;
12947 spec->int_mic.mux_idx = 6;
12948 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012949}
12950
12951static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12952{
12953 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012954 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012955}
12956
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012957static struct snd_kcontrol_new alc268_dell_mixer[] = {
12958 /* output mixer control */
12959 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12960 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12961 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12962 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12963 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12964 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12965 { }
12966};
12967
12968static struct hda_verb alc268_dell_verbs[] = {
12969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12971 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012972 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012973 { }
12974};
12975
12976/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012977static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012978{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012979 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012980
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012981 spec->autocfg.hp_pins[0] = 0x15;
12982 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012983 spec->ext_mic.pin = 0x18;
12984 spec->ext_mic.mux_idx = 0;
12985 spec->int_mic.pin = 0x19;
12986 spec->int_mic.mux_idx = 1;
12987 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012988}
12989
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012990static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12991 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12992 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12993 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12994 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12995 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12996 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12997 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12998 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12999 { }
13000};
13001
13002static struct hda_verb alc267_quanta_il1_verbs[] = {
13003 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13005 { }
13006};
13007
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013008static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013009{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013010 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013011 spec->autocfg.hp_pins[0] = 0x15;
13012 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013013 spec->ext_mic.pin = 0x18;
13014 spec->ext_mic.mux_idx = 0;
13015 spec->int_mic.pin = 0x19;
13016 spec->int_mic.mux_idx = 1;
13017 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013018}
13019
Kailang Yanga361d842007-06-05 12:30:55 +020013020/*
13021 * generic initialization of ADC, input mixers and output mixers
13022 */
13023static struct hda_verb alc268_base_init_verbs[] = {
13024 /* Unmute DAC0-1 and set vol = 0 */
13025 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013026 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013027
13028 /*
13029 * Set up output mixers (0x0c - 0x0e)
13030 */
13031 /* set vol=0 to output mixers */
13032 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013033 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13034
13035 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13036 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13037
13038 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13040 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13041 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13042 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13043 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13044 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13045 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13046
13047 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13048 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13049 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013051 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013052
13053 /* set PCBEEP vol = 0, mute connections */
13054 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13055 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13056 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013057
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013058 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013059
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013060 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13061 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13062 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13063 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013064
Kailang Yanga361d842007-06-05 12:30:55 +020013065 { }
13066};
13067
13068/*
13069 * generic initialization of ADC, input mixers and output mixers
13070 */
13071static struct hda_verb alc268_volume_init_verbs[] = {
13072 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013073 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13074 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013075
13076 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13077 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13078 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13079 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13080 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13081
Kailang Yanga361d842007-06-05 12:30:55 +020013082 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013083 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13084 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13085
13086 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013088
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013089 /* set PCBEEP vol = 0, mute connections */
13090 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13091 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13092 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013093
13094 { }
13095};
13096
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013097static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13098 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13099 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13100 { } /* end */
13101};
13102
Kailang Yanga361d842007-06-05 12:30:55 +020013103static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13104 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013106 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013107 { } /* end */
13108};
13109
13110static struct snd_kcontrol_new alc268_capture_mixer[] = {
13111 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13112 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13113 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13114 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013115 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013116 { } /* end */
13117};
13118
13119static struct hda_input_mux alc268_capture_source = {
13120 .num_items = 4,
13121 .items = {
13122 { "Mic", 0x0 },
13123 { "Front Mic", 0x1 },
13124 { "Line", 0x2 },
13125 { "CD", 0x3 },
13126 },
13127};
13128
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013129static struct hda_input_mux alc268_acer_capture_source = {
13130 .num_items = 3,
13131 .items = {
13132 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013133 { "Internal Mic", 0x1 },
13134 { "Line", 0x2 },
13135 },
13136};
13137
13138static struct hda_input_mux alc268_acer_dmic_capture_source = {
13139 .num_items = 3,
13140 .items = {
13141 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013142 { "Internal Mic", 0x6 },
13143 { "Line", 0x2 },
13144 },
13145};
13146
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013147#ifdef CONFIG_SND_DEBUG
13148static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013149 /* Volume widgets */
13150 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13152 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13153 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13154 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13155 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13156 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13157 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13158 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13159 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13160 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13161 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13162 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013163 /* The below appears problematic on some hardwares */
13164 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013165 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13166 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13167 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13168 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13169
13170 /* Modes for retasking pin widgets */
13171 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13172 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13173 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13174 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13175
13176 /* Controls for GPIO pins, assuming they are configured as outputs */
13177 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13178 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13179 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13180 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13181
13182 /* Switches to allow the digital SPDIF output pin to be enabled.
13183 * The ALC268 does not have an SPDIF input.
13184 */
13185 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13186
13187 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13188 * this output to turn on an external amplifier.
13189 */
13190 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13191 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13192
13193 { } /* end */
13194};
13195#endif
13196
Kailang Yanga361d842007-06-05 12:30:55 +020013197/* create input playback/capture controls for the given pin */
13198static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13199 const char *ctlname, int idx)
13200{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013201 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013202 int err;
13203
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013204 switch (nid) {
13205 case 0x14:
13206 case 0x16:
13207 dac = 0x02;
13208 break;
13209 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013210 case 0x1a: /* ALC259/269 only */
13211 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013212 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013213 dac = 0x03;
13214 break;
13215 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013216 snd_printd(KERN_WARNING "hda_codec: "
13217 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013218 return 0;
13219 }
13220 if (spec->multiout.dac_nids[0] != dac &&
13221 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013222 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013223 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013224 HDA_OUTPUT));
13225 if (err < 0)
13226 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013227 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13228 }
13229
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013230 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013231 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013232 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013233 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013234 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013235 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013236 if (err < 0)
13237 return err;
13238 return 0;
13239}
13240
13241/* add playback controls from the parsed DAC table */
13242static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13243 const struct auto_pin_cfg *cfg)
13244{
13245 hda_nid_t nid;
13246 int err;
13247
Kailang Yanga361d842007-06-05 12:30:55 +020013248 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013249
13250 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013251 if (nid) {
13252 const char *name;
13253 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13254 name = "Speaker";
13255 else
13256 name = "Front";
13257 err = alc268_new_analog_output(spec, nid, name, 0);
13258 if (err < 0)
13259 return err;
13260 }
Kailang Yanga361d842007-06-05 12:30:55 +020013261
13262 nid = cfg->speaker_pins[0];
13263 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013264 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013265 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13266 if (err < 0)
13267 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013268 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013269 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13270 if (err < 0)
13271 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013272 }
13273 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013274 if (nid) {
13275 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13276 if (err < 0)
13277 return err;
13278 }
Kailang Yanga361d842007-06-05 12:30:55 +020013279
13280 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13281 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013282 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013283 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013284 if (err < 0)
13285 return err;
13286 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013287 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013288}
13289
13290/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013291static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013292 const struct auto_pin_cfg *cfg)
13293{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013294 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013295}
13296
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013297static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13298 hda_nid_t nid, int pin_type)
13299{
13300 int idx;
13301
13302 alc_set_pin_output(codec, nid, pin_type);
13303 if (nid == 0x14 || nid == 0x16)
13304 idx = 0;
13305 else
13306 idx = 1;
13307 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13308}
13309
13310static void alc268_auto_init_multi_out(struct hda_codec *codec)
13311{
13312 struct alc_spec *spec = codec->spec;
13313 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13314 if (nid) {
13315 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13316 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13317 }
13318}
13319
13320static void alc268_auto_init_hp_out(struct hda_codec *codec)
13321{
13322 struct alc_spec *spec = codec->spec;
13323 hda_nid_t pin;
13324
13325 pin = spec->autocfg.hp_pins[0];
13326 if (pin)
13327 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13328 pin = spec->autocfg.speaker_pins[0];
13329 if (pin)
13330 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13331}
13332
Kailang Yanga361d842007-06-05 12:30:55 +020013333static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13334{
13335 struct alc_spec *spec = codec->spec;
13336 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13337 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13338 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13339 unsigned int dac_vol1, dac_vol2;
13340
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013341 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013342 snd_hda_codec_write(codec, speaker_nid, 0,
13343 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013344 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013345 snd_hda_codec_write(codec, 0x0f, 0,
13346 AC_VERB_SET_AMP_GAIN_MUTE,
13347 AMP_IN_UNMUTE(1));
13348 snd_hda_codec_write(codec, 0x10, 0,
13349 AC_VERB_SET_AMP_GAIN_MUTE,
13350 AMP_IN_UNMUTE(1));
13351 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013352 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013353 snd_hda_codec_write(codec, 0x0f, 0,
13354 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13355 snd_hda_codec_write(codec, 0x10, 0,
13356 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13357 }
13358
13359 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013360 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013361 dac_vol2 = AMP_OUT_ZERO;
13362 else if (line_nid == 0x15)
13363 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013364 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013365 dac_vol2 = AMP_OUT_ZERO;
13366 else if (hp_nid == 0x15)
13367 dac_vol1 = AMP_OUT_ZERO;
13368 if (line_nid != 0x16 || hp_nid != 0x16 ||
13369 spec->autocfg.line_out_pins[1] != 0x16 ||
13370 spec->autocfg.line_out_pins[2] != 0x16)
13371 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13372
13373 snd_hda_codec_write(codec, 0x02, 0,
13374 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13375 snd_hda_codec_write(codec, 0x03, 0,
13376 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13377}
13378
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013379/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013380#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13381#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013382#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013383#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13384
13385/*
13386 * BIOS auto configuration
13387 */
13388static int alc268_parse_auto_config(struct hda_codec *codec)
13389{
13390 struct alc_spec *spec = codec->spec;
13391 int err;
13392 static hda_nid_t alc268_ignore[] = { 0 };
13393
13394 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13395 alc268_ignore);
13396 if (err < 0)
13397 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013398 if (!spec->autocfg.line_outs) {
13399 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13400 spec->multiout.max_channels = 2;
13401 spec->no_analog = 1;
13402 goto dig_only;
13403 }
Kailang Yanga361d842007-06-05 12:30:55 +020013404 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013405 }
Kailang Yanga361d842007-06-05 12:30:55 +020013406 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13407 if (err < 0)
13408 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013409 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013410 if (err < 0)
13411 return err;
13412
13413 spec->multiout.max_channels = 2;
13414
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013415 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013416 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013417 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013418 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013419 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013420
Takashi Iwai892981f2009-03-02 08:04:35 +010013421 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013422 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013423
Takashi Iwaid88897e2008-10-31 15:01:37 +010013424 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013425 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013426 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013427
Takashi Iwai776e1842007-08-29 15:07:11 +020013428 err = alc_auto_add_mic_boost(codec);
13429 if (err < 0)
13430 return err;
13431
Kailang Yang6227cdc2010-02-25 08:36:52 +010013432 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013433
Kailang Yanga361d842007-06-05 12:30:55 +020013434 return 1;
13435}
13436
Kailang Yanga361d842007-06-05 12:30:55 +020013437#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13438
13439/* init callback for auto-configuration model -- overriding the default init */
13440static void alc268_auto_init(struct hda_codec *codec)
13441{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013442 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013443 alc268_auto_init_multi_out(codec);
13444 alc268_auto_init_hp_out(codec);
13445 alc268_auto_init_mono_speaker_out(codec);
13446 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013447 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013448 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013449 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013450}
13451
13452/*
13453 * configuration and preset
13454 */
13455static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013456 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013457 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013458 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013459 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013460 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013461 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013462 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013463 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013464#ifdef CONFIG_SND_DEBUG
13465 [ALC268_TEST] = "test",
13466#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013467 [ALC268_AUTO] = "auto",
13468};
13469
13470static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013471 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013472 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013473 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013474 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013475 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013476 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13477 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013478 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013479 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13480 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013481 /* almost compatible with toshiba but with optional digital outs;
13482 * auto-probing seems working fine
13483 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013484 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013485 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013486 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013487 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013488 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013489 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013490 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013491 {}
13492};
13493
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013494/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13495static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13496 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13497 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13498 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13499 ALC268_TOSHIBA),
13500 {}
13501};
13502
Kailang Yanga361d842007-06-05 12:30:55 +020013503static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013504 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013505 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13506 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013507 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13508 alc267_quanta_il1_verbs },
13509 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13510 .dac_nids = alc268_dac_nids,
13511 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13512 .adc_nids = alc268_adc_nids_alt,
13513 .hp_nid = 0x03,
13514 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13515 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013516 .unsol_event = alc_sku_unsol_event,
13517 .setup = alc267_quanta_il1_setup,
13518 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013519 },
Kailang Yanga361d842007-06-05 12:30:55 +020013520 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013521 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13522 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013523 .init_verbs = { alc268_base_init_verbs },
13524 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13525 .dac_nids = alc268_dac_nids,
13526 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13527 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013528 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013529 .hp_nid = 0x03,
13530 .dig_out_nid = ALC268_DIGOUT_NID,
13531 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13532 .channel_mode = alc268_modes,
13533 .input_mux = &alc268_capture_source,
13534 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013535 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013536 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013537 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013538 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13539 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013540 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13541 .dac_nids = alc268_dac_nids,
13542 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13543 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013544 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013545 .hp_nid = 0x03,
13546 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13547 .channel_mode = alc268_modes,
13548 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013549 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013550 .setup = alc268_toshiba_setup,
13551 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013552 },
13553 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013554 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013555 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013556 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13557 alc268_acer_verbs },
13558 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13559 .dac_nids = alc268_dac_nids,
13560 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13561 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013562 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013563 .hp_nid = 0x02,
13564 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13565 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013566 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013567 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013568 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013569 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013570 [ALC268_ACER_DMIC] = {
13571 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13572 alc268_beep_mixer },
13573 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13574 alc268_acer_verbs },
13575 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13576 .dac_nids = alc268_dac_nids,
13577 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13578 .adc_nids = alc268_adc_nids_alt,
13579 .capsrc_nids = alc268_capsrc_nids,
13580 .hp_nid = 0x02,
13581 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13582 .channel_mode = alc268_modes,
13583 .input_mux = &alc268_acer_dmic_capture_source,
13584 .unsol_event = alc268_acer_unsol_event,
13585 .init_hook = alc268_acer_init_hook,
13586 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013587 [ALC268_ACER_ASPIRE_ONE] = {
13588 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013589 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013590 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013591 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13592 alc268_acer_aspire_one_verbs },
13593 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13594 .dac_nids = alc268_dac_nids,
13595 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13596 .adc_nids = alc268_adc_nids_alt,
13597 .capsrc_nids = alc268_capsrc_nids,
13598 .hp_nid = 0x03,
13599 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13600 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013601 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013602 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013603 .init_hook = alc268_acer_lc_init_hook,
13604 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013605 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013606 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13607 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013608 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13609 alc268_dell_verbs },
13610 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13611 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013612 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13613 .adc_nids = alc268_adc_nids_alt,
13614 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013615 .hp_nid = 0x02,
13616 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13617 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013618 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013619 .setup = alc268_dell_setup,
13620 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013621 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013622 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013623 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13624 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013625 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13626 alc268_toshiba_verbs },
13627 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13628 .dac_nids = alc268_dac_nids,
13629 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13630 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013631 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013632 .hp_nid = 0x03,
13633 .dig_out_nid = ALC268_DIGOUT_NID,
13634 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13635 .channel_mode = alc268_modes,
13636 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013637 .setup = alc268_toshiba_setup,
13638 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013639 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013640#ifdef CONFIG_SND_DEBUG
13641 [ALC268_TEST] = {
13642 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13643 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13644 alc268_volume_init_verbs },
13645 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13646 .dac_nids = alc268_dac_nids,
13647 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13648 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013649 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013650 .hp_nid = 0x03,
13651 .dig_out_nid = ALC268_DIGOUT_NID,
13652 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13653 .channel_mode = alc268_modes,
13654 .input_mux = &alc268_capture_source,
13655 },
13656#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013657};
13658
13659static int patch_alc268(struct hda_codec *codec)
13660{
13661 struct alc_spec *spec;
13662 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013663 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013664
Julia Lawallef86f582009-12-19 08:18:03 +010013665 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013666 if (spec == NULL)
13667 return -ENOMEM;
13668
13669 codec->spec = spec;
13670
13671 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13672 alc268_models,
13673 alc268_cfg_tbl);
13674
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013675 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13676 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013677 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013678
Kailang Yanga361d842007-06-05 12:30:55 +020013679 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013680 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13681 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013682 board_config = ALC268_AUTO;
13683 }
13684
13685 if (board_config == ALC268_AUTO) {
13686 /* automatic parse from the BIOS config */
13687 err = alc268_parse_auto_config(codec);
13688 if (err < 0) {
13689 alc_free(codec);
13690 return err;
13691 } else if (!err) {
13692 printk(KERN_INFO
13693 "hda_codec: Cannot set up configuration "
13694 "from BIOS. Using base mode...\n");
13695 board_config = ALC268_3ST;
13696 }
13697 }
13698
13699 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013700 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013701
Kailang Yanga361d842007-06-05 12:30:55 +020013702 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13703 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013704 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013705
Kailang Yanga361d842007-06-05 12:30:55 +020013706 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13707
Takashi Iwai22971e32009-02-10 11:56:44 +010013708 has_beep = 0;
13709 for (i = 0; i < spec->num_mixers; i++) {
13710 if (spec->mixers[i] == alc268_beep_mixer) {
13711 has_beep = 1;
13712 break;
13713 }
13714 }
13715
13716 if (has_beep) {
13717 err = snd_hda_attach_beep_device(codec, 0x1);
13718 if (err < 0) {
13719 alc_free(codec);
13720 return err;
13721 }
13722 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13723 /* override the amp caps for beep generator */
13724 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013725 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13726 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13727 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13728 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013729 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013730
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013731 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013732 /* check whether NID 0x07 is valid */
13733 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013734 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013735
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013736 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013737 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013738 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013739 if (spec->auto_mic ||
13740 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013741 spec->adc_nids = alc268_adc_nids_alt;
13742 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013743 if (spec->auto_mic)
13744 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013745 if (spec->auto_mic || spec->input_mux->num_items == 1)
13746 add_mixer(spec, alc268_capture_nosrc_mixer);
13747 else
13748 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013749 } else {
13750 spec->adc_nids = alc268_adc_nids;
13751 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013752 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013753 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013754 /* set default input source */
13755 for (i = 0; i < spec->num_adc_nids; i++)
13756 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13757 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013758 i < spec->num_mux_defs ?
13759 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013760 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013761 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013762
13763 spec->vmaster_nid = 0x02;
13764
Kailang Yanga361d842007-06-05 12:30:55 +020013765 codec->patch_ops = alc_patch_ops;
13766 if (board_config == ALC268_AUTO)
13767 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013768
Kailang Yanga361d842007-06-05 12:30:55 +020013769 return 0;
13770}
13771
13772/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013773 * ALC269 channel source setting (2 channel)
13774 */
13775#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13776
13777#define alc269_dac_nids alc260_dac_nids
13778
13779static hda_nid_t alc269_adc_nids[1] = {
13780 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013781 0x08,
13782};
13783
Takashi Iwaie01bf502008-08-21 16:25:07 +020013784static hda_nid_t alc269_capsrc_nids[1] = {
13785 0x23,
13786};
13787
Kailang Yang84898e82010-02-04 14:16:14 +010013788static hda_nid_t alc269vb_adc_nids[1] = {
13789 /* ADC1 */
13790 0x09,
13791};
13792
13793static hda_nid_t alc269vb_capsrc_nids[1] = {
13794 0x22,
13795};
13796
Takashi Iwai66946352010-03-29 17:21:45 +020013797static hda_nid_t alc269_adc_candidates[] = {
13798 0x08, 0x09, 0x07,
13799};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013800
Kailang Yangf6a92242007-12-13 16:52:54 +010013801#define alc269_modes alc260_modes
13802#define alc269_capture_source alc880_lg_lw_capture_source
13803
13804static struct snd_kcontrol_new alc269_base_mixer[] = {
13805 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13806 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13807 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13808 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13809 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13810 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13812 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13813 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13814 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13815 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13816 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13817 { } /* end */
13818};
13819
Kailang Yang60db6b52008-08-26 13:13:00 +020013820static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13821 /* output mixer control */
13822 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13823 {
13824 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13825 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013826 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013827 .info = snd_hda_mixer_amp_switch_info,
13828 .get = snd_hda_mixer_amp_switch_get,
13829 .put = alc268_acer_master_sw_put,
13830 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13831 },
13832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13835 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13836 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13837 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013838 { }
13839};
13840
Tony Vroon64154832008-11-06 15:08:49 +000013841static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13842 /* output mixer control */
13843 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13844 {
13845 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13846 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013847 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013848 .info = snd_hda_mixer_amp_switch_info,
13849 .get = snd_hda_mixer_amp_switch_get,
13850 .put = alc268_acer_master_sw_put,
13851 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13852 },
13853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13855 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13856 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13857 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13858 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13859 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13860 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13861 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013862 { }
13863};
13864
Kailang Yang84898e82010-02-04 14:16:14 +010013865static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013866 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013867 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013869 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013870 { } /* end */
13871};
13872
Kailang Yang84898e82010-02-04 14:16:14 +010013873static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13874 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13875 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13876 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13877 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13878 { } /* end */
13879};
13880
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020013881static struct snd_kcontrol_new alc269_asus_mixer[] = {
13882 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13883 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
13884 { } /* end */
13885};
13886
Kailang Yangf6a92242007-12-13 16:52:54 +010013887/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013888static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13889 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13890 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13892 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13893 { } /* end */
13894};
13895
13896static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013897 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13898 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13900 { } /* end */
13901};
13902
Kailang Yang84898e82010-02-04 14:16:14 +010013903static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13904 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13905 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13906 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13907 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13908 { } /* end */
13909};
13910
13911static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13912 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13913 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13914 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13915 { } /* end */
13916};
13917
Takashi Iwai26f5df22008-11-03 17:39:46 +010013918/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013919#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013920
Kailang Yang60db6b52008-08-26 13:13:00 +020013921static struct hda_verb alc269_quanta_fl1_verbs[] = {
13922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13923 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13924 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13925 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13926 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13927 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13928 { }
13929};
13930
Tony Vroon64154832008-11-06 15:08:49 +000013931static struct hda_verb alc269_lifebook_verbs[] = {
13932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13934 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13935 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13936 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13937 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13938 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13939 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13941 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13942 { }
13943};
13944
Kailang Yang60db6b52008-08-26 13:13:00 +020013945/* toggle speaker-output according to the hp-jack state */
13946static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13947{
13948 unsigned int present;
13949 unsigned char bits;
13950
Wu Fengguang864f92b2009-11-18 12:38:02 +080013951 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013952 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020013953 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013954 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013955 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013956 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020013957
13958 snd_hda_codec_write(codec, 0x20, 0,
13959 AC_VERB_SET_COEF_INDEX, 0x0c);
13960 snd_hda_codec_write(codec, 0x20, 0,
13961 AC_VERB_SET_PROC_COEF, 0x680);
13962
13963 snd_hda_codec_write(codec, 0x20, 0,
13964 AC_VERB_SET_COEF_INDEX, 0x0c);
13965 snd_hda_codec_write(codec, 0x20, 0,
13966 AC_VERB_SET_PROC_COEF, 0x480);
13967}
13968
Tony Vroon64154832008-11-06 15:08:49 +000013969/* toggle speaker-output according to the hp-jacks state */
13970static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13971{
13972 unsigned int present;
13973 unsigned char bits;
13974
13975 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013976 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013977
13978 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013979 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013980
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013981 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000013982 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013983 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013984 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013985 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000013986
13987 snd_hda_codec_write(codec, 0x20, 0,
13988 AC_VERB_SET_COEF_INDEX, 0x0c);
13989 snd_hda_codec_write(codec, 0x20, 0,
13990 AC_VERB_SET_PROC_COEF, 0x680);
13991
13992 snd_hda_codec_write(codec, 0x20, 0,
13993 AC_VERB_SET_COEF_INDEX, 0x0c);
13994 snd_hda_codec_write(codec, 0x20, 0,
13995 AC_VERB_SET_PROC_COEF, 0x480);
13996}
13997
Tony Vroon64154832008-11-06 15:08:49 +000013998static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13999{
14000 unsigned int present_laptop;
14001 unsigned int present_dock;
14002
Wu Fengguang864f92b2009-11-18 12:38:02 +080014003 present_laptop = snd_hda_jack_detect(codec, 0x18);
14004 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014005
14006 /* Laptop mic port overrides dock mic port, design decision */
14007 if (present_dock)
14008 snd_hda_codec_write(codec, 0x23, 0,
14009 AC_VERB_SET_CONNECT_SEL, 0x3);
14010 if (present_laptop)
14011 snd_hda_codec_write(codec, 0x23, 0,
14012 AC_VERB_SET_CONNECT_SEL, 0x0);
14013 if (!present_dock && !present_laptop)
14014 snd_hda_codec_write(codec, 0x23, 0,
14015 AC_VERB_SET_CONNECT_SEL, 0x1);
14016}
14017
Kailang Yang60db6b52008-08-26 13:13:00 +020014018static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14019 unsigned int res)
14020{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014021 switch (res >> 26) {
14022 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014023 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014024 break;
14025 case ALC880_MIC_EVENT:
14026 alc_mic_automute(codec);
14027 break;
14028 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014029}
14030
Tony Vroon64154832008-11-06 15:08:49 +000014031static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14032 unsigned int res)
14033{
14034 if ((res >> 26) == ALC880_HP_EVENT)
14035 alc269_lifebook_speaker_automute(codec);
14036 if ((res >> 26) == ALC880_MIC_EVENT)
14037 alc269_lifebook_mic_autoswitch(codec);
14038}
14039
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014040static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14041{
14042 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014043 spec->autocfg.hp_pins[0] = 0x15;
14044 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014045 spec->ext_mic.pin = 0x18;
14046 spec->ext_mic.mux_idx = 0;
14047 spec->int_mic.pin = 0x19;
14048 spec->int_mic.mux_idx = 1;
14049 spec->auto_mic = 1;
14050}
14051
Kailang Yang60db6b52008-08-26 13:13:00 +020014052static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14053{
14054 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014055 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014056}
14057
Tony Vroon64154832008-11-06 15:08:49 +000014058static void alc269_lifebook_init_hook(struct hda_codec *codec)
14059{
14060 alc269_lifebook_speaker_automute(codec);
14061 alc269_lifebook_mic_autoswitch(codec);
14062}
14063
Kailang Yang84898e82010-02-04 14:16:14 +010014064static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014065 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14066 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14067 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14068 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14069 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14070 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14071 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14072 {}
14073};
14074
Kailang Yang84898e82010-02-04 14:16:14 +010014075static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014076 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14077 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14078 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14079 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14080 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14081 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14082 {}
14083};
14084
Kailang Yang84898e82010-02-04 14:16:14 +010014085static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14086 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14087 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14088 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14090 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14091 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14092 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14093 {}
14094};
14095
14096static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14097 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14098 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14099 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14101 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14102 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14103 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14104 {}
14105};
14106
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014107static struct hda_verb alc271_acer_dmic_verbs[] = {
14108 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14109 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14112 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14113 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14114 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14115 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14116 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14117 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14118 { }
14119};
14120
Kailang Yang60db6b52008-08-26 13:13:00 +020014121/* toggle speaker-output according to the hp-jack state */
14122static void alc269_speaker_automute(struct hda_codec *codec)
14123{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014124 struct alc_spec *spec = codec->spec;
14125 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014126 unsigned int present;
14127 unsigned char bits;
14128
Kailang Yangebb83ee2009-12-17 12:23:00 +010014129 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014130 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014131 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014132 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014133 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014134 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014135}
14136
Kailang Yang60db6b52008-08-26 13:13:00 +020014137/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014138static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014139 unsigned int res)
14140{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014141 switch (res >> 26) {
14142 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014143 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014144 break;
14145 case ALC880_MIC_EVENT:
14146 alc_mic_automute(codec);
14147 break;
14148 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014149}
14150
Kailang Yang226b1ec2010-04-09 11:01:20 +020014151static void alc269_laptop_amic_setup(struct hda_codec *codec)
14152{
14153 struct alc_spec *spec = codec->spec;
14154 spec->autocfg.hp_pins[0] = 0x15;
14155 spec->autocfg.speaker_pins[0] = 0x14;
14156 spec->ext_mic.pin = 0x18;
14157 spec->ext_mic.mux_idx = 0;
14158 spec->int_mic.pin = 0x19;
14159 spec->int_mic.mux_idx = 1;
14160 spec->auto_mic = 1;
14161}
14162
Kailang Yang84898e82010-02-04 14:16:14 +010014163static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014164{
14165 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014166 spec->autocfg.hp_pins[0] = 0x15;
14167 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014168 spec->ext_mic.pin = 0x18;
14169 spec->ext_mic.mux_idx = 0;
14170 spec->int_mic.pin = 0x12;
14171 spec->int_mic.mux_idx = 5;
14172 spec->auto_mic = 1;
14173}
14174
Kailang Yang226b1ec2010-04-09 11:01:20 +020014175static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014176{
14177 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014178 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014179 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014180 spec->ext_mic.pin = 0x18;
14181 spec->ext_mic.mux_idx = 0;
14182 spec->int_mic.pin = 0x19;
14183 spec->int_mic.mux_idx = 1;
14184 spec->auto_mic = 1;
14185}
14186
Kailang Yang226b1ec2010-04-09 11:01:20 +020014187static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14188{
14189 struct alc_spec *spec = codec->spec;
14190 spec->autocfg.hp_pins[0] = 0x21;
14191 spec->autocfg.speaker_pins[0] = 0x14;
14192 spec->ext_mic.pin = 0x18;
14193 spec->ext_mic.mux_idx = 0;
14194 spec->int_mic.pin = 0x12;
14195 spec->int_mic.mux_idx = 6;
14196 spec->auto_mic = 1;
14197}
14198
Kailang Yang84898e82010-02-04 14:16:14 +010014199static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014200{
14201 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014202 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014203}
14204
Kailang Yangf6a92242007-12-13 16:52:54 +010014205/*
14206 * generic initialization of ADC, input mixers and output mixers
14207 */
14208static struct hda_verb alc269_init_verbs[] = {
14209 /*
14210 * Unmute ADC0 and set the default input to mic-in
14211 */
Kailang Yang84898e82010-02-04 14:16:14 +010014212 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014213
14214 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014215 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014216 */
14217 /* set vol=0 to output mixers */
14218 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14219 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14220
14221 /* set up input amps for analog loopback */
14222 /* Amp Indices: DAC = 0, mixer = 1 */
14223 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14224 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14225 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14226 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14228 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14229
14230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14232 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14233 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14234 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14235 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14236 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14237
14238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14239 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014240
Kailang Yang84898e82010-02-04 14:16:14 +010014241 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014242 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14243 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014244 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014245
14246 /* set EAPD */
14247 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014248 { }
14249};
14250
14251static struct hda_verb alc269vb_init_verbs[] = {
14252 /*
14253 * Unmute ADC0 and set the default input to mic-in
14254 */
14255 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14256
14257 /*
14258 * Set up output mixers (0x02 - 0x03)
14259 */
14260 /* set vol=0 to output mixers */
14261 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14262 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14263
14264 /* set up input amps for analog loopback */
14265 /* Amp Indices: DAC = 0, mixer = 1 */
14266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14267 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14268 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14269 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14270 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14271 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14272
14273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14274 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14275 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14276 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14278 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14279 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14280
14281 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14282 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14283
14284 /* FIXME: use Mux-type input source selection */
14285 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14286 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14287 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14288
14289 /* set EAPD */
14290 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014291 { }
14292};
14293
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014294#define alc269_auto_create_multi_out_ctls \
14295 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014296#define alc269_auto_create_input_ctls \
14297 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014298
14299#ifdef CONFIG_SND_HDA_POWER_SAVE
14300#define alc269_loopbacks alc880_loopbacks
14301#endif
14302
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014303/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014304#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14305#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14306#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14307#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14308
Takashi Iwaif03d3112009-03-05 14:18:16 +010014309static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14310 .substreams = 1,
14311 .channels_min = 2,
14312 .channels_max = 8,
14313 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14314 /* NID is set in alc_build_pcms */
14315 .ops = {
14316 .open = alc880_playback_pcm_open,
14317 .prepare = alc880_playback_pcm_prepare,
14318 .cleanup = alc880_playback_pcm_cleanup
14319 },
14320};
14321
14322static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14323 .substreams = 1,
14324 .channels_min = 2,
14325 .channels_max = 2,
14326 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14327 /* NID is set in alc_build_pcms */
14328};
14329
Takashi Iwaiad358792010-03-30 18:00:59 +020014330#ifdef CONFIG_SND_HDA_POWER_SAVE
14331static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14332{
14333 switch (codec->subsystem_id) {
14334 case 0x103c1586:
14335 return 1;
14336 }
14337 return 0;
14338}
14339
14340static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14341{
14342 /* update mute-LED according to the speaker mute state */
14343 if (nid == 0x01 || nid == 0x14) {
14344 int pinval;
14345 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14346 HDA_AMP_MUTE)
14347 pinval = 0x24;
14348 else
14349 pinval = 0x20;
14350 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014351 snd_hda_codec_update_cache(codec, 0x19, 0,
14352 AC_VERB_SET_PIN_WIDGET_CONTROL,
14353 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014354 }
14355 return alc_check_power_status(codec, nid);
14356}
14357#endif /* CONFIG_SND_HDA_POWER_SAVE */
14358
Takashi Iwai840b64c2010-07-13 22:49:01 +020014359static int alc275_setup_dual_adc(struct hda_codec *codec)
14360{
14361 struct alc_spec *spec = codec->spec;
14362
14363 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14364 return 0;
14365 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14366 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14367 if (spec->ext_mic.pin <= 0x12) {
14368 spec->private_adc_nids[0] = 0x08;
14369 spec->private_adc_nids[1] = 0x11;
14370 spec->private_capsrc_nids[0] = 0x23;
14371 spec->private_capsrc_nids[1] = 0x22;
14372 } else {
14373 spec->private_adc_nids[0] = 0x11;
14374 spec->private_adc_nids[1] = 0x08;
14375 spec->private_capsrc_nids[0] = 0x22;
14376 spec->private_capsrc_nids[1] = 0x23;
14377 }
14378 spec->adc_nids = spec->private_adc_nids;
14379 spec->capsrc_nids = spec->private_capsrc_nids;
14380 spec->num_adc_nids = 2;
14381 spec->dual_adc_switch = 1;
14382 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14383 spec->adc_nids[0], spec->adc_nids[1]);
14384 return 1;
14385 }
14386 return 0;
14387}
14388
Kailang Yangf6a92242007-12-13 16:52:54 +010014389/*
14390 * BIOS auto configuration
14391 */
14392static int alc269_parse_auto_config(struct hda_codec *codec)
14393{
14394 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014395 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014396 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14397
14398 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14399 alc269_ignore);
14400 if (err < 0)
14401 return err;
14402
14403 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14404 if (err < 0)
14405 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014406 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014407 if (err < 0)
14408 return err;
14409
14410 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14411
Takashi Iwai757899a2010-07-30 10:48:14 +020014412 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014413
Takashi Iwai603c4012008-07-30 15:01:44 +020014414 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014415 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014416
Kailang Yang84898e82010-02-04 14:16:14 +010014417 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14418 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014419 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014420 } else {
14421 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014422 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014423 }
14424
Kailang Yangf6a92242007-12-13 16:52:54 +010014425 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014426 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014427
14428 if (!alc275_setup_dual_adc(codec))
14429 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14430 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014431
Takashi Iwaie01bf502008-08-21 16:25:07 +020014432 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014433 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014434 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14435 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014436
14437 err = alc_auto_add_mic_boost(codec);
14438 if (err < 0)
14439 return err;
14440
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014441 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014442 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014443
Kailang Yangf6a92242007-12-13 16:52:54 +010014444 return 1;
14445}
14446
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014447#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14448#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014449#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14450
14451
14452/* init callback for auto-configuration model -- overriding the default init */
14453static void alc269_auto_init(struct hda_codec *codec)
14454{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014455 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014456 alc269_auto_init_multi_out(codec);
14457 alc269_auto_init_hp_out(codec);
14458 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014459 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014460 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014461 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014462}
14463
Takashi Iwaiff818c22010-04-12 08:59:25 +020014464enum {
14465 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014466 ALC269_FIXUP_DELL_M101Z,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014467};
14468
Tobias Klauserfbc25662010-05-20 10:40:55 +020014469static const struct hda_verb alc269_sony_vaio_fixup_verbs[] = {
Takashi Iwaiff818c22010-04-12 08:59:25 +020014470 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14471 {}
14472};
14473
14474static const struct alc_fixup alc269_fixups[] = {
14475 [ALC269_FIXUP_SONY_VAIO] = {
14476 .verbs = alc269_sony_vaio_fixup_verbs
14477 },
David Henningsson145a9022010-09-16 10:07:53 +020014478 [ALC269_FIXUP_DELL_M101Z] = {
14479 .verbs = (const struct hda_verb[]) {
14480 /* Enables internal speaker */
14481 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14482 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14483 {}
14484 }
14485 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014486};
14487
14488static struct snd_pci_quirk alc269_fixup_tbl[] = {
14489 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014490 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014491 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014492 {}
14493};
14494
14495
Kailang Yangf6a92242007-12-13 16:52:54 +010014496/*
14497 * configuration and preset
14498 */
14499static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014500 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014501 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014502 [ALC269_AMIC] = "laptop-amic",
14503 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014504 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014505 [ALC269_LIFEBOOK] = "lifebook",
14506 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014507};
14508
14509static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014510 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014511 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014512 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014513 ALC269_AMIC),
14514 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14515 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14516 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14517 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14518 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14519 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14520 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14521 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14522 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14523 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14524 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14525 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14526 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14527 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14528 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14529 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14530 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14531 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14532 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14533 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14534 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14535 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14536 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14537 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14538 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14539 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14540 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14541 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14542 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14543 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14544 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14545 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14546 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14547 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14548 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14549 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014550 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014551 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014552 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014553 ALC269_DMIC),
14554 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14555 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014556 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014557 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014558 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14559 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14560 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14561 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14562 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14563 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014564 {}
14565};
14566
14567static struct alc_config_preset alc269_presets[] = {
14568 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014569 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014570 .init_verbs = { alc269_init_verbs },
14571 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14572 .dac_nids = alc269_dac_nids,
14573 .hp_nid = 0x03,
14574 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14575 .channel_mode = alc269_modes,
14576 .input_mux = &alc269_capture_source,
14577 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014578 [ALC269_QUANTA_FL1] = {
14579 .mixers = { alc269_quanta_fl1_mixer },
14580 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14581 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14582 .dac_nids = alc269_dac_nids,
14583 .hp_nid = 0x03,
14584 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14585 .channel_mode = alc269_modes,
14586 .input_mux = &alc269_capture_source,
14587 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014588 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014589 .init_hook = alc269_quanta_fl1_init_hook,
14590 },
Kailang Yang84898e82010-02-04 14:16:14 +010014591 [ALC269_AMIC] = {
14592 .mixers = { alc269_laptop_mixer },
14593 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014594 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014595 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014596 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14597 .dac_nids = alc269_dac_nids,
14598 .hp_nid = 0x03,
14599 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14600 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014601 .unsol_event = alc269_laptop_unsol_event,
14602 .setup = alc269_laptop_amic_setup,
14603 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014604 },
Kailang Yang84898e82010-02-04 14:16:14 +010014605 [ALC269_DMIC] = {
14606 .mixers = { alc269_laptop_mixer },
14607 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014608 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014609 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014610 .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,
Kailang Yang84898e82010-02-04 14:16:14 +010014615 .unsol_event = alc269_laptop_unsol_event,
14616 .setup = alc269_laptop_dmic_setup,
14617 .init_hook = alc269_laptop_inithook,
14618 },
14619 [ALC269VB_AMIC] = {
14620 .mixers = { alc269vb_laptop_mixer },
14621 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14622 .init_verbs = { alc269vb_init_verbs,
14623 alc269vb_laptop_amic_init_verbs },
14624 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14625 .dac_nids = alc269_dac_nids,
14626 .hp_nid = 0x03,
14627 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14628 .channel_mode = alc269_modes,
14629 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014630 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014631 .init_hook = alc269_laptop_inithook,
14632 },
14633 [ALC269VB_DMIC] = {
14634 .mixers = { alc269vb_laptop_mixer },
14635 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14636 .init_verbs = { alc269vb_init_verbs,
14637 alc269vb_laptop_dmic_init_verbs },
14638 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14639 .dac_nids = alc269_dac_nids,
14640 .hp_nid = 0x03,
14641 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14642 .channel_mode = alc269_modes,
14643 .unsol_event = alc269_laptop_unsol_event,
14644 .setup = alc269vb_laptop_dmic_setup,
14645 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014646 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014647 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014648 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014649 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014650 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014651 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014652 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14653 .dac_nids = alc269_dac_nids,
14654 .hp_nid = 0x03,
14655 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14656 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014657 .unsol_event = alc269_laptop_unsol_event,
14658 .setup = alc269_laptop_dmic_setup,
14659 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014660 },
Tony Vroon64154832008-11-06 15:08:49 +000014661 [ALC269_LIFEBOOK] = {
14662 .mixers = { alc269_lifebook_mixer },
14663 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14664 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14665 .dac_nids = alc269_dac_nids,
14666 .hp_nid = 0x03,
14667 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14668 .channel_mode = alc269_modes,
14669 .input_mux = &alc269_capture_source,
14670 .unsol_event = alc269_lifebook_unsol_event,
14671 .init_hook = alc269_lifebook_init_hook,
14672 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014673 [ALC271_ACER] = {
14674 .mixers = { alc269_asus_mixer },
14675 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14676 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14677 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14678 .dac_nids = alc269_dac_nids,
14679 .adc_nids = alc262_dmic_adc_nids,
14680 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14681 .capsrc_nids = alc262_dmic_capsrc_nids,
14682 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14683 .channel_mode = alc269_modes,
14684 .input_mux = &alc269_capture_source,
14685 .dig_out_nid = ALC880_DIGOUT_NID,
14686 .unsol_event = alc_sku_unsol_event,
14687 .setup = alc269vb_laptop_dmic_setup,
14688 .init_hook = alc_inithook,
14689 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014690};
14691
14692static int patch_alc269(struct hda_codec *codec)
14693{
14694 struct alc_spec *spec;
14695 int board_config;
14696 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014697 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014698
14699 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14700 if (spec == NULL)
14701 return -ENOMEM;
14702
14703 codec->spec = spec;
14704
Kailang Yangda00c242010-03-19 11:23:45 +010014705 alc_auto_parse_customize_define(codec);
14706
Kailang Yang274693f2009-12-03 10:07:50 +010014707 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014708 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14709 spec->cdefine.platform_type == 1)
14710 alc_codec_rename(codec, "ALC271X");
14711 else
14712 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014713 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014714 } else
14715 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014716
Kailang Yangf6a92242007-12-13 16:52:54 +010014717 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14718 alc269_models,
14719 alc269_cfg_tbl);
14720
14721 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014722 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14723 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014724 board_config = ALC269_AUTO;
14725 }
14726
Takashi Iwaiff818c22010-04-12 08:59:25 +020014727 if (board_config == ALC269_AUTO)
14728 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14729
Kailang Yangf6a92242007-12-13 16:52:54 +010014730 if (board_config == ALC269_AUTO) {
14731 /* automatic parse from the BIOS config */
14732 err = alc269_parse_auto_config(codec);
14733 if (err < 0) {
14734 alc_free(codec);
14735 return err;
14736 } else if (!err) {
14737 printk(KERN_INFO
14738 "hda_codec: Cannot set up configuration "
14739 "from BIOS. Using base mode...\n");
14740 board_config = ALC269_BASIC;
14741 }
14742 }
14743
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014744 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014745 err = snd_hda_attach_beep_device(codec, 0x1);
14746 if (err < 0) {
14747 alc_free(codec);
14748 return err;
14749 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014750 }
14751
Kailang Yangf6a92242007-12-13 16:52:54 +010014752 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014753 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014754
Kailang Yang84898e82010-02-04 14:16:14 +010014755 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014756 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14757 * fix the sample rate of analog I/O to 44.1kHz
14758 */
14759 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14760 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014761 } else if (spec->dual_adc_switch) {
14762 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14763 /* switch ADC dynamically */
14764 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014765 } else {
14766 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14767 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14768 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014769 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14770 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14771
Takashi Iwai66946352010-03-29 17:21:45 +020014772 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14773 if (!is_alc269vb) {
14774 spec->adc_nids = alc269_adc_nids;
14775 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14776 spec->capsrc_nids = alc269_capsrc_nids;
14777 } else {
14778 spec->adc_nids = alc269vb_adc_nids;
14779 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14780 spec->capsrc_nids = alc269vb_capsrc_nids;
14781 }
Kailang Yang84898e82010-02-04 14:16:14 +010014782 }
14783
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014784 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014785 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014786 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010014787 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014788
Takashi Iwaiff818c22010-04-12 08:59:25 +020014789 if (board_config == ALC269_AUTO)
14790 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
14791
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014792 spec->vmaster_nid = 0x02;
14793
Kailang Yangf6a92242007-12-13 16:52:54 +010014794 codec->patch_ops = alc_patch_ops;
14795 if (board_config == ALC269_AUTO)
14796 spec->init_hook = alc269_auto_init;
14797#ifdef CONFIG_SND_HDA_POWER_SAVE
14798 if (!spec->loopback.amplist)
14799 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020014800 if (alc269_mic2_for_mute_led(codec))
14801 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010014802#endif
14803
14804 return 0;
14805}
14806
14807/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014808 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14809 */
14810
14811/*
14812 * set the path ways for 2 channel output
14813 * need to set the codec line out and mic 1 pin widgets to inputs
14814 */
14815static struct hda_verb alc861_threestack_ch2_init[] = {
14816 /* set pin widget 1Ah (line in) for input */
14817 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014818 /* set pin widget 18h (mic1/2) for input, for mic also enable
14819 * the vref
14820 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014821 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14822
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014823 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14824#if 0
14825 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14826 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14827#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014828 { } /* end */
14829};
14830/*
14831 * 6ch mode
14832 * need to set the codec line out and mic 1 pin widgets to outputs
14833 */
14834static struct hda_verb alc861_threestack_ch6_init[] = {
14835 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14836 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14837 /* set pin widget 18h (mic1) for output (CLFE)*/
14838 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14839
14840 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014841 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014842
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014843 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14844#if 0
14845 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14846 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14847#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014848 { } /* end */
14849};
14850
14851static struct hda_channel_mode alc861_threestack_modes[2] = {
14852 { 2, alc861_threestack_ch2_init },
14853 { 6, alc861_threestack_ch6_init },
14854};
Takashi Iwai22309c32006-08-09 16:57:28 +020014855/* Set mic1 as input and unmute the mixer */
14856static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14857 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14858 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14859 { } /* end */
14860};
14861/* Set mic1 as output and mute mixer */
14862static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14863 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14864 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14865 { } /* end */
14866};
14867
14868static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14869 { 2, alc861_uniwill_m31_ch2_init },
14870 { 4, alc861_uniwill_m31_ch4_init },
14871};
Kailang Yangdf694da2005-12-05 19:42:22 +010014872
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014873/* Set mic1 and line-in as input and unmute the mixer */
14874static struct hda_verb alc861_asus_ch2_init[] = {
14875 /* set pin widget 1Ah (line in) for input */
14876 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014877 /* set pin widget 18h (mic1/2) for input, for mic also enable
14878 * the vref
14879 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014880 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14881
14882 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14883#if 0
14884 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14885 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14886#endif
14887 { } /* end */
14888};
14889/* Set mic1 nad line-in as output and mute mixer */
14890static struct hda_verb alc861_asus_ch6_init[] = {
14891 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14892 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14893 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14894 /* set pin widget 18h (mic1) for output (CLFE)*/
14895 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14896 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14897 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14898 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14899
14900 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14901#if 0
14902 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14903 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14904#endif
14905 { } /* end */
14906};
14907
14908static struct hda_channel_mode alc861_asus_modes[2] = {
14909 { 2, alc861_asus_ch2_init },
14910 { 6, alc861_asus_ch6_init },
14911};
14912
Kailang Yangdf694da2005-12-05 19:42:22 +010014913/* patch-ALC861 */
14914
14915static struct snd_kcontrol_new alc861_base_mixer[] = {
14916 /* output mixer control */
14917 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14918 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14919 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14920 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14921 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14922
14923 /*Input mixer control */
14924 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14925 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14926 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14927 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14928 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14929 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14931 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14932 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14933 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014934
Kailang Yangdf694da2005-12-05 19:42:22 +010014935 { } /* end */
14936};
14937
14938static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14939 /* output mixer control */
14940 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14941 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14942 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14943 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14944 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14945
14946 /* Input mixer control */
14947 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14948 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14949 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14950 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14951 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14952 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14954 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14955 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014957
Kailang Yangdf694da2005-12-05 19:42:22 +010014958 {
14959 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14960 .name = "Channel Mode",
14961 .info = alc_ch_mode_info,
14962 .get = alc_ch_mode_get,
14963 .put = alc_ch_mode_put,
14964 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14965 },
14966 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014967};
14968
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014969static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014970 /* output mixer control */
14971 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14972 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14973 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014974
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014975 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014976};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014977
Takashi Iwai22309c32006-08-09 16:57:28 +020014978static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14979 /* output mixer control */
14980 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14981 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14982 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14983 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14984 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14985
14986 /* Input mixer control */
14987 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14988 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14989 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14990 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14991 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14992 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14994 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14996 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014997
Takashi Iwai22309c32006-08-09 16:57:28 +020014998 {
14999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15000 .name = "Channel Mode",
15001 .info = alc_ch_mode_info,
15002 .get = alc_ch_mode_get,
15003 .put = alc_ch_mode_put,
15004 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15005 },
15006 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015007};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015008
15009static struct snd_kcontrol_new alc861_asus_mixer[] = {
15010 /* output mixer control */
15011 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15012 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15013 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15014 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15015 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15016
15017 /* Input mixer control */
15018 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15019 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15020 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15021 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15022 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15023 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15025 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15026 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015027 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15028
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015029 {
15030 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15031 .name = "Channel Mode",
15032 .info = alc_ch_mode_info,
15033 .get = alc_ch_mode_get,
15034 .put = alc_ch_mode_put,
15035 .private_value = ARRAY_SIZE(alc861_asus_modes),
15036 },
15037 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015038};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015039
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015040/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015041static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015042 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15043 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015044 { }
15045};
15046
Kailang Yangdf694da2005-12-05 19:42:22 +010015047/*
15048 * generic initialization of ADC, input mixers and output mixers
15049 */
15050static struct hda_verb alc861_base_init_verbs[] = {
15051 /*
15052 * Unmute ADC0 and set the default input to mic-in
15053 */
15054 /* port-A for surround (rear panel) */
15055 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15056 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15057 /* port-B for mic-in (rear panel) with vref */
15058 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15059 /* port-C for line-in (rear panel) */
15060 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15061 /* port-D for Front */
15062 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15063 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15064 /* port-E for HP out (front panel) */
15065 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15066 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015067 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015068 /* port-F for mic-in (front panel) with vref */
15069 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15070 /* port-G for CLFE (rear panel) */
15071 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15072 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15073 /* port-H for side (rear panel) */
15074 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15075 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15076 /* CD-in */
15077 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15078 /* route front mic to ADC1*/
15079 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15080 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015081
Kailang Yangdf694da2005-12-05 19:42:22 +010015082 /* Unmute DAC0~3 & spdif out*/
15083 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15084 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15085 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15086 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15087 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015088
Kailang Yangdf694da2005-12-05 19:42:22 +010015089 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15090 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15091 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15092 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15093 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015094
Kailang Yangdf694da2005-12-05 19:42:22 +010015095 /* Unmute Stereo Mixer 15 */
15096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15098 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015099 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015100
15101 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15102 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15103 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15104 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15105 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15106 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15107 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15108 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015109 /* hp used DAC 3 (Front) */
15110 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15112
15113 { }
15114};
15115
15116static struct hda_verb alc861_threestack_init_verbs[] = {
15117 /*
15118 * Unmute ADC0 and set the default input to mic-in
15119 */
15120 /* port-A for surround (rear panel) */
15121 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15122 /* port-B for mic-in (rear panel) with vref */
15123 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15124 /* port-C for line-in (rear panel) */
15125 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15126 /* port-D for Front */
15127 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15128 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15129 /* port-E for HP out (front panel) */
15130 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15131 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015132 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015133 /* port-F for mic-in (front panel) with vref */
15134 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15135 /* port-G for CLFE (rear panel) */
15136 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15137 /* port-H for side (rear panel) */
15138 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15139 /* CD-in */
15140 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15141 /* route front mic to ADC1*/
15142 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15143 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15144 /* Unmute DAC0~3 & spdif out*/
15145 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15146 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15147 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15148 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015150
Kailang Yangdf694da2005-12-05 19:42:22 +010015151 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15152 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15153 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15154 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15155 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015156
Kailang Yangdf694da2005-12-05 19:42:22 +010015157 /* Unmute Stereo Mixer 15 */
15158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15159 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15160 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015161 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015162
15163 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15164 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15165 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15166 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15167 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15168 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15169 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15170 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015171 /* hp used DAC 3 (Front) */
15172 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15174 { }
15175};
Takashi Iwai22309c32006-08-09 16:57:28 +020015176
15177static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15178 /*
15179 * Unmute ADC0 and set the default input to mic-in
15180 */
15181 /* port-A for surround (rear panel) */
15182 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15183 /* port-B for mic-in (rear panel) with vref */
15184 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15185 /* port-C for line-in (rear panel) */
15186 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15187 /* port-D for Front */
15188 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15189 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15190 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015191 /* this has to be set to VREF80 */
15192 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015193 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015194 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015195 /* port-F for mic-in (front panel) with vref */
15196 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15197 /* port-G for CLFE (rear panel) */
15198 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15199 /* port-H for side (rear panel) */
15200 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15201 /* CD-in */
15202 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15203 /* route front mic to ADC1*/
15204 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15205 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15206 /* Unmute DAC0~3 & spdif out*/
15207 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15209 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15210 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15211 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015212
Takashi Iwai22309c32006-08-09 16:57:28 +020015213 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15214 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15215 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15216 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15217 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015218
Takashi Iwai22309c32006-08-09 16:57:28 +020015219 /* Unmute Stereo Mixer 15 */
15220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15221 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015224
15225 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15226 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15227 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15228 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15229 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15230 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15231 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15232 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015233 /* hp used DAC 3 (Front) */
15234 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015235 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15236 { }
15237};
15238
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015239static struct hda_verb alc861_asus_init_verbs[] = {
15240 /*
15241 * Unmute ADC0 and set the default input to mic-in
15242 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015243 /* port-A for surround (rear panel)
15244 * according to codec#0 this is the HP jack
15245 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015246 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15247 /* route front PCM to HP */
15248 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15249 /* port-B for mic-in (rear panel) with vref */
15250 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15251 /* port-C for line-in (rear panel) */
15252 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15253 /* port-D for Front */
15254 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15255 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15256 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015257 /* this has to be set to VREF80 */
15258 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015259 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015260 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015261 /* port-F for mic-in (front panel) with vref */
15262 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15263 /* port-G for CLFE (rear panel) */
15264 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15265 /* port-H for side (rear panel) */
15266 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15267 /* CD-in */
15268 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15269 /* route front mic to ADC1*/
15270 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15272 /* Unmute DAC0~3 & spdif out*/
15273 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15274 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15275 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15276 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15277 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15278 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15279 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15280 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15281 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15282 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015283
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015284 /* Unmute Stereo Mixer 15 */
15285 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15286 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015289
15290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15292 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15294 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15295 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15296 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15297 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015298 /* hp used DAC 3 (Front) */
15299 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015300 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15301 { }
15302};
15303
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015304/* additional init verbs for ASUS laptops */
15305static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15306 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15307 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15308 { }
15309};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015310
Kailang Yangdf694da2005-12-05 19:42:22 +010015311/*
15312 * generic initialization of ADC, input mixers and output mixers
15313 */
15314static struct hda_verb alc861_auto_init_verbs[] = {
15315 /*
15316 * Unmute ADC0 and set the default input to mic-in
15317 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015318 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015320
Kailang Yangdf694da2005-12-05 19:42:22 +010015321 /* Unmute DAC0~3 & spdif out*/
15322 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15323 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15324 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15325 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015327
Kailang Yangdf694da2005-12-05 19:42:22 +010015328 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15329 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15330 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15331 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15332 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015333
Kailang Yangdf694da2005-12-05 19:42:22 +010015334 /* Unmute Stereo Mixer 15 */
15335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15337 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15339
Takashi Iwai1c209302009-07-22 15:17:45 +020015340 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15342 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15345 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15346 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15347 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015348
15349 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15350 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015351 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15352 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015353 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15354 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015355 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15356 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015357
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015358 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015359
15360 { }
15361};
15362
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015363static struct hda_verb alc861_toshiba_init_verbs[] = {
15364 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015365
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015366 { }
15367};
15368
15369/* toggle speaker-output according to the hp-jack state */
15370static void alc861_toshiba_automute(struct hda_codec *codec)
15371{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015372 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015373
Takashi Iwai47fd8302007-08-10 17:11:07 +020015374 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15375 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15376 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15377 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015378}
15379
15380static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15381 unsigned int res)
15382{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015383 if ((res >> 26) == ALC880_HP_EVENT)
15384 alc861_toshiba_automute(codec);
15385}
15386
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015387/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015388#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15389#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15390#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15391#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15392
15393
15394#define ALC861_DIGOUT_NID 0x07
15395
15396static struct hda_channel_mode alc861_8ch_modes[1] = {
15397 { 8, NULL }
15398};
15399
15400static hda_nid_t alc861_dac_nids[4] = {
15401 /* front, surround, clfe, side */
15402 0x03, 0x06, 0x05, 0x04
15403};
15404
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015405static hda_nid_t alc660_dac_nids[3] = {
15406 /* front, clfe, surround */
15407 0x03, 0x05, 0x06
15408};
15409
Kailang Yangdf694da2005-12-05 19:42:22 +010015410static hda_nid_t alc861_adc_nids[1] = {
15411 /* ADC0-2 */
15412 0x08,
15413};
15414
15415static struct hda_input_mux alc861_capture_source = {
15416 .num_items = 5,
15417 .items = {
15418 { "Mic", 0x0 },
15419 { "Front Mic", 0x3 },
15420 { "Line", 0x1 },
15421 { "CD", 0x4 },
15422 { "Mixer", 0x5 },
15423 },
15424};
15425
Takashi Iwai1c209302009-07-22 15:17:45 +020015426static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15427{
15428 struct alc_spec *spec = codec->spec;
15429 hda_nid_t mix, srcs[5];
15430 int i, j, num;
15431
15432 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15433 return 0;
15434 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15435 if (num < 0)
15436 return 0;
15437 for (i = 0; i < num; i++) {
15438 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015439 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015440 if (type != AC_WID_AUD_OUT)
15441 continue;
15442 for (j = 0; j < spec->multiout.num_dacs; j++)
15443 if (spec->multiout.dac_nids[j] == srcs[i])
15444 break;
15445 if (j >= spec->multiout.num_dacs)
15446 return srcs[i];
15447 }
15448 return 0;
15449}
15450
Kailang Yangdf694da2005-12-05 19:42:22 +010015451/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015452static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015453 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015454{
Takashi Iwai1c209302009-07-22 15:17:45 +020015455 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015456 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015457 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015458
15459 spec->multiout.dac_nids = spec->private_dac_nids;
15460 for (i = 0; i < cfg->line_outs; i++) {
15461 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015462 dac = alc861_look_for_dac(codec, nid);
15463 if (!dac)
15464 continue;
15465 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015466 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015467 return 0;
15468}
15469
Takashi Iwai1c209302009-07-22 15:17:45 +020015470static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15471 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015472{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015473 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015474 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15475}
15476
15477/* add playback controls from the parsed DAC table */
15478static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15479 const struct auto_pin_cfg *cfg)
15480{
15481 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015482 static const char *chname[4] = {
15483 "Front", "Surround", NULL /*CLFE*/, "Side"
15484 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015485 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015486 int i, err;
15487
15488 if (cfg->line_outs == 1) {
15489 const char *pfx = NULL;
15490 if (!cfg->hp_outs)
15491 pfx = "Master";
15492 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15493 pfx = "Speaker";
15494 if (pfx) {
15495 nid = spec->multiout.dac_nids[0];
15496 return alc861_create_out_sw(codec, pfx, nid, 3);
15497 }
15498 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015499
15500 for (i = 0; i < cfg->line_outs; i++) {
15501 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015502 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015503 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015504 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015505 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015506 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015507 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015508 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015509 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015510 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015511 return err;
15512 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015513 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015514 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015515 return err;
15516 }
15517 }
15518 return 0;
15519}
15520
Takashi Iwai1c209302009-07-22 15:17:45 +020015521static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015522{
Takashi Iwai1c209302009-07-22 15:17:45 +020015523 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015524 int err;
15525 hda_nid_t nid;
15526
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015527 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015528 return 0;
15529
15530 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015531 nid = alc861_look_for_dac(codec, pin);
15532 if (nid) {
15533 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15534 if (err < 0)
15535 return err;
15536 spec->multiout.hp_nid = nid;
15537 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015538 }
15539 return 0;
15540}
15541
15542/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015543static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015544 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015545{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015546 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015547}
15548
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015549static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15550 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015551 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015552{
Takashi Iwai1c209302009-07-22 15:17:45 +020015553 hda_nid_t mix, srcs[5];
15554 int i, num;
15555
Jacek Luczak564c5be2008-05-03 18:41:23 +020015556 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15557 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015558 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015559 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015560 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15561 return;
15562 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15563 if (num < 0)
15564 return;
15565 for (i = 0; i < num; i++) {
15566 unsigned int mute;
15567 if (srcs[i] == dac || srcs[i] == 0x15)
15568 mute = AMP_IN_UNMUTE(i);
15569 else
15570 mute = AMP_IN_MUTE(i);
15571 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15572 mute);
15573 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015574}
15575
15576static void alc861_auto_init_multi_out(struct hda_codec *codec)
15577{
15578 struct alc_spec *spec = codec->spec;
15579 int i;
15580
15581 for (i = 0; i < spec->autocfg.line_outs; i++) {
15582 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015583 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015584 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015585 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015586 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015587 }
15588}
15589
15590static void alc861_auto_init_hp_out(struct hda_codec *codec)
15591{
15592 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015593
Takashi Iwai15870f02009-10-05 08:25:13 +020015594 if (spec->autocfg.hp_outs)
15595 alc861_auto_set_output_and_unmute(codec,
15596 spec->autocfg.hp_pins[0],
15597 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015598 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015599 if (spec->autocfg.speaker_outs)
15600 alc861_auto_set_output_and_unmute(codec,
15601 spec->autocfg.speaker_pins[0],
15602 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015603 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015604}
15605
15606static void alc861_auto_init_analog_input(struct hda_codec *codec)
15607{
15608 struct alc_spec *spec = codec->spec;
15609 int i;
15610
15611 for (i = 0; i < AUTO_PIN_LAST; i++) {
15612 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010015613 if (nid >= 0x0c && nid <= 0x11)
15614 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015615 }
15616}
15617
15618/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015619/* return 1 if successful, 0 if the proper config is not found,
15620 * or a negative error code
15621 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015622static int alc861_parse_auto_config(struct hda_codec *codec)
15623{
15624 struct alc_spec *spec = codec->spec;
15625 int err;
15626 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15627
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015628 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15629 alc861_ignore);
15630 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015631 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015632 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015633 return 0; /* can't find valid BIOS pin config */
15634
Takashi Iwai1c209302009-07-22 15:17:45 +020015635 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015636 if (err < 0)
15637 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015638 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015639 if (err < 0)
15640 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015641 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015642 if (err < 0)
15643 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015644 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015645 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015646 return err;
15647
15648 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15649
Takashi Iwai757899a2010-07-30 10:48:14 +020015650 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015651
Takashi Iwai603c4012008-07-30 15:01:44 +020015652 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015653 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015654
Takashi Iwaid88897e2008-10-31 15:01:37 +010015655 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015656
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015657 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015658 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015659
15660 spec->adc_nids = alc861_adc_nids;
15661 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015662 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015663
Kailang Yang6227cdc2010-02-25 08:36:52 +010015664 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015665
Kailang Yangdf694da2005-12-05 19:42:22 +010015666 return 1;
15667}
15668
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015669/* additional initialization for auto-configuration model */
15670static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015671{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015672 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015673 alc861_auto_init_multi_out(codec);
15674 alc861_auto_init_hp_out(codec);
15675 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015676 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015677 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015678 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015679}
15680
Takashi Iwaicb53c622007-08-10 17:21:45 +020015681#ifdef CONFIG_SND_HDA_POWER_SAVE
15682static struct hda_amp_list alc861_loopbacks[] = {
15683 { 0x15, HDA_INPUT, 0 },
15684 { 0x15, HDA_INPUT, 1 },
15685 { 0x15, HDA_INPUT, 2 },
15686 { 0x15, HDA_INPUT, 3 },
15687 { } /* end */
15688};
15689#endif
15690
Kailang Yangdf694da2005-12-05 19:42:22 +010015691
15692/*
15693 * configuration and preset
15694 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015695static const char *alc861_models[ALC861_MODEL_LAST] = {
15696 [ALC861_3ST] = "3stack",
15697 [ALC660_3ST] = "3stack-660",
15698 [ALC861_3ST_DIG] = "3stack-dig",
15699 [ALC861_6ST_DIG] = "6stack-dig",
15700 [ALC861_UNIWILL_M31] = "uniwill-m31",
15701 [ALC861_TOSHIBA] = "toshiba",
15702 [ALC861_ASUS] = "asus",
15703 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15704 [ALC861_AUTO] = "auto",
15705};
15706
15707static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015708 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015709 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15710 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15711 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015712 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015713 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015714 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015715 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15716 * Any other models that need this preset?
15717 */
15718 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015719 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15720 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015721 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15722 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15723 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15724 /* FIXME: the below seems conflict */
15725 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15726 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15727 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015728 {}
15729};
15730
15731static struct alc_config_preset alc861_presets[] = {
15732 [ALC861_3ST] = {
15733 .mixers = { alc861_3ST_mixer },
15734 .init_verbs = { alc861_threestack_init_verbs },
15735 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15736 .dac_nids = alc861_dac_nids,
15737 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15738 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015739 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015740 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15741 .adc_nids = alc861_adc_nids,
15742 .input_mux = &alc861_capture_source,
15743 },
15744 [ALC861_3ST_DIG] = {
15745 .mixers = { alc861_base_mixer },
15746 .init_verbs = { alc861_threestack_init_verbs },
15747 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15748 .dac_nids = alc861_dac_nids,
15749 .dig_out_nid = ALC861_DIGOUT_NID,
15750 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15751 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015752 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015753 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15754 .adc_nids = alc861_adc_nids,
15755 .input_mux = &alc861_capture_source,
15756 },
15757 [ALC861_6ST_DIG] = {
15758 .mixers = { alc861_base_mixer },
15759 .init_verbs = { alc861_base_init_verbs },
15760 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15761 .dac_nids = alc861_dac_nids,
15762 .dig_out_nid = ALC861_DIGOUT_NID,
15763 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15764 .channel_mode = alc861_8ch_modes,
15765 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15766 .adc_nids = alc861_adc_nids,
15767 .input_mux = &alc861_capture_source,
15768 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015769 [ALC660_3ST] = {
15770 .mixers = { alc861_3ST_mixer },
15771 .init_verbs = { alc861_threestack_init_verbs },
15772 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15773 .dac_nids = alc660_dac_nids,
15774 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15775 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015776 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015777 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15778 .adc_nids = alc861_adc_nids,
15779 .input_mux = &alc861_capture_source,
15780 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015781 [ALC861_UNIWILL_M31] = {
15782 .mixers = { alc861_uniwill_m31_mixer },
15783 .init_verbs = { alc861_uniwill_m31_init_verbs },
15784 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15785 .dac_nids = alc861_dac_nids,
15786 .dig_out_nid = ALC861_DIGOUT_NID,
15787 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15788 .channel_mode = alc861_uniwill_m31_modes,
15789 .need_dac_fix = 1,
15790 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15791 .adc_nids = alc861_adc_nids,
15792 .input_mux = &alc861_capture_source,
15793 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015794 [ALC861_TOSHIBA] = {
15795 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015796 .init_verbs = { alc861_base_init_verbs,
15797 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015798 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15799 .dac_nids = alc861_dac_nids,
15800 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15801 .channel_mode = alc883_3ST_2ch_modes,
15802 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15803 .adc_nids = alc861_adc_nids,
15804 .input_mux = &alc861_capture_source,
15805 .unsol_event = alc861_toshiba_unsol_event,
15806 .init_hook = alc861_toshiba_automute,
15807 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015808 [ALC861_ASUS] = {
15809 .mixers = { alc861_asus_mixer },
15810 .init_verbs = { alc861_asus_init_verbs },
15811 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15812 .dac_nids = alc861_dac_nids,
15813 .dig_out_nid = ALC861_DIGOUT_NID,
15814 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15815 .channel_mode = alc861_asus_modes,
15816 .need_dac_fix = 1,
15817 .hp_nid = 0x06,
15818 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15819 .adc_nids = alc861_adc_nids,
15820 .input_mux = &alc861_capture_source,
15821 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015822 [ALC861_ASUS_LAPTOP] = {
15823 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15824 .init_verbs = { alc861_asus_init_verbs,
15825 alc861_asus_laptop_init_verbs },
15826 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15827 .dac_nids = alc861_dac_nids,
15828 .dig_out_nid = ALC861_DIGOUT_NID,
15829 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15830 .channel_mode = alc883_3ST_2ch_modes,
15831 .need_dac_fix = 1,
15832 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15833 .adc_nids = alc861_adc_nids,
15834 .input_mux = &alc861_capture_source,
15835 },
15836};
Kailang Yangdf694da2005-12-05 19:42:22 +010015837
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015838/* Pin config fixes */
15839enum {
15840 PINFIX_FSC_AMILO_PI1505,
15841};
15842
15843static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15844 { 0x0b, 0x0221101f }, /* HP */
15845 { 0x0f, 0x90170310 }, /* speaker */
15846 { }
15847};
15848
15849static const struct alc_fixup alc861_fixups[] = {
15850 [PINFIX_FSC_AMILO_PI1505] = {
15851 .pins = alc861_fsc_amilo_pi1505_pinfix
15852 },
15853};
15854
15855static struct snd_pci_quirk alc861_fixup_tbl[] = {
15856 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15857 {}
15858};
Kailang Yangdf694da2005-12-05 19:42:22 +010015859
15860static int patch_alc861(struct hda_codec *codec)
15861{
15862 struct alc_spec *spec;
15863 int board_config;
15864 int err;
15865
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015866 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015867 if (spec == NULL)
15868 return -ENOMEM;
15869
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015870 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015871
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015872 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15873 alc861_models,
15874 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015875
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015876 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015877 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15878 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015879 board_config = ALC861_AUTO;
15880 }
15881
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015882 if (board_config == ALC861_AUTO)
15883 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015884
Kailang Yangdf694da2005-12-05 19:42:22 +010015885 if (board_config == ALC861_AUTO) {
15886 /* automatic parse from the BIOS config */
15887 err = alc861_parse_auto_config(codec);
15888 if (err < 0) {
15889 alc_free(codec);
15890 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015891 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015892 printk(KERN_INFO
15893 "hda_codec: Cannot set up configuration "
15894 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015895 board_config = ALC861_3ST_DIG;
15896 }
15897 }
15898
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015899 err = snd_hda_attach_beep_device(codec, 0x23);
15900 if (err < 0) {
15901 alc_free(codec);
15902 return err;
15903 }
15904
Kailang Yangdf694da2005-12-05 19:42:22 +010015905 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015906 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015907
Kailang Yangdf694da2005-12-05 19:42:22 +010015908 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15909 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15910
Kailang Yangdf694da2005-12-05 19:42:22 +010015911 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15912 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15913
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015914 if (!spec->cap_mixer)
15915 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015916 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15917
Takashi Iwai2134ea42008-01-10 16:53:55 +010015918 spec->vmaster_nid = 0x03;
15919
Takashi Iwai7fa90e82010-04-12 08:49:00 +020015920 if (board_config == ALC861_AUTO)
15921 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
15922
Kailang Yangdf694da2005-12-05 19:42:22 +010015923 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015924 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015925 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015926#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015927 spec->power_hook = alc_power_eapd;
15928#endif
15929 }
15930#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015931 if (!spec->loopback.amplist)
15932 spec->loopback.amplist = alc861_loopbacks;
15933#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015934
Kailang Yangdf694da2005-12-05 19:42:22 +010015935 return 0;
15936}
15937
15938/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015939 * ALC861-VD support
15940 *
15941 * Based on ALC882
15942 *
15943 * In addition, an independent DAC
15944 */
15945#define ALC861VD_DIGOUT_NID 0x06
15946
15947static hda_nid_t alc861vd_dac_nids[4] = {
15948 /* front, surr, clfe, side surr */
15949 0x02, 0x03, 0x04, 0x05
15950};
15951
15952/* dac_nids for ALC660vd are in a different order - according to
15953 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015954 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015955 * of ALC660vd codecs, but for now there is only 3stack mixer
15956 * - and it is the same as in 861vd.
15957 * adc_nids in ALC660vd are (is) the same as in 861vd
15958 */
15959static hda_nid_t alc660vd_dac_nids[3] = {
15960 /* front, rear, clfe, rear_surr */
15961 0x02, 0x04, 0x03
15962};
15963
15964static hda_nid_t alc861vd_adc_nids[1] = {
15965 /* ADC0 */
15966 0x09,
15967};
15968
Takashi Iwaie1406342008-02-11 18:32:32 +010015969static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15970
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015971/* input MUX */
15972/* FIXME: should be a matrix-type input source selection */
15973static struct hda_input_mux alc861vd_capture_source = {
15974 .num_items = 4,
15975 .items = {
15976 { "Mic", 0x0 },
15977 { "Front Mic", 0x1 },
15978 { "Line", 0x2 },
15979 { "CD", 0x4 },
15980 },
15981};
15982
Kailang Yang272a5272007-05-14 11:00:38 +020015983static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015984 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015985 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015986 { "Ext Mic", 0x0 },
15987 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015988 },
15989};
15990
Kailang Yangd1a991a2007-08-15 16:21:59 +020015991static struct hda_input_mux alc861vd_hp_capture_source = {
15992 .num_items = 2,
15993 .items = {
15994 { "Front Mic", 0x0 },
15995 { "ATAPI Mic", 0x1 },
15996 },
15997};
15998
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015999/*
16000 * 2ch mode
16001 */
16002static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16003 { 2, NULL }
16004};
16005
16006/*
16007 * 6ch mode
16008 */
16009static struct hda_verb alc861vd_6stack_ch6_init[] = {
16010 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16011 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16012 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16013 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16014 { } /* end */
16015};
16016
16017/*
16018 * 8ch mode
16019 */
16020static struct hda_verb alc861vd_6stack_ch8_init[] = {
16021 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16022 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16023 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16024 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16025 { } /* end */
16026};
16027
16028static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16029 { 6, alc861vd_6stack_ch6_init },
16030 { 8, alc861vd_6stack_ch8_init },
16031};
16032
16033static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16034 {
16035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16036 .name = "Channel Mode",
16037 .info = alc_ch_mode_info,
16038 .get = alc_ch_mode_get,
16039 .put = alc_ch_mode_put,
16040 },
16041 { } /* end */
16042};
16043
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016044/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16045 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16046 */
16047static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16048 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16049 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16050
16051 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16052 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16053
16054 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16055 HDA_OUTPUT),
16056 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16057 HDA_OUTPUT),
16058 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16059 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16060
16061 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16062 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16063
16064 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16065
16066 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16067 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16068 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16069
16070 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16071 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16072 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16073
16074 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16075 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16076
16077 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16078 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16079
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016080 { } /* end */
16081};
16082
16083static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16084 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16085 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16086
16087 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16088
16089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16090 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16091 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16092
16093 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16094 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16095 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16096
16097 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16098 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16099
16100 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16101 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16102
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016103 { } /* end */
16104};
16105
Kailang Yangbdd148a2007-05-08 15:19:08 +020016106static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16107 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16108 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16109 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16110
16111 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16112
16113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16114 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16115 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16116
16117 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16118 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16119 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16120
16121 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16122 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16123
16124 { } /* end */
16125};
16126
Tobin Davisb419f342008-03-07 11:57:51 +010016127/* Pin assignment: Speaker=0x14, HP = 0x15,
16128 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016129 */
16130static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016131 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16132 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016133 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16134 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016135 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16136 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16137 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16138 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16139 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16140 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016141 { } /* end */
16142};
16143
Kailang Yangd1a991a2007-08-15 16:21:59 +020016144/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16145 * Front Mic=0x18, ATAPI Mic = 0x19,
16146 */
16147static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16148 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16149 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16150 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16151 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16152 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16153 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16154 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16155 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016156
Kailang Yangd1a991a2007-08-15 16:21:59 +020016157 { } /* end */
16158};
16159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016160/*
16161 * generic initialization of ADC, input mixers and output mixers
16162 */
16163static struct hda_verb alc861vd_volume_init_verbs[] = {
16164 /*
16165 * Unmute ADC0 and set the default input to mic-in
16166 */
16167 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16168 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16169
16170 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16171 * the analog-loopback mixer widget
16172 */
16173 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016174 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016179
16180 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016181 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16182 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16183 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016185
16186 /*
16187 * Set up output mixers (0x02 - 0x05)
16188 */
16189 /* set vol=0 to output mixers */
16190 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16191 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16192 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16193 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16194
16195 /* set up input amps for analog loopback */
16196 /* Amp Indices: DAC = 0, mixer = 1 */
16197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16199 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16203 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16204 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16205
16206 { }
16207};
16208
16209/*
16210 * 3-stack pin configuration:
16211 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16212 */
16213static struct hda_verb alc861vd_3stack_init_verbs[] = {
16214 /*
16215 * Set pin mode and muting
16216 */
16217 /* set front pin widgets 0x14 for output */
16218 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16219 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16220 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16221
16222 /* Mic (rear) pin: input vref at 80% */
16223 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16225 /* Front Mic pin: input vref at 80% */
16226 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16227 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16228 /* Line In pin: input */
16229 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16230 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16231 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16232 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16233 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16234 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16235 /* CD pin widget for input */
16236 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16237
16238 { }
16239};
16240
16241/*
16242 * 6-stack pin configuration:
16243 */
16244static struct hda_verb alc861vd_6stack_init_verbs[] = {
16245 /*
16246 * Set pin mode and muting
16247 */
16248 /* set front pin widgets 0x14 for output */
16249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16250 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16251 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16252
16253 /* Rear Pin: output 1 (0x0d) */
16254 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16255 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16256 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16257 /* CLFE Pin: output 2 (0x0e) */
16258 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16259 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16260 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16261 /* Side Pin: output 3 (0x0f) */
16262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16264 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16265
16266 /* Mic (rear) pin: input vref at 80% */
16267 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16268 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16269 /* Front Mic pin: input vref at 80% */
16270 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16271 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16272 /* Line In pin: input */
16273 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16274 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16275 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16277 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16278 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16279 /* CD pin widget for input */
16280 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16281
16282 { }
16283};
16284
Kailang Yangbdd148a2007-05-08 15:19:08 +020016285static struct hda_verb alc861vd_eapd_verbs[] = {
16286 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16287 { }
16288};
16289
Kailang Yangf9423e72008-05-27 12:32:25 +020016290static struct hda_verb alc660vd_eapd_verbs[] = {
16291 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16292 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16293 { }
16294};
16295
Kailang Yangbdd148a2007-05-08 15:19:08 +020016296static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16297 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16298 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16299 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16300 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016302 {}
16303};
16304
Kailang Yangbdd148a2007-05-08 15:19:08 +020016305static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16306{
16307 unsigned int present;
16308 unsigned char bits;
16309
Wu Fengguang864f92b2009-11-18 12:38:02 +080016310 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016311 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016312
Takashi Iwai47fd8302007-08-10 17:11:07 +020016313 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16314 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016315}
16316
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016317static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016318{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016319 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016320 spec->autocfg.hp_pins[0] = 0x1b;
16321 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016322}
16323
16324static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16325{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016326 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016327 alc861vd_lenovo_mic_automute(codec);
16328}
16329
16330static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16331 unsigned int res)
16332{
16333 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016334 case ALC880_MIC_EVENT:
16335 alc861vd_lenovo_mic_automute(codec);
16336 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016337 default:
16338 alc_automute_amp_unsol_event(codec, res);
16339 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016340 }
16341}
16342
Kailang Yang272a5272007-05-14 11:00:38 +020016343static struct hda_verb alc861vd_dallas_verbs[] = {
16344 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16345 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16346 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16347 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16348
16349 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16350 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16351 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16352 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16353 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16354 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16355 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16356 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016357
Kailang Yang272a5272007-05-14 11:00:38 +020016358 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16359 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16360 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16361 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16362 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16363 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16364 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16365 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16366
16367 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16368 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16369 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16370 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16371 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16372 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16373 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16374 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16375
16376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16380
16381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016382 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016383 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16384
16385 { } /* end */
16386};
16387
16388/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016389static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016390{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016391 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016392
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016393 spec->autocfg.hp_pins[0] = 0x15;
16394 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016395}
16396
Takashi Iwaicb53c622007-08-10 17:21:45 +020016397#ifdef CONFIG_SND_HDA_POWER_SAVE
16398#define alc861vd_loopbacks alc880_loopbacks
16399#endif
16400
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016401/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016402#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16403#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16404#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16405#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16406
16407/*
16408 * configuration and preset
16409 */
16410static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16411 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016412 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016413 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016414 [ALC861VD_3ST] = "3stack",
16415 [ALC861VD_3ST_DIG] = "3stack-digout",
16416 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016417 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016418 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016419 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016420 [ALC861VD_AUTO] = "auto",
16421};
16422
16423static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016424 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16425 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016426 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016427 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016428 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016429 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016430 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016431 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016432 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016433 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016434 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016435 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016436 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016437 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016438 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016439 {}
16440};
16441
16442static struct alc_config_preset alc861vd_presets[] = {
16443 [ALC660VD_3ST] = {
16444 .mixers = { alc861vd_3st_mixer },
16445 .init_verbs = { alc861vd_volume_init_verbs,
16446 alc861vd_3stack_init_verbs },
16447 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16448 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016449 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16450 .channel_mode = alc861vd_3stack_2ch_modes,
16451 .input_mux = &alc861vd_capture_source,
16452 },
Mike Crash6963f842007-06-25 12:12:51 +020016453 [ALC660VD_3ST_DIG] = {
16454 .mixers = { alc861vd_3st_mixer },
16455 .init_verbs = { alc861vd_volume_init_verbs,
16456 alc861vd_3stack_init_verbs },
16457 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16458 .dac_nids = alc660vd_dac_nids,
16459 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016460 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16461 .channel_mode = alc861vd_3stack_2ch_modes,
16462 .input_mux = &alc861vd_capture_source,
16463 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016464 [ALC861VD_3ST] = {
16465 .mixers = { alc861vd_3st_mixer },
16466 .init_verbs = { alc861vd_volume_init_verbs,
16467 alc861vd_3stack_init_verbs },
16468 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16469 .dac_nids = alc861vd_dac_nids,
16470 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16471 .channel_mode = alc861vd_3stack_2ch_modes,
16472 .input_mux = &alc861vd_capture_source,
16473 },
16474 [ALC861VD_3ST_DIG] = {
16475 .mixers = { alc861vd_3st_mixer },
16476 .init_verbs = { alc861vd_volume_init_verbs,
16477 alc861vd_3stack_init_verbs },
16478 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16479 .dac_nids = alc861vd_dac_nids,
16480 .dig_out_nid = ALC861VD_DIGOUT_NID,
16481 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16482 .channel_mode = alc861vd_3stack_2ch_modes,
16483 .input_mux = &alc861vd_capture_source,
16484 },
16485 [ALC861VD_6ST_DIG] = {
16486 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16487 .init_verbs = { alc861vd_volume_init_verbs,
16488 alc861vd_6stack_init_verbs },
16489 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16490 .dac_nids = alc861vd_dac_nids,
16491 .dig_out_nid = ALC861VD_DIGOUT_NID,
16492 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16493 .channel_mode = alc861vd_6stack_modes,
16494 .input_mux = &alc861vd_capture_source,
16495 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016496 [ALC861VD_LENOVO] = {
16497 .mixers = { alc861vd_lenovo_mixer },
16498 .init_verbs = { alc861vd_volume_init_verbs,
16499 alc861vd_3stack_init_verbs,
16500 alc861vd_eapd_verbs,
16501 alc861vd_lenovo_unsol_verbs },
16502 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16503 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016504 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16505 .channel_mode = alc861vd_3stack_2ch_modes,
16506 .input_mux = &alc861vd_capture_source,
16507 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016508 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016509 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016510 },
Kailang Yang272a5272007-05-14 11:00:38 +020016511 [ALC861VD_DALLAS] = {
16512 .mixers = { alc861vd_dallas_mixer },
16513 .init_verbs = { alc861vd_dallas_verbs },
16514 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16515 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016516 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16517 .channel_mode = alc861vd_3stack_2ch_modes,
16518 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016519 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016520 .setup = alc861vd_dallas_setup,
16521 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016522 },
16523 [ALC861VD_HP] = {
16524 .mixers = { alc861vd_hp_mixer },
16525 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16526 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16527 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016528 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016529 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16530 .channel_mode = alc861vd_3stack_2ch_modes,
16531 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016532 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016533 .setup = alc861vd_dallas_setup,
16534 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016535 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016536 [ALC660VD_ASUS_V1S] = {
16537 .mixers = { alc861vd_lenovo_mixer },
16538 .init_verbs = { alc861vd_volume_init_verbs,
16539 alc861vd_3stack_init_verbs,
16540 alc861vd_eapd_verbs,
16541 alc861vd_lenovo_unsol_verbs },
16542 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16543 .dac_nids = alc660vd_dac_nids,
16544 .dig_out_nid = ALC861VD_DIGOUT_NID,
16545 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16546 .channel_mode = alc861vd_3stack_2ch_modes,
16547 .input_mux = &alc861vd_capture_source,
16548 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016549 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016550 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016551 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016552};
16553
16554/*
16555 * BIOS auto configuration
16556 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016557static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16558 const struct auto_pin_cfg *cfg)
16559{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016560 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016561}
16562
16563
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016564static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16565 hda_nid_t nid, int pin_type, int dac_idx)
16566{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016567 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016568}
16569
16570static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16571{
16572 struct alc_spec *spec = codec->spec;
16573 int i;
16574
16575 for (i = 0; i <= HDA_SIDE; i++) {
16576 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016577 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016578 if (nid)
16579 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016580 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016581 }
16582}
16583
16584
16585static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16586{
16587 struct alc_spec *spec = codec->spec;
16588 hda_nid_t pin;
16589
16590 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016591 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016592 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016593 pin = spec->autocfg.speaker_pins[0];
16594 if (pin)
16595 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016596}
16597
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016598#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16599
16600static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16601{
16602 struct alc_spec *spec = codec->spec;
16603 int i;
16604
16605 for (i = 0; i < AUTO_PIN_LAST; i++) {
16606 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020016607 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016608 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016609 if (nid != ALC861VD_PIN_CD_NID &&
16610 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016611 snd_hda_codec_write(codec, nid, 0,
16612 AC_VERB_SET_AMP_GAIN_MUTE,
16613 AMP_OUT_MUTE);
16614 }
16615 }
16616}
16617
Takashi Iwaif511b012008-08-15 16:46:42 +020016618#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16619
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016620#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16621#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16622
16623/* add playback controls from the parsed DAC table */
16624/* Based on ALC880 version. But ALC861VD has separate,
16625 * different NIDs for mute/unmute switch and volume control */
16626static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16627 const struct auto_pin_cfg *cfg)
16628{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016629 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16630 hda_nid_t nid_v, nid_s;
16631 int i, err;
16632
16633 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016634 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016635 continue;
16636 nid_v = alc861vd_idx_to_mixer_vol(
16637 alc880_dac_to_idx(
16638 spec->multiout.dac_nids[i]));
16639 nid_s = alc861vd_idx_to_mixer_switch(
16640 alc880_dac_to_idx(
16641 spec->multiout.dac_nids[i]));
16642
16643 if (i == 2) {
16644 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016645 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16646 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016647 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16648 HDA_OUTPUT));
16649 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016650 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016651 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16652 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016653 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16654 HDA_OUTPUT));
16655 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016656 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016657 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16658 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016659 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16660 HDA_INPUT));
16661 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016662 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016663 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16664 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016665 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16666 HDA_INPUT));
16667 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016668 return err;
16669 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016670 const char *pfx;
16671 if (cfg->line_outs == 1 &&
16672 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16673 if (!cfg->hp_pins)
16674 pfx = "Speaker";
16675 else
16676 pfx = "PCM";
16677 } else
16678 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016679 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016680 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16681 HDA_OUTPUT));
16682 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016683 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016684 if (cfg->line_outs == 1 &&
16685 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16686 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016687 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016688 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016689 HDA_INPUT));
16690 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016691 return err;
16692 }
16693 }
16694 return 0;
16695}
16696
16697/* add playback controls for speaker and HP outputs */
16698/* Based on ALC880 version. But ALC861VD has separate,
16699 * different NIDs for mute/unmute switch and volume control */
16700static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16701 hda_nid_t pin, const char *pfx)
16702{
16703 hda_nid_t nid_v, nid_s;
16704 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016705
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016706 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016707 return 0;
16708
16709 if (alc880_is_fixed_pin(pin)) {
16710 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16711 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016712 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016713 spec->multiout.hp_nid = nid_v;
16714 else
16715 spec->multiout.extra_out_nid[0] = nid_v;
16716 /* control HP volume/switch on the output mixer amp */
16717 nid_v = alc861vd_idx_to_mixer_vol(
16718 alc880_fixed_pin_idx(pin));
16719 nid_s = alc861vd_idx_to_mixer_switch(
16720 alc880_fixed_pin_idx(pin));
16721
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016722 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016723 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16724 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016725 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016726 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016727 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16728 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016729 return err;
16730 } else if (alc880_is_multi_pin(pin)) {
16731 /* set manual connection */
16732 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016733 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016734 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16735 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016736 return err;
16737 }
16738 return 0;
16739}
16740
16741/* parse the BIOS configuration and set up the alc_spec
16742 * return 1 if successful, 0 if the proper config is not found,
16743 * or a negative error code
16744 * Based on ALC880 version - had to change it to override
16745 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16746static int alc861vd_parse_auto_config(struct hda_codec *codec)
16747{
16748 struct alc_spec *spec = codec->spec;
16749 int err;
16750 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16751
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016752 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16753 alc861vd_ignore);
16754 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016755 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016756 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016757 return 0; /* can't find valid BIOS pin config */
16758
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016759 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16760 if (err < 0)
16761 return err;
16762 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16763 if (err < 0)
16764 return err;
16765 err = alc861vd_auto_create_extra_out(spec,
16766 spec->autocfg.speaker_pins[0],
16767 "Speaker");
16768 if (err < 0)
16769 return err;
16770 err = alc861vd_auto_create_extra_out(spec,
16771 spec->autocfg.hp_pins[0],
16772 "Headphone");
16773 if (err < 0)
16774 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016775 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016776 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016777 return err;
16778
16779 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16780
Takashi Iwai757899a2010-07-30 10:48:14 +020016781 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016782
Takashi Iwai603c4012008-07-30 15:01:44 +020016783 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016784 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016785
Takashi Iwaid88897e2008-10-31 15:01:37 +010016786 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016787
16788 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016789 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016790
Takashi Iwai776e1842007-08-29 15:07:11 +020016791 err = alc_auto_add_mic_boost(codec);
16792 if (err < 0)
16793 return err;
16794
Kailang Yang6227cdc2010-02-25 08:36:52 +010016795 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016796
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016797 return 1;
16798}
16799
16800/* additional initialization for auto-configuration model */
16801static void alc861vd_auto_init(struct hda_codec *codec)
16802{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016803 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016804 alc861vd_auto_init_multi_out(codec);
16805 alc861vd_auto_init_hp_out(codec);
16806 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016807 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016808 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016809 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016810 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016811}
16812
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016813enum {
16814 ALC660VD_FIX_ASUS_GPIO1
16815};
16816
16817/* reset GPIO1 */
16818static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16819 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16820 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16821 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16822 { }
16823};
16824
16825static const struct alc_fixup alc861vd_fixups[] = {
16826 [ALC660VD_FIX_ASUS_GPIO1] = {
16827 .verbs = alc660vd_fix_asus_gpio1_verbs,
16828 },
16829};
16830
16831static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16832 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16833 {}
16834};
16835
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016836static int patch_alc861vd(struct hda_codec *codec)
16837{
16838 struct alc_spec *spec;
16839 int err, board_config;
16840
16841 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16842 if (spec == NULL)
16843 return -ENOMEM;
16844
16845 codec->spec = spec;
16846
16847 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16848 alc861vd_models,
16849 alc861vd_cfg_tbl);
16850
16851 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016852 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16853 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016854 board_config = ALC861VD_AUTO;
16855 }
16856
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016857 if (board_config == ALC861VD_AUTO)
16858 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016859
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016860 if (board_config == ALC861VD_AUTO) {
16861 /* automatic parse from the BIOS config */
16862 err = alc861vd_parse_auto_config(codec);
16863 if (err < 0) {
16864 alc_free(codec);
16865 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016866 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016867 printk(KERN_INFO
16868 "hda_codec: Cannot set up configuration "
16869 "from BIOS. Using base mode...\n");
16870 board_config = ALC861VD_3ST;
16871 }
16872 }
16873
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016874 err = snd_hda_attach_beep_device(codec, 0x23);
16875 if (err < 0) {
16876 alc_free(codec);
16877 return err;
16878 }
16879
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016880 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016881 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016882
Kailang Yang2f893282008-05-27 12:14:47 +020016883 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016884 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016885 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016886 }
16887
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016888 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16889 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16890
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016891 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16892 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16893
Takashi Iwaidd704692009-08-11 08:45:11 +020016894 if (!spec->adc_nids) {
16895 spec->adc_nids = alc861vd_adc_nids;
16896 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16897 }
16898 if (!spec->capsrc_nids)
16899 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016900
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016901 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016902 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016903
Takashi Iwai2134ea42008-01-10 16:53:55 +010016904 spec->vmaster_nid = 0x02;
16905
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016906 if (board_config == ALC861VD_AUTO)
16907 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
16908
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016909 codec->patch_ops = alc_patch_ops;
16910
16911 if (board_config == ALC861VD_AUTO)
16912 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016913#ifdef CONFIG_SND_HDA_POWER_SAVE
16914 if (!spec->loopback.amplist)
16915 spec->loopback.amplist = alc861vd_loopbacks;
16916#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016917
16918 return 0;
16919}
16920
16921/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016922 * ALC662 support
16923 *
16924 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16925 * configuration. Each pin widget can choose any input DACs and a mixer.
16926 * Each ADC is connected from a mixer of all inputs. This makes possible
16927 * 6-channel independent captures.
16928 *
16929 * In addition, an independent DAC for the multi-playback (not used in this
16930 * driver yet).
16931 */
16932#define ALC662_DIGOUT_NID 0x06
16933#define ALC662_DIGIN_NID 0x0a
16934
16935static hda_nid_t alc662_dac_nids[4] = {
16936 /* front, rear, clfe, rear_surr */
16937 0x02, 0x03, 0x04
16938};
16939
Kailang Yang622e84c2009-04-21 07:39:04 +020016940static hda_nid_t alc272_dac_nids[2] = {
16941 0x02, 0x03
16942};
16943
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016944static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016945 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016946 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016947};
Takashi Iwaie1406342008-02-11 18:32:32 +010016948
Kailang Yang622e84c2009-04-21 07:39:04 +020016949static hda_nid_t alc272_adc_nids[1] = {
16950 /* ADC1-2 */
16951 0x08,
16952};
16953
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016954static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016955static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16956
Takashi Iwaie1406342008-02-11 18:32:32 +010016957
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016958/* input MUX */
16959/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016960static struct hda_input_mux alc662_capture_source = {
16961 .num_items = 4,
16962 .items = {
16963 { "Mic", 0x0 },
16964 { "Front Mic", 0x1 },
16965 { "Line", 0x2 },
16966 { "CD", 0x4 },
16967 },
16968};
16969
16970static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16971 .num_items = 2,
16972 .items = {
16973 { "Mic", 0x1 },
16974 { "Line", 0x2 },
16975 },
16976};
Kailang Yang291702f2007-10-16 14:28:03 +020016977
Kailang Yang6dda9f42008-05-27 12:05:31 +020016978static struct hda_input_mux alc663_capture_source = {
16979 .num_items = 3,
16980 .items = {
16981 { "Mic", 0x0 },
16982 { "Front Mic", 0x1 },
16983 { "Line", 0x2 },
16984 },
16985};
16986
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016987#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016988static struct hda_input_mux alc272_nc10_capture_source = {
16989 .num_items = 16,
16990 .items = {
16991 { "Autoselect Mic", 0x0 },
16992 { "Internal Mic", 0x1 },
16993 { "In-0x02", 0x2 },
16994 { "In-0x03", 0x3 },
16995 { "In-0x04", 0x4 },
16996 { "In-0x05", 0x5 },
16997 { "In-0x06", 0x6 },
16998 { "In-0x07", 0x7 },
16999 { "In-0x08", 0x8 },
17000 { "In-0x09", 0x9 },
17001 { "In-0x0a", 0x0a },
17002 { "In-0x0b", 0x0b },
17003 { "In-0x0c", 0x0c },
17004 { "In-0x0d", 0x0d },
17005 { "In-0x0e", 0x0e },
17006 { "In-0x0f", 0x0f },
17007 },
17008};
17009#endif
17010
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017011/*
17012 * 2ch mode
17013 */
17014static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17015 { 2, NULL }
17016};
17017
17018/*
17019 * 2ch mode
17020 */
17021static struct hda_verb alc662_3ST_ch2_init[] = {
17022 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17023 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17024 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17025 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17026 { } /* end */
17027};
17028
17029/*
17030 * 6ch mode
17031 */
17032static struct hda_verb alc662_3ST_ch6_init[] = {
17033 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17034 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17035 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17036 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17037 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17038 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17039 { } /* end */
17040};
17041
17042static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17043 { 2, alc662_3ST_ch2_init },
17044 { 6, alc662_3ST_ch6_init },
17045};
17046
17047/*
17048 * 2ch mode
17049 */
17050static struct hda_verb alc662_sixstack_ch6_init[] = {
17051 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17052 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17053 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17054 { } /* end */
17055};
17056
17057/*
17058 * 6ch mode
17059 */
17060static struct hda_verb alc662_sixstack_ch8_init[] = {
17061 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17062 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17063 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17064 { } /* end */
17065};
17066
17067static struct hda_channel_mode alc662_5stack_modes[2] = {
17068 { 2, alc662_sixstack_ch6_init },
17069 { 6, alc662_sixstack_ch8_init },
17070};
17071
17072/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17073 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17074 */
17075
17076static struct snd_kcontrol_new alc662_base_mixer[] = {
17077 /* output mixer control */
17078 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017079 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017080 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017081 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017082 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17083 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017084 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17085 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017086 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17087
17088 /*Input mixer control */
17089 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17090 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17091 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17092 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17093 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17094 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17095 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17096 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017097 { } /* end */
17098};
17099
17100static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17101 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017102 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17104 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17105 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17108 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17109 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017112 { } /* end */
17113};
17114
17115static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17116 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017117 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017118 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017119 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017120 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17121 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017122 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17123 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17125 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17126 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17127 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17128 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17129 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17130 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17131 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17132 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017133 { } /* end */
17134};
17135
17136static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17137 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17138 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017139 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17140 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017141 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17142 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17143 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17144 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17145 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017146 { } /* end */
17147};
17148
Kailang Yang291702f2007-10-16 14:28:03 +020017149static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017150 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17151 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017152
17153 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17154 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17155 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17156
17157 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17158 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17159 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17160 { } /* end */
17161};
17162
Kailang Yang8c427222008-01-10 13:03:59 +010017163static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017164 ALC262_HIPPO_MASTER_SWITCH,
17165 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017166 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017167 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17168 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017169 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17170 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17171 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17172 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17173 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17174 { } /* end */
17175};
17176
Kailang Yangf1d4e282008-08-26 14:03:29 +020017177static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17178 .ops = &snd_hda_bind_vol,
17179 .values = {
17180 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17181 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17182 0
17183 },
17184};
17185
17186static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17187 .ops = &snd_hda_bind_sw,
17188 .values = {
17189 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17190 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17191 0
17192 },
17193};
17194
Kailang Yang6dda9f42008-05-27 12:05:31 +020017195static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017196 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17197 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17199 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17200 { } /* end */
17201};
17202
17203static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17204 .ops = &snd_hda_bind_sw,
17205 .values = {
17206 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17207 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17208 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17209 0
17210 },
17211};
17212
17213static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17214 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17215 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17217 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17218 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17219 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17220
17221 { } /* end */
17222};
17223
17224static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17225 .ops = &snd_hda_bind_sw,
17226 .values = {
17227 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17228 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17229 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17230 0
17231 },
17232};
17233
17234static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17235 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17236 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17238 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17239 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17240 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17241 { } /* end */
17242};
17243
17244static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017245 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17246 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017247 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17250 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17251 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17252 { } /* end */
17253};
17254
17255static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17256 .ops = &snd_hda_bind_vol,
17257 .values = {
17258 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17259 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17260 0
17261 },
17262};
17263
17264static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17265 .ops = &snd_hda_bind_sw,
17266 .values = {
17267 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17268 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17269 0
17270 },
17271};
17272
17273static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17274 HDA_BIND_VOL("Master Playback Volume",
17275 &alc663_asus_two_bind_master_vol),
17276 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17277 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017278 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017281 { } /* end */
17282};
17283
17284static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17285 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17286 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17287 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17289 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17290 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017291 { } /* end */
17292};
17293
17294static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17295 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17296 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17297 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17298 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17299 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17300
17301 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17302 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17303 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17304 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17305 { } /* end */
17306};
17307
17308static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17309 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17310 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17312
17313 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17314 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17315 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17316 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17319 { } /* end */
17320};
17321
Kailang Yangebb83ee2009-12-17 12:23:00 +010017322static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17323 .ops = &snd_hda_bind_sw,
17324 .values = {
17325 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17326 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17327 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17328 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17329 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17330 0
17331 },
17332};
17333
17334static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17335 .ops = &snd_hda_bind_sw,
17336 .values = {
17337 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17338 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17339 0
17340 },
17341};
17342
17343static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17344 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17345 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17346 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17347 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17348 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17349 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17350 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17351 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17352 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17353 { } /* end */
17354};
17355
17356static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17357 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17358 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17359 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17360 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17361 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17364 { } /* end */
17365};
17366
17367
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017368static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17369 {
17370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17371 .name = "Channel Mode",
17372 .info = alc_ch_mode_info,
17373 .get = alc_ch_mode_get,
17374 .put = alc_ch_mode_put,
17375 },
17376 { } /* end */
17377};
17378
17379static struct hda_verb alc662_init_verbs[] = {
17380 /* ADC: mute amp left and right */
17381 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17382 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017383
Kailang Yangb60dd392007-09-20 12:50:29 +020017384 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17385 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17386 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17387 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17388 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17389 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017390
17391 /* Front Pin: output 0 (0x0c) */
17392 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17393 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17394
17395 /* Rear Pin: output 1 (0x0d) */
17396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17398
17399 /* CLFE Pin: output 2 (0x0e) */
17400 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17401 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17402
17403 /* Mic (rear) pin: input vref at 80% */
17404 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17405 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17406 /* Front Mic pin: input vref at 80% */
17407 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17408 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17409 /* Line In pin: input */
17410 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17411 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17412 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17413 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17415 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17416 /* CD pin widget for input */
17417 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17418
17419 /* FIXME: use matrix-type input source selection */
17420 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17421 /* Input mixer */
17422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017423 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017424
17425 /* always trun on EAPD */
17426 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17427 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17428
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017429 { }
17430};
17431
Kailang Yangcec27c82010-02-04 14:18:18 +010017432static struct hda_verb alc663_init_verbs[] = {
17433 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17434 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17435 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17436 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17437 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17439 { }
17440};
17441
17442static struct hda_verb alc272_init_verbs[] = {
17443 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17444 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17445 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17446 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17447 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17448 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17449 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17450 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17451 { }
17452};
17453
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017454static struct hda_verb alc662_sue_init_verbs[] = {
17455 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17456 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017457 {}
17458};
17459
17460static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17461 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17462 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17463 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017464};
17465
Kailang Yang8c427222008-01-10 13:03:59 +010017466/* Set Unsolicited Event*/
17467static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17468 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17469 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17470 {}
17471};
17472
Kailang Yang6dda9f42008-05-27 12:05:31 +020017473static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17475 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017476 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17477 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017478 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017481 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17482 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17483 {}
17484};
17485
Kailang Yangf1d4e282008-08-26 14:03:29 +020017486static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17487 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17488 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17489 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17490 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17491 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17492 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17493 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17494 {}
17495};
17496
17497static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17498 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17500 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17501 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17502 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17504 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17505 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17506 {}
17507};
17508
17509static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17510 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17512 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17515 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17516 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17517 {}
17518};
17519
17520static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17521 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17522 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17523 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17524 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17525 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17526 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17527 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17529 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17530 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17531 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17532 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17533 {}
17534};
17535
17536static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17537 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17539 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17540 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17541 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17542 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17543 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17544 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17545 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17546 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17547 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17548 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17549 {}
17550};
17551
Kailang Yang6dda9f42008-05-27 12:05:31 +020017552static struct hda_verb alc663_g71v_init_verbs[] = {
17553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17554 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17555 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17556
17557 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17558 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17559 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17560
17561 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17562 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17563 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17564 {}
17565};
17566
17567static struct hda_verb alc663_g50v_init_verbs[] = {
17568 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17569 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17570 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17571
17572 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17573 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17574 {}
17575};
17576
Kailang Yangf1d4e282008-08-26 14:03:29 +020017577static struct hda_verb alc662_ecs_init_verbs[] = {
17578 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17579 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17580 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17581 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17582 {}
17583};
17584
Kailang Yang622e84c2009-04-21 07:39:04 +020017585static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17586 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17587 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17588 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17590 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17591 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17592 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17593 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17595 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17596 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17597 {}
17598};
17599
17600static struct hda_verb alc272_dell_init_verbs[] = {
17601 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17602 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17604 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17605 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17606 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17607 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17608 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17609 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17610 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17611 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17612 {}
17613};
17614
Kailang Yangebb83ee2009-12-17 12:23:00 +010017615static struct hda_verb alc663_mode7_init_verbs[] = {
17616 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17617 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17618 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17619 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17620 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17622 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17623 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17624 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17625 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17626 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17627 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17628 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17629 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17630 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17631 {}
17632};
17633
17634static struct hda_verb alc663_mode8_init_verbs[] = {
17635 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17640 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17641 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17642 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17643 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17644 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17645 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17647 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17648 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17649 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17650 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17651 {}
17652};
17653
Kailang Yangf1d4e282008-08-26 14:03:29 +020017654static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17655 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17656 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17657 { } /* end */
17658};
17659
Kailang Yang622e84c2009-04-21 07:39:04 +020017660static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17661 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17662 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17663 { } /* end */
17664};
17665
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017666static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17667{
17668 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017669 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670
Wu Fengguang864f92b2009-11-18 12:38:02 +080017671 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017672 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017673
Takashi Iwai47fd8302007-08-10 17:11:07 +020017674 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17675 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017676}
17677
17678static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17679{
17680 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017681 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017682
Wu Fengguang864f92b2009-11-18 12:38:02 +080017683 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017684 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017685
Takashi Iwai47fd8302007-08-10 17:11:07 +020017686 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17687 HDA_AMP_MUTE, bits);
17688 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17689 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017690}
17691
17692static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17693 unsigned int res)
17694{
17695 if ((res >> 26) == ALC880_HP_EVENT)
17696 alc662_lenovo_101e_all_automute(codec);
17697 if ((res >> 26) == ALC880_FRONT_EVENT)
17698 alc662_lenovo_101e_ispeaker_automute(codec);
17699}
17700
Kailang Yang291702f2007-10-16 14:28:03 +020017701/* unsolicited event for HP jack sensing */
17702static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17703 unsigned int res)
17704{
Kailang Yang291702f2007-10-16 14:28:03 +020017705 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017706 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017707 else
17708 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017709}
17710
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017711static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017712{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017713 struct alc_spec *spec = codec->spec;
17714
17715 alc262_hippo1_setup(codec);
17716 spec->ext_mic.pin = 0x18;
17717 spec->ext_mic.mux_idx = 0;
17718 spec->int_mic.pin = 0x19;
17719 spec->int_mic.mux_idx = 1;
17720 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017721}
17722
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017723static void alc662_eeepc_inithook(struct hda_codec *codec)
17724{
17725 alc262_hippo_automute(codec);
17726 alc_mic_automute(codec);
17727}
17728
17729static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017730{
Takashi Iwai42171c12009-05-08 14:11:43 +020017731 struct alc_spec *spec = codec->spec;
17732
17733 spec->autocfg.hp_pins[0] = 0x14;
17734 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017735}
17736
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017737#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17738
Kailang Yang6dda9f42008-05-27 12:05:31 +020017739static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17740{
17741 unsigned int present;
17742 unsigned char bits;
17743
Wu Fengguang864f92b2009-11-18 12:38:02 +080017744 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017745 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017746 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017747 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017748 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017749 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017750}
17751
17752static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17753{
17754 unsigned int present;
17755 unsigned char bits;
17756
Wu Fengguang864f92b2009-11-18 12:38:02 +080017757 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017758 bits = present ? HDA_AMP_MUTE : 0;
17759 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017760 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017761 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017762 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017763 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017764 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017765 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017766 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017767}
17768
17769static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17770{
17771 unsigned int present;
17772 unsigned char bits;
17773
Wu Fengguang864f92b2009-11-18 12:38:02 +080017774 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017775 bits = present ? HDA_AMP_MUTE : 0;
17776 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017777 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017778 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017779 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017780 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017781 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017782 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017783 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017784}
17785
17786static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17787{
17788 unsigned int present;
17789 unsigned char bits;
17790
Wu Fengguang864f92b2009-11-18 12:38:02 +080017791 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017792 bits = present ? 0 : PIN_OUT;
17793 snd_hda_codec_write(codec, 0x14, 0,
17794 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17795}
17796
17797static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17798{
17799 unsigned int present1, present2;
17800
Wu Fengguang864f92b2009-11-18 12:38:02 +080017801 present1 = snd_hda_jack_detect(codec, 0x21);
17802 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017803
17804 if (present1 || present2) {
17805 snd_hda_codec_write_cache(codec, 0x14, 0,
17806 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17807 } else {
17808 snd_hda_codec_write_cache(codec, 0x14, 0,
17809 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17810 }
17811}
17812
17813static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17814{
17815 unsigned int present1, present2;
17816
Wu Fengguang864f92b2009-11-18 12:38:02 +080017817 present1 = snd_hda_jack_detect(codec, 0x1b);
17818 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017819
17820 if (present1 || present2) {
17821 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017822 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017823 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017824 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017825 } else {
17826 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017827 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017828 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017829 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017830 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017831}
17832
Kailang Yangebb83ee2009-12-17 12:23:00 +010017833static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17834{
17835 unsigned int present1, present2;
17836
17837 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17838 AC_VERB_GET_PIN_SENSE, 0)
17839 & AC_PINSENSE_PRESENCE;
17840 present2 = snd_hda_codec_read(codec, 0x21, 0,
17841 AC_VERB_GET_PIN_SENSE, 0)
17842 & AC_PINSENSE_PRESENCE;
17843
17844 if (present1 || present2) {
17845 snd_hda_codec_write_cache(codec, 0x14, 0,
17846 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17847 snd_hda_codec_write_cache(codec, 0x17, 0,
17848 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17849 } else {
17850 snd_hda_codec_write_cache(codec, 0x14, 0,
17851 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17852 snd_hda_codec_write_cache(codec, 0x17, 0,
17853 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17854 }
17855}
17856
17857static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17858{
17859 unsigned int present1, present2;
17860
17861 present1 = snd_hda_codec_read(codec, 0x21, 0,
17862 AC_VERB_GET_PIN_SENSE, 0)
17863 & AC_PINSENSE_PRESENCE;
17864 present2 = snd_hda_codec_read(codec, 0x15, 0,
17865 AC_VERB_GET_PIN_SENSE, 0)
17866 & AC_PINSENSE_PRESENCE;
17867
17868 if (present1 || present2) {
17869 snd_hda_codec_write_cache(codec, 0x14, 0,
17870 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17871 snd_hda_codec_write_cache(codec, 0x17, 0,
17872 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17873 } else {
17874 snd_hda_codec_write_cache(codec, 0x14, 0,
17875 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17876 snd_hda_codec_write_cache(codec, 0x17, 0,
17877 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17878 }
17879}
17880
Kailang Yang6dda9f42008-05-27 12:05:31 +020017881static void alc663_m51va_unsol_event(struct hda_codec *codec,
17882 unsigned int res)
17883{
17884 switch (res >> 26) {
17885 case ALC880_HP_EVENT:
17886 alc663_m51va_speaker_automute(codec);
17887 break;
17888 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017889 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017890 break;
17891 }
17892}
17893
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017894static void alc663_m51va_setup(struct hda_codec *codec)
17895{
17896 struct alc_spec *spec = codec->spec;
17897 spec->ext_mic.pin = 0x18;
17898 spec->ext_mic.mux_idx = 0;
17899 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017900 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017901 spec->auto_mic = 1;
17902}
17903
Kailang Yang6dda9f42008-05-27 12:05:31 +020017904static void alc663_m51va_inithook(struct hda_codec *codec)
17905{
17906 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017907 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017908}
17909
Kailang Yangf1d4e282008-08-26 14:03:29 +020017910/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017911#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017912
17913static void alc663_mode1_setup(struct hda_codec *codec)
17914{
17915 struct alc_spec *spec = codec->spec;
17916 spec->ext_mic.pin = 0x18;
17917 spec->ext_mic.mux_idx = 0;
17918 spec->int_mic.pin = 0x19;
17919 spec->int_mic.mux_idx = 1;
17920 spec->auto_mic = 1;
17921}
17922
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017923#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017924
Kailang Yangf1d4e282008-08-26 14:03:29 +020017925/* ***************** Mode2 ******************************/
17926static void alc662_mode2_unsol_event(struct hda_codec *codec,
17927 unsigned int res)
17928{
17929 switch (res >> 26) {
17930 case ALC880_HP_EVENT:
17931 alc662_f5z_speaker_automute(codec);
17932 break;
17933 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017934 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017935 break;
17936 }
17937}
17938
Kailang Yangebb83ee2009-12-17 12:23:00 +010017939#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017940
Kailang Yangf1d4e282008-08-26 14:03:29 +020017941static void alc662_mode2_inithook(struct hda_codec *codec)
17942{
17943 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017944 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017945}
17946/* ***************** Mode3 ******************************/
17947static void alc663_mode3_unsol_event(struct hda_codec *codec,
17948 unsigned int res)
17949{
17950 switch (res >> 26) {
17951 case ALC880_HP_EVENT:
17952 alc663_two_hp_m1_speaker_automute(codec);
17953 break;
17954 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017955 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017956 break;
17957 }
17958}
17959
Kailang Yangebb83ee2009-12-17 12:23:00 +010017960#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017961
Kailang Yangf1d4e282008-08-26 14:03:29 +020017962static void alc663_mode3_inithook(struct hda_codec *codec)
17963{
17964 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017965 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017966}
17967/* ***************** Mode4 ******************************/
17968static void alc663_mode4_unsol_event(struct hda_codec *codec,
17969 unsigned int res)
17970{
17971 switch (res >> 26) {
17972 case ALC880_HP_EVENT:
17973 alc663_21jd_two_speaker_automute(codec);
17974 break;
17975 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017976 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017977 break;
17978 }
17979}
17980
Kailang Yangebb83ee2009-12-17 12:23:00 +010017981#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017982
Kailang Yangf1d4e282008-08-26 14:03:29 +020017983static void alc663_mode4_inithook(struct hda_codec *codec)
17984{
17985 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017986 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017987}
17988/* ***************** Mode5 ******************************/
17989static void alc663_mode5_unsol_event(struct hda_codec *codec,
17990 unsigned int res)
17991{
17992 switch (res >> 26) {
17993 case ALC880_HP_EVENT:
17994 alc663_15jd_two_speaker_automute(codec);
17995 break;
17996 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017997 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017998 break;
17999 }
18000}
18001
Kailang Yangebb83ee2009-12-17 12:23:00 +010018002#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018003
Kailang Yangf1d4e282008-08-26 14:03:29 +020018004static void alc663_mode5_inithook(struct hda_codec *codec)
18005{
18006 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018007 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018008}
18009/* ***************** Mode6 ******************************/
18010static void alc663_mode6_unsol_event(struct hda_codec *codec,
18011 unsigned int res)
18012{
18013 switch (res >> 26) {
18014 case ALC880_HP_EVENT:
18015 alc663_two_hp_m2_speaker_automute(codec);
18016 break;
18017 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018018 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018019 break;
18020 }
18021}
18022
Kailang Yangebb83ee2009-12-17 12:23:00 +010018023#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018024
Kailang Yangf1d4e282008-08-26 14:03:29 +020018025static void alc663_mode6_inithook(struct hda_codec *codec)
18026{
18027 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018028 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018029}
18030
Kailang Yangebb83ee2009-12-17 12:23:00 +010018031/* ***************** Mode7 ******************************/
18032static void alc663_mode7_unsol_event(struct hda_codec *codec,
18033 unsigned int res)
18034{
18035 switch (res >> 26) {
18036 case ALC880_HP_EVENT:
18037 alc663_two_hp_m7_speaker_automute(codec);
18038 break;
18039 case ALC880_MIC_EVENT:
18040 alc_mic_automute(codec);
18041 break;
18042 }
18043}
18044
18045#define alc663_mode7_setup alc663_mode1_setup
18046
18047static void alc663_mode7_inithook(struct hda_codec *codec)
18048{
18049 alc663_two_hp_m7_speaker_automute(codec);
18050 alc_mic_automute(codec);
18051}
18052
18053/* ***************** Mode8 ******************************/
18054static void alc663_mode8_unsol_event(struct hda_codec *codec,
18055 unsigned int res)
18056{
18057 switch (res >> 26) {
18058 case ALC880_HP_EVENT:
18059 alc663_two_hp_m8_speaker_automute(codec);
18060 break;
18061 case ALC880_MIC_EVENT:
18062 alc_mic_automute(codec);
18063 break;
18064 }
18065}
18066
18067#define alc663_mode8_setup alc663_m51va_setup
18068
18069static void alc663_mode8_inithook(struct hda_codec *codec)
18070{
18071 alc663_two_hp_m8_speaker_automute(codec);
18072 alc_mic_automute(codec);
18073}
18074
Kailang Yang6dda9f42008-05-27 12:05:31 +020018075static void alc663_g71v_hp_automute(struct hda_codec *codec)
18076{
18077 unsigned int present;
18078 unsigned char bits;
18079
Wu Fengguang864f92b2009-11-18 12:38:02 +080018080 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018081 bits = present ? HDA_AMP_MUTE : 0;
18082 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18083 HDA_AMP_MUTE, bits);
18084 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18085 HDA_AMP_MUTE, bits);
18086}
18087
18088static void alc663_g71v_front_automute(struct hda_codec *codec)
18089{
18090 unsigned int present;
18091 unsigned char bits;
18092
Wu Fengguang864f92b2009-11-18 12:38:02 +080018093 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018094 bits = present ? HDA_AMP_MUTE : 0;
18095 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18096 HDA_AMP_MUTE, bits);
18097}
18098
18099static void alc663_g71v_unsol_event(struct hda_codec *codec,
18100 unsigned int res)
18101{
18102 switch (res >> 26) {
18103 case ALC880_HP_EVENT:
18104 alc663_g71v_hp_automute(codec);
18105 break;
18106 case ALC880_FRONT_EVENT:
18107 alc663_g71v_front_automute(codec);
18108 break;
18109 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018110 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018111 break;
18112 }
18113}
18114
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018115#define alc663_g71v_setup alc663_m51va_setup
18116
Kailang Yang6dda9f42008-05-27 12:05:31 +020018117static void alc663_g71v_inithook(struct hda_codec *codec)
18118{
18119 alc663_g71v_front_automute(codec);
18120 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018121 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018122}
18123
18124static void alc663_g50v_unsol_event(struct hda_codec *codec,
18125 unsigned int res)
18126{
18127 switch (res >> 26) {
18128 case ALC880_HP_EVENT:
18129 alc663_m51va_speaker_automute(codec);
18130 break;
18131 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018132 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018133 break;
18134 }
18135}
18136
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018137#define alc663_g50v_setup alc663_m51va_setup
18138
Kailang Yang6dda9f42008-05-27 12:05:31 +020018139static void alc663_g50v_inithook(struct hda_codec *codec)
18140{
18141 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018142 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018143}
18144
Kailang Yangf1d4e282008-08-26 14:03:29 +020018145static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18146 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018147 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018148
18149 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18150 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18151 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18152
18153 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18154 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18155 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18156 { } /* end */
18157};
18158
Chris Pockelé9541ba12009-05-12 08:08:53 +020018159static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18160 /* Master Playback automatically created from Speaker and Headphone */
18161 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18162 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18163 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18165
18166 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18167 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18168 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18169
18170 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18171 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18172 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18173 { } /* end */
18174};
18175
Takashi Iwaicb53c622007-08-10 17:21:45 +020018176#ifdef CONFIG_SND_HDA_POWER_SAVE
18177#define alc662_loopbacks alc880_loopbacks
18178#endif
18179
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018180
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018181/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018182#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18183#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18184#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18185#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18186
18187/*
18188 * configuration and preset
18189 */
18190static const char *alc662_models[ALC662_MODEL_LAST] = {
18191 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18192 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18193 [ALC662_3ST_6ch] = "3stack-6ch",
18194 [ALC662_5ST_DIG] = "6stack-dig",
18195 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018196 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018197 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018198 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018199 [ALC663_ASUS_M51VA] = "m51va",
18200 [ALC663_ASUS_G71V] = "g71v",
18201 [ALC663_ASUS_H13] = "h13",
18202 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018203 [ALC663_ASUS_MODE1] = "asus-mode1",
18204 [ALC662_ASUS_MODE2] = "asus-mode2",
18205 [ALC663_ASUS_MODE3] = "asus-mode3",
18206 [ALC663_ASUS_MODE4] = "asus-mode4",
18207 [ALC663_ASUS_MODE5] = "asus-mode5",
18208 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018209 [ALC663_ASUS_MODE7] = "asus-mode7",
18210 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018211 [ALC272_DELL] = "dell",
18212 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018213 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018214 [ALC662_AUTO] = "auto",
18215};
18216
18217static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018218 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018219 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18220 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018221 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18222 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018223 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018224 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18225 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18226 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18227 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018228 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18229 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018230 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018231 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18232 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18233 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18234 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18235 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018236 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018237 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18238 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018239 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18240 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18241 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18242 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018243 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018244 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18245 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18246 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018247 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18248 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18249 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18250 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018251 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018252 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18253 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018254 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018255 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18256 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18257 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018258 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018259 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018260 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18261 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018262 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18263 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18264 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018265 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018266 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18267 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018268 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018269 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018270 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018271 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18272 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18273 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018274 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018275 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18276 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018277 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018278 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018279 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018280 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018281 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18282 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018283 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018284 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018285 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18286 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018287 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018288 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018289 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018290 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018291 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018292 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018293 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18294 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018295 {}
18296};
18297
18298static struct alc_config_preset alc662_presets[] = {
18299 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018300 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018301 .init_verbs = { alc662_init_verbs },
18302 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18303 .dac_nids = alc662_dac_nids,
18304 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018305 .dig_in_nid = ALC662_DIGIN_NID,
18306 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18307 .channel_mode = alc662_3ST_2ch_modes,
18308 .input_mux = &alc662_capture_source,
18309 },
18310 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018311 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018312 .init_verbs = { alc662_init_verbs },
18313 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18314 .dac_nids = alc662_dac_nids,
18315 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018316 .dig_in_nid = ALC662_DIGIN_NID,
18317 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18318 .channel_mode = alc662_3ST_6ch_modes,
18319 .need_dac_fix = 1,
18320 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018321 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018322 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018323 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018324 .init_verbs = { alc662_init_verbs },
18325 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18326 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018327 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18328 .channel_mode = alc662_3ST_6ch_modes,
18329 .need_dac_fix = 1,
18330 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018331 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018332 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018333 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018334 .init_verbs = { alc662_init_verbs },
18335 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18336 .dac_nids = alc662_dac_nids,
18337 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018338 .dig_in_nid = ALC662_DIGIN_NID,
18339 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18340 .channel_mode = alc662_5stack_modes,
18341 .input_mux = &alc662_capture_source,
18342 },
18343 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018344 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018345 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18346 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18347 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018348 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18349 .channel_mode = alc662_3ST_2ch_modes,
18350 .input_mux = &alc662_lenovo_101e_capture_source,
18351 .unsol_event = alc662_lenovo_101e_unsol_event,
18352 .init_hook = alc662_lenovo_101e_all_automute,
18353 },
Kailang Yang291702f2007-10-16 14:28:03 +020018354 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018355 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018356 .init_verbs = { alc662_init_verbs,
18357 alc662_eeepc_sue_init_verbs },
18358 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18359 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018360 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18361 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018362 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018363 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018364 .init_hook = alc662_eeepc_inithook,
18365 },
Kailang Yang8c427222008-01-10 13:03:59 +010018366 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018367 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018368 alc662_chmode_mixer },
18369 .init_verbs = { alc662_init_verbs,
18370 alc662_eeepc_ep20_sue_init_verbs },
18371 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18372 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018373 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18374 .channel_mode = alc662_3ST_6ch_modes,
18375 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018376 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018377 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018378 .init_hook = alc662_eeepc_ep20_inithook,
18379 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018380 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018381 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018382 .init_verbs = { alc662_init_verbs,
18383 alc662_ecs_init_verbs },
18384 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18385 .dac_nids = alc662_dac_nids,
18386 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18387 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018388 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018389 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018390 .init_hook = alc662_eeepc_inithook,
18391 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018392 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018393 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018394 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18395 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18396 .dac_nids = alc662_dac_nids,
18397 .dig_out_nid = ALC662_DIGOUT_NID,
18398 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18399 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018400 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018401 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018402 .init_hook = alc663_m51va_inithook,
18403 },
18404 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018405 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018406 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18407 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18408 .dac_nids = alc662_dac_nids,
18409 .dig_out_nid = ALC662_DIGOUT_NID,
18410 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18411 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018412 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018413 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018414 .init_hook = alc663_g71v_inithook,
18415 },
18416 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018417 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018418 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18419 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18420 .dac_nids = alc662_dac_nids,
18421 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18422 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018423 .unsol_event = alc663_m51va_unsol_event,
18424 .init_hook = alc663_m51va_inithook,
18425 },
18426 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018427 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018428 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18429 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18430 .dac_nids = alc662_dac_nids,
18431 .dig_out_nid = ALC662_DIGOUT_NID,
18432 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18433 .channel_mode = alc662_3ST_6ch_modes,
18434 .input_mux = &alc663_capture_source,
18435 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018436 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018437 .init_hook = alc663_g50v_inithook,
18438 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018439 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018440 .mixers = { alc663_m51va_mixer },
18441 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018442 .init_verbs = { alc662_init_verbs,
18443 alc663_21jd_amic_init_verbs },
18444 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18445 .hp_nid = 0x03,
18446 .dac_nids = alc662_dac_nids,
18447 .dig_out_nid = ALC662_DIGOUT_NID,
18448 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18449 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018450 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018451 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018452 .init_hook = alc663_mode1_inithook,
18453 },
18454 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018455 .mixers = { alc662_1bjd_mixer },
18456 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018457 .init_verbs = { alc662_init_verbs,
18458 alc662_1bjd_amic_init_verbs },
18459 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18460 .dac_nids = alc662_dac_nids,
18461 .dig_out_nid = ALC662_DIGOUT_NID,
18462 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18463 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018464 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018465 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018466 .init_hook = alc662_mode2_inithook,
18467 },
18468 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018469 .mixers = { alc663_two_hp_m1_mixer },
18470 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018471 .init_verbs = { alc662_init_verbs,
18472 alc663_two_hp_amic_m1_init_verbs },
18473 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18474 .hp_nid = 0x03,
18475 .dac_nids = alc662_dac_nids,
18476 .dig_out_nid = ALC662_DIGOUT_NID,
18477 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18478 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018479 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018480 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018481 .init_hook = alc663_mode3_inithook,
18482 },
18483 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018484 .mixers = { alc663_asus_21jd_clfe_mixer },
18485 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018486 .init_verbs = { alc662_init_verbs,
18487 alc663_21jd_amic_init_verbs},
18488 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18489 .hp_nid = 0x03,
18490 .dac_nids = alc662_dac_nids,
18491 .dig_out_nid = ALC662_DIGOUT_NID,
18492 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18493 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018494 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018495 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018496 .init_hook = alc663_mode4_inithook,
18497 },
18498 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018499 .mixers = { alc663_asus_15jd_clfe_mixer },
18500 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018501 .init_verbs = { alc662_init_verbs,
18502 alc663_15jd_amic_init_verbs },
18503 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18504 .hp_nid = 0x03,
18505 .dac_nids = alc662_dac_nids,
18506 .dig_out_nid = ALC662_DIGOUT_NID,
18507 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18508 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018509 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018510 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018511 .init_hook = alc663_mode5_inithook,
18512 },
18513 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018514 .mixers = { alc663_two_hp_m2_mixer },
18515 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018516 .init_verbs = { alc662_init_verbs,
18517 alc663_two_hp_amic_m2_init_verbs },
18518 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18519 .hp_nid = 0x03,
18520 .dac_nids = alc662_dac_nids,
18521 .dig_out_nid = ALC662_DIGOUT_NID,
18522 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18523 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018524 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018525 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018526 .init_hook = alc663_mode6_inithook,
18527 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018528 [ALC663_ASUS_MODE7] = {
18529 .mixers = { alc663_mode7_mixer },
18530 .cap_mixer = alc662_auto_capture_mixer,
18531 .init_verbs = { alc662_init_verbs,
18532 alc663_mode7_init_verbs },
18533 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18534 .hp_nid = 0x03,
18535 .dac_nids = alc662_dac_nids,
18536 .dig_out_nid = ALC662_DIGOUT_NID,
18537 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18538 .channel_mode = alc662_3ST_2ch_modes,
18539 .unsol_event = alc663_mode7_unsol_event,
18540 .setup = alc663_mode7_setup,
18541 .init_hook = alc663_mode7_inithook,
18542 },
18543 [ALC663_ASUS_MODE8] = {
18544 .mixers = { alc663_mode8_mixer },
18545 .cap_mixer = alc662_auto_capture_mixer,
18546 .init_verbs = { alc662_init_verbs,
18547 alc663_mode8_init_verbs },
18548 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18549 .hp_nid = 0x03,
18550 .dac_nids = alc662_dac_nids,
18551 .dig_out_nid = ALC662_DIGOUT_NID,
18552 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18553 .channel_mode = alc662_3ST_2ch_modes,
18554 .unsol_event = alc663_mode8_unsol_event,
18555 .setup = alc663_mode8_setup,
18556 .init_hook = alc663_mode8_inithook,
18557 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018558 [ALC272_DELL] = {
18559 .mixers = { alc663_m51va_mixer },
18560 .cap_mixer = alc272_auto_capture_mixer,
18561 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18562 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18563 .dac_nids = alc662_dac_nids,
18564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18565 .adc_nids = alc272_adc_nids,
18566 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18567 .capsrc_nids = alc272_capsrc_nids,
18568 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018569 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018570 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018571 .init_hook = alc663_m51va_inithook,
18572 },
18573 [ALC272_DELL_ZM1] = {
18574 .mixers = { alc663_m51va_mixer },
18575 .cap_mixer = alc662_auto_capture_mixer,
18576 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18577 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18578 .dac_nids = alc662_dac_nids,
18579 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18580 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018581 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018582 .capsrc_nids = alc662_capsrc_nids,
18583 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018584 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018585 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018586 .init_hook = alc663_m51va_inithook,
18587 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018588 [ALC272_SAMSUNG_NC10] = {
18589 .mixers = { alc272_nc10_mixer },
18590 .init_verbs = { alc662_init_verbs,
18591 alc663_21jd_amic_init_verbs },
18592 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18593 .dac_nids = alc272_dac_nids,
18594 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18595 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018596 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018597 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018598 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018599 .init_hook = alc663_mode4_inithook,
18600 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018601};
18602
18603
18604/*
18605 * BIOS auto configuration
18606 */
18607
Takashi Iwai7085ec12009-10-02 09:03:58 +020018608/* convert from MIX nid to DAC */
18609static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18610{
18611 if (nid == 0x0f)
18612 return 0x02;
18613 else if (nid >= 0x0c && nid <= 0x0e)
18614 return nid - 0x0c + 0x02;
18615 else
18616 return 0;
18617}
18618
18619/* get MIX nid connected to the given pin targeted to DAC */
18620static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18621 hda_nid_t dac)
18622{
18623 hda_nid_t mix[4];
18624 int i, num;
18625
18626 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18627 for (i = 0; i < num; i++) {
18628 if (alc662_mix_to_dac(mix[i]) == dac)
18629 return mix[i];
18630 }
18631 return 0;
18632}
18633
18634/* look for an empty DAC slot */
18635static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18636{
18637 struct alc_spec *spec = codec->spec;
18638 hda_nid_t srcs[5];
18639 int i, j, num;
18640
18641 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18642 if (num < 0)
18643 return 0;
18644 for (i = 0; i < num; i++) {
18645 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18646 if (!nid)
18647 continue;
18648 for (j = 0; j < spec->multiout.num_dacs; j++)
18649 if (spec->multiout.dac_nids[j] == nid)
18650 break;
18651 if (j >= spec->multiout.num_dacs)
18652 return nid;
18653 }
18654 return 0;
18655}
18656
18657/* fill in the dac_nids table from the parsed pin configuration */
18658static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18659 const struct auto_pin_cfg *cfg)
18660{
18661 struct alc_spec *spec = codec->spec;
18662 int i;
18663 hda_nid_t dac;
18664
18665 spec->multiout.dac_nids = spec->private_dac_nids;
18666 for (i = 0; i < cfg->line_outs; i++) {
18667 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18668 if (!dac)
18669 continue;
18670 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18671 }
18672 return 0;
18673}
18674
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018675static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018676 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018677{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018678 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018679 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18680}
18681
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018682static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018683 hda_nid_t nid, unsigned int chs)
18684{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018685 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018686 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18687}
18688
18689#define alc662_add_stereo_vol(spec, pfx, nid) \
18690 alc662_add_vol_ctl(spec, pfx, nid, 3)
18691#define alc662_add_stereo_sw(spec, pfx, nid) \
18692 alc662_add_sw_ctl(spec, pfx, nid, 3)
18693
18694/* add playback controls from the parsed DAC table */
18695static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18696 const struct auto_pin_cfg *cfg)
18697{
18698 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018699 static const char *chname[4] = {
18700 "Front", "Surround", NULL /*CLFE*/, "Side"
18701 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018702 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018703 int i, err;
18704
18705 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018706 nid = spec->multiout.dac_nids[i];
18707 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018708 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018709 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18710 if (!mix)
18711 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018712 if (i == 2) {
18713 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018714 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018715 if (err < 0)
18716 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018717 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018718 if (err < 0)
18719 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018720 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018721 if (err < 0)
18722 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018723 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018724 if (err < 0)
18725 return err;
18726 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018727 const char *pfx;
18728 if (cfg->line_outs == 1 &&
18729 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018730 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018731 pfx = "Speaker";
18732 else
18733 pfx = "PCM";
18734 } else
18735 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018736 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018737 if (err < 0)
18738 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018739 if (cfg->line_outs == 1 &&
18740 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18741 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018742 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018743 if (err < 0)
18744 return err;
18745 }
18746 }
18747 return 0;
18748}
18749
18750/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018751/* return DAC nid if any new DAC is assigned */
18752static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018753 const char *pfx)
18754{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018755 struct alc_spec *spec = codec->spec;
18756 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018757 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018758
18759 if (!pin)
18760 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018761 nid = alc662_look_for_dac(codec, pin);
18762 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018763 /* the corresponding DAC is already occupied */
18764 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18765 return 0; /* no way */
18766 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018767 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018768 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18769 }
18770
18771 mix = alc662_dac_to_mix(codec, pin, nid);
18772 if (!mix)
18773 return 0;
18774 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18775 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018776 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018777 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18778 if (err < 0)
18779 return err;
18780 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018781}
18782
18783/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018784#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018785 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018786
18787static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18788 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018789 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018790{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018791 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020018792 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018793
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018794 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018795 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018796 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18797 if (num <= 1)
18798 return;
18799 for (i = 0; i < num; i++) {
18800 if (alc662_mix_to_dac(srcs[i]) != dac)
18801 continue;
18802 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18803 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018804 }
18805}
18806
18807static void alc662_auto_init_multi_out(struct hda_codec *codec)
18808{
18809 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018810 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018811 int i;
18812
18813 for (i = 0; i <= HDA_SIDE; i++) {
18814 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18815 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018816 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018817 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018818 }
18819}
18820
18821static void alc662_auto_init_hp_out(struct hda_codec *codec)
18822{
18823 struct alc_spec *spec = codec->spec;
18824 hda_nid_t pin;
18825
18826 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018827 if (pin)
18828 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18829 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018830 pin = spec->autocfg.speaker_pins[0];
18831 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018832 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18833 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018834}
18835
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018836#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18837
18838static void alc662_auto_init_analog_input(struct hda_codec *codec)
18839{
18840 struct alc_spec *spec = codec->spec;
18841 int i;
18842
18843 for (i = 0; i < AUTO_PIN_LAST; i++) {
18844 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018845 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018846 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018847 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018848 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018849 snd_hda_codec_write(codec, nid, 0,
18850 AC_VERB_SET_AMP_GAIN_MUTE,
18851 AMP_OUT_MUTE);
18852 }
18853 }
18854}
18855
Takashi Iwaif511b012008-08-15 16:46:42 +020018856#define alc662_auto_init_input_src alc882_auto_init_input_src
18857
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018858static int alc662_parse_auto_config(struct hda_codec *codec)
18859{
18860 struct alc_spec *spec = codec->spec;
18861 int err;
18862 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18863
18864 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18865 alc662_ignore);
18866 if (err < 0)
18867 return err;
18868 if (!spec->autocfg.line_outs)
18869 return 0; /* can't find valid BIOS pin config */
18870
Takashi Iwai7085ec12009-10-02 09:03:58 +020018871 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018872 if (err < 0)
18873 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018874 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018875 if (err < 0)
18876 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018877 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018878 spec->autocfg.speaker_pins[0],
18879 "Speaker");
18880 if (err < 0)
18881 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018882 if (err)
18883 spec->multiout.extra_out_nid[0] = err;
18884 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018885 "Headphone");
18886 if (err < 0)
18887 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018888 if (err)
18889 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018890 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018891 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018892 return err;
18893
18894 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18895
Takashi Iwai757899a2010-07-30 10:48:14 +020018896 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018897
Takashi Iwai603c4012008-07-30 15:01:44 +020018898 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018899 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018900
18901 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018902 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018903
Kailang Yangcec27c82010-02-04 14:18:18 +010018904 add_verb(spec, alc662_init_verbs);
18905 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020018906 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010018907 add_verb(spec, alc663_init_verbs);
18908
18909 if (codec->vendor_id == 0x10ec0272)
18910 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018911
18912 err = alc_auto_add_mic_boost(codec);
18913 if (err < 0)
18914 return err;
18915
Kailang Yang6227cdc2010-02-25 08:36:52 +010018916 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18917 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18918 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18919 else
18920 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018921
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018922 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018923}
18924
18925/* additional initialization for auto-configuration model */
18926static void alc662_auto_init(struct hda_codec *codec)
18927{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018928 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018929 alc662_auto_init_multi_out(codec);
18930 alc662_auto_init_hp_out(codec);
18931 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018932 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020018933 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018934 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018935 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018936}
18937
18938static int patch_alc662(struct hda_codec *codec)
18939{
18940 struct alc_spec *spec;
18941 int err, board_config;
18942
18943 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18944 if (!spec)
18945 return -ENOMEM;
18946
18947 codec->spec = spec;
18948
Kailang Yangda00c242010-03-19 11:23:45 +010018949 alc_auto_parse_customize_define(codec);
18950
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018951 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18952
Kailang Yangc027ddc2010-03-19 11:33:06 +010018953 if (alc_read_coef_idx(codec, 0) == 0x8020)
18954 alc_codec_rename(codec, "ALC661");
18955 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18956 codec->bus->pci->subsystem_vendor == 0x1025 &&
18957 spec->cdefine.platform_type == 1)
18958 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010018959
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018960 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18961 alc662_models,
18962 alc662_cfg_tbl);
18963 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018964 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18965 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018966 board_config = ALC662_AUTO;
18967 }
18968
18969 if (board_config == ALC662_AUTO) {
18970 /* automatic parse from the BIOS config */
18971 err = alc662_parse_auto_config(codec);
18972 if (err < 0) {
18973 alc_free(codec);
18974 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018975 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018976 printk(KERN_INFO
18977 "hda_codec: Cannot set up configuration "
18978 "from BIOS. Using base mode...\n");
18979 board_config = ALC662_3ST_2ch_DIG;
18980 }
18981 }
18982
Takashi Iwaidc1eae22010-07-29 15:30:02 +020018983 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020018984 err = snd_hda_attach_beep_device(codec, 0x1);
18985 if (err < 0) {
18986 alc_free(codec);
18987 return err;
18988 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018989 }
18990
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018991 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018992 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018993
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018994 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18995 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18996
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018997 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18998 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18999
Takashi Iwaidd704692009-08-11 08:45:11 +020019000 if (!spec->adc_nids) {
19001 spec->adc_nids = alc662_adc_nids;
19002 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19003 }
19004 if (!spec->capsrc_nids)
19005 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019006
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019007 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019008 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019009
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019010 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019011 switch (codec->vendor_id) {
19012 case 0x10ec0662:
19013 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19014 break;
19015 case 0x10ec0272:
19016 case 0x10ec0663:
19017 case 0x10ec0665:
19018 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19019 break;
19020 case 0x10ec0273:
19021 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19022 break;
19023 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019024 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019025 spec->vmaster_nid = 0x02;
19026
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019027 codec->patch_ops = alc_patch_ops;
19028 if (board_config == ALC662_AUTO)
19029 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020019030#ifdef CONFIG_SND_HDA_POWER_SAVE
19031 if (!spec->loopback.amplist)
19032 spec->loopback.amplist = alc662_loopbacks;
19033#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019034
19035 return 0;
19036}
19037
Kailang Yang274693f2009-12-03 10:07:50 +010019038static int patch_alc888(struct hda_codec *codec)
19039{
19040 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19041 kfree(codec->chip_name);
19042 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019043 if (!codec->chip_name) {
19044 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019045 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019046 }
19047 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019048 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019049 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019050}
19051
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019052/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019053 * ALC680 support
19054 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019055#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019056#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19057#define alc680_modes alc260_modes
19058
19059static hda_nid_t alc680_dac_nids[3] = {
19060 /* Lout1, Lout2, hp */
19061 0x02, 0x03, 0x04
19062};
19063
19064static hda_nid_t alc680_adc_nids[3] = {
19065 /* ADC0-2 */
19066 /* DMIC, MIC, Line-in*/
19067 0x07, 0x08, 0x09
19068};
19069
Kailang Yangc69aefa2010-08-17 10:39:22 +020019070/*
19071 * Analog capture ADC cgange
19072 */
19073static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19074 struct hda_codec *codec,
19075 unsigned int stream_tag,
19076 unsigned int format,
19077 struct snd_pcm_substream *substream)
19078{
19079 struct alc_spec *spec = codec->spec;
19080 struct auto_pin_cfg *cfg = &spec->autocfg;
19081 unsigned int pre_mic, pre_line;
19082
19083 pre_mic = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]);
19084 pre_line = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_LINE]);
19085
19086 spec->cur_adc_stream_tag = stream_tag;
19087 spec->cur_adc_format = format;
19088
19089 if (pre_mic || pre_line) {
19090 if (pre_mic)
19091 snd_hda_codec_setup_stream(codec, 0x08, stream_tag, 0,
19092 format);
19093 else
19094 snd_hda_codec_setup_stream(codec, 0x09, stream_tag, 0,
19095 format);
19096 } else
19097 snd_hda_codec_setup_stream(codec, 0x07, stream_tag, 0, format);
19098 return 0;
19099}
19100
19101static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19102 struct hda_codec *codec,
19103 struct snd_pcm_substream *substream)
19104{
19105 snd_hda_codec_cleanup_stream(codec, 0x07);
19106 snd_hda_codec_cleanup_stream(codec, 0x08);
19107 snd_hda_codec_cleanup_stream(codec, 0x09);
19108 return 0;
19109}
19110
19111static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19112 .substreams = 1, /* can be overridden */
19113 .channels_min = 2,
19114 .channels_max = 2,
19115 /* NID is set in alc_build_pcms */
19116 .ops = {
19117 .prepare = alc680_capture_pcm_prepare,
19118 .cleanup = alc680_capture_pcm_cleanup
19119 },
19120};
19121
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019122static struct snd_kcontrol_new alc680_base_mixer[] = {
19123 /* output mixer control */
19124 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19125 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19126 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019128 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019129 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019130 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019131 { }
19132};
19133
Kailang Yangc69aefa2010-08-17 10:39:22 +020019134static struct hda_bind_ctls alc680_bind_cap_vol = {
19135 .ops = &snd_hda_bind_vol,
19136 .values = {
19137 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19138 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19139 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19140 0
19141 },
19142};
19143
19144static struct hda_bind_ctls alc680_bind_cap_switch = {
19145 .ops = &snd_hda_bind_sw,
19146 .values = {
19147 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19148 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19149 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19150 0
19151 },
19152};
19153
19154static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19155 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19156 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019157 { } /* end */
19158};
19159
19160/*
19161 * generic initialization of ADC, input mixers and output mixers
19162 */
19163static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019164 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19165 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19166 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019167
Kailang Yangc69aefa2010-08-17 10:39:22 +020019168 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19169 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19172 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19173 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019174
19175 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19176 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19177 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19179 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019180
19181 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19182 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
19183
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019184 { }
19185};
19186
Kailang Yangc69aefa2010-08-17 10:39:22 +020019187/* toggle speaker-output according to the hp-jack state */
19188static void alc680_base_setup(struct hda_codec *codec)
19189{
19190 struct alc_spec *spec = codec->spec;
19191
19192 spec->autocfg.hp_pins[0] = 0x16;
19193 spec->autocfg.speaker_pins[0] = 0x14;
19194 spec->autocfg.speaker_pins[1] = 0x15;
19195 spec->autocfg.input_pins[AUTO_PIN_MIC] = 0x18;
19196 spec->autocfg.input_pins[AUTO_PIN_LINE] = 0x19;
19197}
19198
19199static void alc680_rec_autoswitch(struct hda_codec *codec)
19200{
19201 struct alc_spec *spec = codec->spec;
19202 struct auto_pin_cfg *cfg = &spec->autocfg;
19203 unsigned int present;
19204 hda_nid_t new_adc;
19205
19206 present = snd_hda_jack_detect(codec, cfg->input_pins[AUTO_PIN_MIC]);
19207
19208 new_adc = present ? 0x8 : 0x7;
19209 __snd_hda_codec_cleanup_stream(codec, !present ? 0x8 : 0x7, 1);
19210 snd_hda_codec_setup_stream(codec, new_adc,
19211 spec->cur_adc_stream_tag, 0,
19212 spec->cur_adc_format);
19213
19214}
19215
19216static void alc680_unsol_event(struct hda_codec *codec,
19217 unsigned int res)
19218{
19219 if ((res >> 26) == ALC880_HP_EVENT)
19220 alc_automute_amp(codec);
19221 if ((res >> 26) == ALC880_MIC_EVENT)
19222 alc680_rec_autoswitch(codec);
19223}
19224
19225static void alc680_inithook(struct hda_codec *codec)
19226{
19227 alc_automute_amp(codec);
19228 alc680_rec_autoswitch(codec);
19229}
19230
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019231/* create input playback/capture controls for the given pin */
19232static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19233 const char *ctlname, int idx)
19234{
19235 hda_nid_t dac;
19236 int err;
19237
19238 switch (nid) {
19239 case 0x14:
19240 dac = 0x02;
19241 break;
19242 case 0x15:
19243 dac = 0x03;
19244 break;
19245 case 0x16:
19246 dac = 0x04;
19247 break;
19248 default:
19249 return 0;
19250 }
19251 if (spec->multiout.dac_nids[0] != dac &&
19252 spec->multiout.dac_nids[1] != dac) {
19253 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19254 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19255 HDA_OUTPUT));
19256 if (err < 0)
19257 return err;
19258
19259 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19260 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19261
19262 if (err < 0)
19263 return err;
19264 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19265 }
19266
19267 return 0;
19268}
19269
19270/* add playback controls from the parsed DAC table */
19271static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19272 const struct auto_pin_cfg *cfg)
19273{
19274 hda_nid_t nid;
19275 int err;
19276
19277 spec->multiout.dac_nids = spec->private_dac_nids;
19278
19279 nid = cfg->line_out_pins[0];
19280 if (nid) {
19281 const char *name;
19282 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19283 name = "Speaker";
19284 else
19285 name = "Front";
19286 err = alc680_new_analog_output(spec, nid, name, 0);
19287 if (err < 0)
19288 return err;
19289 }
19290
19291 nid = cfg->speaker_pins[0];
19292 if (nid) {
19293 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19294 if (err < 0)
19295 return err;
19296 }
19297 nid = cfg->hp_pins[0];
19298 if (nid) {
19299 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19300 if (err < 0)
19301 return err;
19302 }
19303
19304 return 0;
19305}
19306
19307static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19308 hda_nid_t nid, int pin_type)
19309{
19310 alc_set_pin_output(codec, nid, pin_type);
19311}
19312
19313static void alc680_auto_init_multi_out(struct hda_codec *codec)
19314{
19315 struct alc_spec *spec = codec->spec;
19316 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19317 if (nid) {
19318 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19319 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19320 }
19321}
19322
19323static void alc680_auto_init_hp_out(struct hda_codec *codec)
19324{
19325 struct alc_spec *spec = codec->spec;
19326 hda_nid_t pin;
19327
19328 pin = spec->autocfg.hp_pins[0];
19329 if (pin)
19330 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19331 pin = spec->autocfg.speaker_pins[0];
19332 if (pin)
19333 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19334}
19335
19336/* pcm configuration: identical with ALC880 */
19337#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19338#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19339#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19340#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019341#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019342
19343/*
19344 * BIOS auto configuration
19345 */
19346static int alc680_parse_auto_config(struct hda_codec *codec)
19347{
19348 struct alc_spec *spec = codec->spec;
19349 int err;
19350 static hda_nid_t alc680_ignore[] = { 0 };
19351
19352 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19353 alc680_ignore);
19354 if (err < 0)
19355 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019356
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019357 if (!spec->autocfg.line_outs) {
19358 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19359 spec->multiout.max_channels = 2;
19360 spec->no_analog = 1;
19361 goto dig_only;
19362 }
19363 return 0; /* can't find valid BIOS pin config */
19364 }
19365 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19366 if (err < 0)
19367 return err;
19368
19369 spec->multiout.max_channels = 2;
19370
19371 dig_only:
19372 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019373 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019374 if (spec->kctls.list)
19375 add_mixer(spec, spec->kctls.list);
19376
19377 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019378
19379 err = alc_auto_add_mic_boost(codec);
19380 if (err < 0)
19381 return err;
19382
19383 return 1;
19384}
19385
19386#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19387
19388/* init callback for auto-configuration model -- overriding the default init */
19389static void alc680_auto_init(struct hda_codec *codec)
19390{
19391 struct alc_spec *spec = codec->spec;
19392 alc680_auto_init_multi_out(codec);
19393 alc680_auto_init_hp_out(codec);
19394 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019395 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019396 if (spec->unsol_event)
19397 alc_inithook(codec);
19398}
19399
19400/*
19401 * configuration and preset
19402 */
19403static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019404 [ALC680_BASE] = "base",
19405 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019406};
19407
19408static struct snd_pci_quirk alc680_cfg_tbl[] = {
19409 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19410 {}
19411};
19412
19413static struct alc_config_preset alc680_presets[] = {
19414 [ALC680_BASE] = {
19415 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019416 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019417 .init_verbs = { alc680_init_verbs },
19418 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19419 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019420 .dig_out_nid = ALC680_DIGOUT_NID,
19421 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19422 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019423 .unsol_event = alc680_unsol_event,
19424 .setup = alc680_base_setup,
19425 .init_hook = alc680_inithook,
19426
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019427 },
19428};
19429
19430static int patch_alc680(struct hda_codec *codec)
19431{
19432 struct alc_spec *spec;
19433 int board_config;
19434 int err;
19435
19436 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19437 if (spec == NULL)
19438 return -ENOMEM;
19439
19440 codec->spec = spec;
19441
19442 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19443 alc680_models,
19444 alc680_cfg_tbl);
19445
19446 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19447 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19448 codec->chip_name);
19449 board_config = ALC680_AUTO;
19450 }
19451
19452 if (board_config == ALC680_AUTO) {
19453 /* automatic parse from the BIOS config */
19454 err = alc680_parse_auto_config(codec);
19455 if (err < 0) {
19456 alc_free(codec);
19457 return err;
19458 } else if (!err) {
19459 printk(KERN_INFO
19460 "hda_codec: Cannot set up configuration "
19461 "from BIOS. Using base mode...\n");
19462 board_config = ALC680_BASE;
19463 }
19464 }
19465
19466 if (board_config != ALC680_AUTO)
19467 setup_preset(codec, &alc680_presets[board_config]);
19468
19469 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019470 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019471 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019472 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019473
19474 if (!spec->adc_nids) {
19475 spec->adc_nids = alc680_adc_nids;
19476 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19477 }
19478
19479 if (!spec->cap_mixer)
19480 set_capture_mixer(codec);
19481
19482 spec->vmaster_nid = 0x02;
19483
19484 codec->patch_ops = alc_patch_ops;
19485 if (board_config == ALC680_AUTO)
19486 spec->init_hook = alc680_auto_init;
19487
19488 return 0;
19489}
19490
19491/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019492 * patch entries
19493 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019494static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019495 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019496 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019497 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019498 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019499 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019500 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019501 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019502 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019503 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019504 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019505 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19506 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19507 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019508 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019509 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019510 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19511 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019512 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019513 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019514 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019515 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019516 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019517 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019518 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019519 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019520 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019521 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019522 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019523 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019524 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019525 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019526 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019527 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019528 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019529 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019530 {} /* terminator */
19531};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019532
19533MODULE_ALIAS("snd-hda-codec-id:10ec*");
19534
19535MODULE_LICENSE("GPL");
19536MODULE_DESCRIPTION("Realtek HD-audio codec");
19537
19538static struct hda_codec_preset_list realtek_list = {
19539 .preset = snd_hda_preset_realtek,
19540 .owner = THIS_MODULE,
19541};
19542
19543static int __init patch_realtek_init(void)
19544{
19545 return snd_hda_add_codec_preset(&realtek_list);
19546}
19547
19548static void __exit patch_realtek_exit(void)
19549{
19550 snd_hda_delete_codec_preset(&realtek_list);
19551}
19552
19553module_init(patch_realtek_init)
19554module_exit(patch_realtek_exit)