blob: 4ec57633af88efb14ce5a632d2dbf1c67d91b7cf [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 Yangf6a92242007-12-13 16:52:54 +0100140 ALC269_AUTO,
141 ALC269_MODEL_LAST /* last tag */
142};
143
Kailang Yangdf694da2005-12-05 19:42:22 +0100144/* ALC861 models */
145enum {
146 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200147 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100148 ALC861_3ST_DIG,
149 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200150 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200151 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200152 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100153 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100154 ALC861_AUTO,
155 ALC861_MODEL_LAST,
156};
157
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100158/* ALC861-VD models */
159enum {
160 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200161 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100162 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100163 ALC861VD_3ST,
164 ALC861VD_3ST_DIG,
165 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200166 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200167 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200168 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100169 ALC861VD_AUTO,
170 ALC861VD_MODEL_LAST,
171};
172
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200173/* ALC662 models */
174enum {
175 ALC662_3ST_2ch_DIG,
176 ALC662_3ST_6ch_DIG,
177 ALC662_3ST_6ch,
178 ALC662_5ST_DIG,
179 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200180 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100181 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200182 ALC663_ASUS_M51VA,
183 ALC663_ASUS_G71V,
184 ALC663_ASUS_H13,
185 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200186 ALC662_ECS,
187 ALC663_ASUS_MODE1,
188 ALC662_ASUS_MODE2,
189 ALC663_ASUS_MODE3,
190 ALC663_ASUS_MODE4,
191 ALC663_ASUS_MODE5,
192 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100193 ALC663_ASUS_MODE7,
194 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200195 ALC272_DELL,
196 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200197 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200198 ALC662_AUTO,
199 ALC662_MODEL_LAST,
200};
201
Kailang Yangdf694da2005-12-05 19:42:22 +0100202/* ALC882 models */
203enum {
204 ALC882_3ST_DIG,
205 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200206 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200207 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200208 ALC882_TARGA,
209 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200210 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100211 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800212 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200213 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200214 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100215 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200216 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800217 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200218 ALC883_3ST_2ch_DIG,
219 ALC883_3ST_6ch_DIG,
220 ALC883_3ST_6ch,
221 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200222 ALC883_TARGA_DIG,
223 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200224 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200225 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200226 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800227 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100228 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200229 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200230 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200231 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200232 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100233 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200234 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200235 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200236 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200237 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200238 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200239 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100240 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100241 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430242 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100243 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100244 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800245 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200246 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200247 ALC889A_INTEL,
248 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200249 ALC888_ASUS_M90V,
250 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200251 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100252 ALC1200_ASUS_P5Q,
Guido Günther3e1647c52009-06-05 00:47:26 +0200253 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200254 ALC882_AUTO,
255 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200256};
257
Kailang Yangdf694da2005-12-05 19:42:22 +0100258/* for GPIO Poll */
259#define GPIO_MASK 0x03
260
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200261/* extra amp-initialization sequence types */
262enum {
263 ALC_INIT_NONE,
264 ALC_INIT_DEFAULT,
265 ALC_INIT_GPIO1,
266 ALC_INIT_GPIO2,
267 ALC_INIT_GPIO3,
268};
269
Takashi Iwai6c819492009-08-10 18:47:44 +0200270struct alc_mic_route {
271 hda_nid_t pin;
272 unsigned char mux_idx;
273 unsigned char amix_idx;
274};
275
276#define MUX_IDX_UNDEF ((unsigned char)-1)
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278struct alc_spec {
279 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100280 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100282 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100283 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200285 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200286 * don't forget NULL
287 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200288 */
289 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200291 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 struct hda_pcm_stream *stream_analog_playback;
293 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100294 struct hda_pcm_stream *stream_analog_alt_playback;
295 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200297 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 struct hda_pcm_stream *stream_digital_playback;
299 struct hda_pcm_stream *stream_digital_capture;
300
301 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200302 struct hda_multi_out multiout; /* playback set-up
303 * max_channels, dacs must be set
304 * dig_out_nid and hp_nid are optional
305 */
Takashi Iwai63300792008-01-24 15:31:36 +0100306 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100307 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100308 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310 /* capture */
311 unsigned int num_adc_nids;
312 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100313 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200314 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
316 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200317 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 const struct hda_input_mux *input_mux;
319 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200320 struct alc_mic_route ext_mic;
321 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
323 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100324 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200326 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200327 int const_channel_count;
328 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100331 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200332
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200333 /* dynamic controls, init_verbs and input_mux */
334 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200335 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200336 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200337 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200338 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
339 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100340
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100341 /* hooks */
342 void (*init_hook)(struct hda_codec *codec);
343 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100344#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500345 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100346#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100347
Takashi Iwai834be882006-03-01 14:16:17 +0100348 /* for pin sensing */
349 unsigned int sense_updated: 1;
350 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100351 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200352 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200353
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100354 /* other flags */
355 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200356 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100357
Takashi Iwai2134ea42008-01-10 16:53:55 +0100358 /* for virtual master */
359 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200360#ifdef CONFIG_SND_HDA_POWER_SAVE
361 struct hda_loopback_check loopback;
362#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200363
364 /* for PLL fix */
365 hda_nid_t pll_nid;
366 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100367};
368
369/*
370 * configuration template - to be copied to the spec instance
371 */
372struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200373 struct snd_kcontrol_new *mixers[5]; /* should be identical size
374 * with spec
375 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100376 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100377 const struct hda_verb *init_verbs[5];
378 unsigned int num_dacs;
379 hda_nid_t *dac_nids;
380 hda_nid_t dig_out_nid; /* optional */
381 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800382 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100383 unsigned int num_adc_nids;
384 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100385 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100386 hda_nid_t dig_in_nid;
387 unsigned int num_channel_mode;
388 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200389 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200390 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200391 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100392 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100393 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200394 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100395 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200396#ifdef CONFIG_SND_HDA_POWER_SAVE
397 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500398 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200399#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400};
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
403/*
404 * input MUX handling
405 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200406static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
407 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408{
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200411 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
412 if (mux_idx >= spec->num_mux_defs)
413 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100414 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
415 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200416 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417}
418
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200419static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
420 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421{
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct alc_spec *spec = codec->spec;
424 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
425
426 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
427 return 0;
428}
429
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200430static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432{
433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
434 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100435 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100437 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100438 hda_nid_t nid = spec->capsrc_nids ?
439 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200440 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Takashi Iwaicd896c32008-11-18 12:36:33 +0100442 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
443 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100444 if (!imux->num_items && mux_idx > 0)
445 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100446
Takashi Iwaia22d5432009-07-27 12:54:26 +0200447 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200448 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100449 /* Matrix-mixer style (e.g. ALC882) */
450 unsigned int *cur_val = &spec->cur_mux[adc_idx];
451 unsigned int i, idx;
452
453 idx = ucontrol->value.enumerated.item[0];
454 if (idx >= imux->num_items)
455 idx = imux->num_items - 1;
456 if (*cur_val == idx)
457 return 0;
458 for (i = 0; i < imux->num_items; i++) {
459 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
460 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
461 imux->items[i].index,
462 HDA_AMP_MUTE, v);
463 }
464 *cur_val = idx;
465 return 1;
466 } else {
467 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100468 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100469 &spec->cur_mux[adc_idx]);
470 }
471}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473/*
474 * channel mode setting
475 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
477 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478{
479 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
480 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100481 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
482 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483}
484
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200485static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
486 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487{
488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
489 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100490 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200491 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200492 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493}
494
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200495static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
496 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
498 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
499 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200500 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
501 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200502 &spec->ext_channel_count);
503 if (err >= 0 && !spec->const_channel_count) {
504 spec->multiout.max_channels = spec->ext_channel_count;
505 if (spec->need_dac_fix)
506 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
507 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200508 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509}
510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100512 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200513 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100514 * being part of a format specifier. Maximum allowed length of a value is
515 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100516 *
517 * Note: some retasking pin complexes seem to ignore requests for input
518 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
519 * are requested. Therefore order this list so that this behaviour will not
520 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200521 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
522 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100524static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100525 "Mic 50pc bias", "Mic 80pc bias",
526 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100527};
528static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100529 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100530};
531/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200532 * in the pin being assumed to be exclusively an input or an output pin. In
533 * addition, "input" pins may or may not process the mic bias option
534 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
535 * accept requests for bias as of chip versions up to March 2006) and/or
536 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200538#define ALC_PIN_DIR_IN 0x00
539#define ALC_PIN_DIR_OUT 0x01
540#define ALC_PIN_DIR_INOUT 0x02
541#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
542#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100543
Kailang Yangea1fb292008-08-26 12:58:38 +0200544/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100545 * For each direction the minimum and maximum values are given.
546 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200547static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100548 { 0, 2 }, /* ALC_PIN_DIR_IN */
549 { 3, 4 }, /* ALC_PIN_DIR_OUT */
550 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200551 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
552 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553};
554#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
555#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
556#define alc_pin_mode_n_items(_dir) \
557 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
558
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200559static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562 unsigned int item_num = uinfo->value.enumerated.item;
563 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
564
565 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200566 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
568
569 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
570 item_num = alc_pin_mode_min(dir);
571 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200572 return 0;
573}
574
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200575static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
576 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200577{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100578 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200579 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
580 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200582 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200583 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
584 AC_VERB_GET_PIN_WIDGET_CONTROL,
585 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200586
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 /* Find enumerated value for current pinctl setting */
588 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200589 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100590 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200591 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592 return 0;
593}
594
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200595static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100597{
598 signed int change;
599 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
600 hda_nid_t nid = kcontrol->private_value & 0xffff;
601 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
602 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200603 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
604 AC_VERB_GET_PIN_WIDGET_CONTROL,
605 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200607 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100608 val = alc_pin_mode_min(dir);
609
610 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100611 if (change) {
612 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200613 snd_hda_codec_write_cache(codec, nid, 0,
614 AC_VERB_SET_PIN_WIDGET_CONTROL,
615 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100616
Kailang Yangea1fb292008-08-26 12:58:38 +0200617 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100618 * for the requested pin mode. Enum values of 2 or less are
619 * input modes.
620 *
621 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200622 * reduces noise slightly (particularly on input) so we'll
623 * do it. However, having both input and output buffers
624 * enabled simultaneously doesn't seem to be problematic if
625 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100626 */
627 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200628 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
629 HDA_AMP_MUTE, HDA_AMP_MUTE);
630 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
631 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100632 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200633 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
634 HDA_AMP_MUTE, HDA_AMP_MUTE);
635 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
636 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100637 }
638 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200639 return change;
640}
641
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100642#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200643 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100644 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645 .info = alc_pin_mode_info, \
646 .get = alc_pin_mode_get, \
647 .put = alc_pin_mode_put, \
648 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100649
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100650/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
651 * together using a mask with more than one bit set. This control is
652 * currently used only by the ALC260 test model. At this stage they are not
653 * needed for any "production" models.
654 */
655#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200656#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200657
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200658static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
659 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100660{
661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
662 hda_nid_t nid = kcontrol->private_value & 0xffff;
663 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
664 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200665 unsigned int val = snd_hda_codec_read(codec, nid, 0,
666 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100667
668 *valp = (val & mask) != 0;
669 return 0;
670}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200671static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100673{
674 signed int change;
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 hda_nid_t nid = kcontrol->private_value & 0xffff;
677 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
678 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200679 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
680 AC_VERB_GET_GPIO_DATA,
681 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100682
683 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200684 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
685 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100686 gpio_data &= ~mask;
687 else
688 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200689 snd_hda_codec_write_cache(codec, nid, 0,
690 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100691
692 return change;
693}
694#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
695 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100696 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100697 .info = alc_gpio_data_info, \
698 .get = alc_gpio_data_get, \
699 .put = alc_gpio_data_put, \
700 .private_value = nid | (mask<<16) }
701#endif /* CONFIG_SND_DEBUG */
702
Jonathan Woithe92621f12006-02-28 11:47:47 +0100703/* A switch control to allow the enabling of the digital IO pins on the
704 * ALC260. This is incredibly simplistic; the intention of this control is
705 * to provide something in the test model allowing digital outputs to be
706 * identified if present. If models are found which can utilise these
707 * outputs a more complete mixer control can be devised for those models if
708 * necessary.
709 */
710#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200711#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200712
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200713static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
714 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100715{
716 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
717 hda_nid_t nid = kcontrol->private_value & 0xffff;
718 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
719 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200720 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100721 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100722
723 *valp = (val & mask) != 0;
724 return 0;
725}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200726static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
727 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100728{
729 signed int change;
730 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
731 hda_nid_t nid = kcontrol->private_value & 0xffff;
732 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
733 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200734 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100735 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200736 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100737
738 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200739 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100740 if (val==0)
741 ctrl_data &= ~mask;
742 else
743 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200744 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
745 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100746
747 return change;
748}
749#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
750 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100751 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100752 .info = alc_spdif_ctrl_info, \
753 .get = alc_spdif_ctrl_get, \
754 .put = alc_spdif_ctrl_put, \
755 .private_value = nid | (mask<<16) }
756#endif /* CONFIG_SND_DEBUG */
757
Jonathan Woithef8225f62008-01-08 12:16:54 +0100758/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
759 * Again, this is only used in the ALC26x test models to help identify when
760 * the EAPD line must be asserted for features to work.
761 */
762#ifdef CONFIG_SND_DEBUG
763#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
764
765static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
767{
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long *valp = ucontrol->value.integer.value;
772 unsigned int val = snd_hda_codec_read(codec, nid, 0,
773 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
774
775 *valp = (val & mask) != 0;
776 return 0;
777}
778
779static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
780 struct snd_ctl_elem_value *ucontrol)
781{
782 int change;
783 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
784 hda_nid_t nid = kcontrol->private_value & 0xffff;
785 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
786 long val = *ucontrol->value.integer.value;
787 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
788 AC_VERB_GET_EAPD_BTLENABLE,
789 0x00);
790
791 /* Set/unset the masked control bit(s) as needed */
792 change = (!val ? 0 : mask) != (ctrl_data & mask);
793 if (!val)
794 ctrl_data &= ~mask;
795 else
796 ctrl_data |= mask;
797 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
798 ctrl_data);
799
800 return change;
801}
802
803#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
804 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100805 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100806 .info = alc_eapd_ctrl_info, \
807 .get = alc_eapd_ctrl_get, \
808 .put = alc_eapd_ctrl_put, \
809 .private_value = nid | (mask<<16) }
810#endif /* CONFIG_SND_DEBUG */
811
Kailang Yangdf694da2005-12-05 19:42:22 +0100812/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100813 * set up the input pin config (depending on the given auto-pin type)
814 */
815static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
816 int auto_pin_type)
817{
818 unsigned int val = PIN_IN;
819
820 if (auto_pin_type <= AUTO_PIN_FRONT_MIC) {
821 unsigned int pincap;
Takashi Iwai1327a322009-03-23 13:07:47 +0100822 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100823 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
824 if (pincap & AC_PINCAP_VREF_80)
825 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200826 else if (pincap & AC_PINCAP_VREF_50)
827 val = PIN_VREF50;
828 else if (pincap & AC_PINCAP_VREF_100)
829 val = PIN_VREF100;
830 else if (pincap & AC_PINCAP_VREF_GRD)
831 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100832 }
833 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
834}
835
836/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100837 */
838static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
839{
840 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
841 return;
842 spec->mixers[spec->num_mixers++] = mix;
843}
844
845static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
846{
847 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
848 return;
849 spec->init_verbs[spec->num_init_verbs++] = verb;
850}
851
852/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100853 * set up from the preset table
854 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200855static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200856 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100857{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200858 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100859 int i;
860
861 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100862 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100863 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200864 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
865 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100866 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200867
Kailang Yangdf694da2005-12-05 19:42:22 +0100868 spec->channel_mode = preset->channel_mode;
869 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200870 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200871 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100872
Hector Martin3b315d72009-06-02 10:54:19 +0200873 if (preset->const_channel_count)
874 spec->multiout.max_channels = preset->const_channel_count;
875 else
876 spec->multiout.max_channels = spec->channel_mode[0].channels;
877 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100878
879 spec->multiout.num_dacs = preset->num_dacs;
880 spec->multiout.dac_nids = preset->dac_nids;
881 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800882 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100883 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200884
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200885 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200886 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200887 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100888 spec->input_mux = preset->input_mux;
889
890 spec->num_adc_nids = preset->num_adc_nids;
891 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100892 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100893 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100894
895 spec->unsol_event = preset->unsol_event;
896 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200897#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100898 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200899 spec->loopback.amplist = preset->loopbacks;
900#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200901
902 if (preset->setup)
903 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100904}
905
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200906/* Enable GPIO mask and set output */
907static struct hda_verb alc_gpio1_init_verbs[] = {
908 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
909 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
910 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
911 { }
912};
913
914static struct hda_verb alc_gpio2_init_verbs[] = {
915 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
916 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
917 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
918 { }
919};
920
Kailang Yangbdd148a2007-05-08 15:19:08 +0200921static struct hda_verb alc_gpio3_init_verbs[] = {
922 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
923 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
924 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
925 { }
926};
927
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200928/*
929 * Fix hardware PLL issue
930 * On some codecs, the analog PLL gating control must be off while
931 * the default value is 1.
932 */
933static void alc_fix_pll(struct hda_codec *codec)
934{
935 struct alc_spec *spec = codec->spec;
936 unsigned int val;
937
938 if (!spec->pll_nid)
939 return;
940 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
941 spec->pll_coef_idx);
942 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
943 AC_VERB_GET_PROC_COEF, 0);
944 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
945 spec->pll_coef_idx);
946 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
947 val & ~(1 << spec->pll_coef_bit));
948}
949
950static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
951 unsigned int coef_idx, unsigned int coef_bit)
952{
953 struct alc_spec *spec = codec->spec;
954 spec->pll_nid = nid;
955 spec->pll_coef_idx = coef_idx;
956 spec->pll_coef_bit = coef_bit;
957 alc_fix_pll(codec);
958}
959
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200960static void alc_automute_pin(struct hda_codec *codec)
Kailang Yangc9b58002007-10-16 14:30:01 +0200961{
962 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200963 unsigned int nid = spec->autocfg.hp_pins[0];
964 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +0200965
Takashi Iwaiad87c642009-11-02 14:23:15 +0100966 if (!nid)
967 return;
Wu Fengguang864f92b2009-11-18 12:38:02 +0800968 spec->jack_present = snd_hda_jack_detect(codec, nid);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +0200969 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
970 nid = spec->autocfg.speaker_pins[i];
971 if (!nid)
972 break;
973 snd_hda_codec_write(codec, nid, 0,
974 AC_VERB_SET_PIN_WIDGET_CONTROL,
975 spec->jack_present ? 0 : PIN_OUT);
976 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200977}
978
Takashi Iwai6c819492009-08-10 18:47:44 +0200979static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
980 hda_nid_t nid)
981{
982 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
983 int i, nums;
984
985 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
986 for (i = 0; i < nums; i++)
987 if (conn[i] == nid)
988 return i;
989 return -1;
990}
991
Kailang Yang7fb0d782008-10-15 11:12:35 +0200992static void alc_mic_automute(struct hda_codec *codec)
993{
994 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +0200995 struct alc_mic_route *dead, *alive;
996 unsigned int present, type;
997 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200998
Takashi Iwaib59bdf32009-08-11 09:47:30 +0200999 if (!spec->auto_mic)
1000 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001001 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1002 return;
1003 if (snd_BUG_ON(!spec->adc_nids))
1004 return;
1005
1006 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1007
Wu Fengguang864f92b2009-11-18 12:38:02 +08001008 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001009 if (present) {
1010 alive = &spec->ext_mic;
1011 dead = &spec->int_mic;
1012 } else {
1013 alive = &spec->int_mic;
1014 dead = &spec->ext_mic;
1015 }
1016
Takashi Iwai6c819492009-08-10 18:47:44 +02001017 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1018 if (type == AC_WID_AUD_MIX) {
1019 /* Matrix-mixer style (e.g. ALC882) */
1020 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1021 alive->mux_idx,
1022 HDA_AMP_MUTE, 0);
1023 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1024 dead->mux_idx,
1025 HDA_AMP_MUTE, HDA_AMP_MUTE);
1026 } else {
1027 /* MUX style (e.g. ALC880) */
1028 snd_hda_codec_write_cache(codec, cap_nid, 0,
1029 AC_VERB_SET_CONNECT_SEL,
1030 alive->mux_idx);
1031 }
1032
1033 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001034}
1035
Kailang Yangc9b58002007-10-16 14:30:01 +02001036/* unsolicited event for HP jack sensing */
1037static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1038{
1039 if (codec->vendor_id == 0x10ec0880)
1040 res >>= 28;
1041 else
1042 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001043 switch (res) {
1044 case ALC880_HP_EVENT:
1045 alc_automute_pin(codec);
1046 break;
1047 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001048 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001049 break;
1050 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001051}
1052
1053static void alc_inithook(struct hda_codec *codec)
1054{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001055 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001056 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001057}
1058
Kailang Yangf9423e72008-05-27 12:32:25 +02001059/* additional initialization for ALC888 variants */
1060static void alc888_coef_init(struct hda_codec *codec)
1061{
1062 unsigned int tmp;
1063
1064 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1065 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1066 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001067 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001068 /* alc888S-VC */
1069 snd_hda_codec_read(codec, 0x20, 0,
1070 AC_VERB_SET_PROC_COEF, 0x830);
1071 else
1072 /* alc888-VB */
1073 snd_hda_codec_read(codec, 0x20, 0,
1074 AC_VERB_SET_PROC_COEF, 0x3030);
1075}
1076
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001077static void alc889_coef_init(struct hda_codec *codec)
1078{
1079 unsigned int tmp;
1080
1081 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1082 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1083 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1084 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1085}
1086
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001087/* turn on/off EAPD control (only if available) */
1088static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1089{
1090 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1091 return;
1092 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1093 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1094 on ? 2 : 0);
1095}
1096
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001097static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001098{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001099 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001100
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001101 switch (type) {
1102 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001103 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1104 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001105 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001106 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1107 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001108 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001109 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1110 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001111 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001112 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001113 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001114 set_eapd(codec, 0x0f, 1);
1115 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001116 break;
1117 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001118 case 0x10ec0267:
1119 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001120 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001121 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001122 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001123 case 0x10ec0660:
1124 case 0x10ec0662:
1125 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001126 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001127 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001128 set_eapd(codec, 0x14, 1);
1129 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001130 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001131 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001132 switch (codec->vendor_id) {
1133 case 0x10ec0260:
1134 snd_hda_codec_write(codec, 0x1a, 0,
1135 AC_VERB_SET_COEF_INDEX, 7);
1136 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1137 AC_VERB_GET_PROC_COEF, 0);
1138 snd_hda_codec_write(codec, 0x1a, 0,
1139 AC_VERB_SET_COEF_INDEX, 7);
1140 snd_hda_codec_write(codec, 0x1a, 0,
1141 AC_VERB_SET_PROC_COEF,
1142 tmp | 0x2010);
1143 break;
1144 case 0x10ec0262:
1145 case 0x10ec0880:
1146 case 0x10ec0882:
1147 case 0x10ec0883:
1148 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001149 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001150 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001151 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001152 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001153 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001154 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001155 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001156#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001157 case 0x10ec0267:
1158 case 0x10ec0268:
1159 snd_hda_codec_write(codec, 0x20, 0,
1160 AC_VERB_SET_COEF_INDEX, 7);
1161 tmp = snd_hda_codec_read(codec, 0x20, 0,
1162 AC_VERB_GET_PROC_COEF, 0);
1163 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001164 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001165 snd_hda_codec_write(codec, 0x20, 0,
1166 AC_VERB_SET_PROC_COEF,
1167 tmp | 0x3000);
1168 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001169#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001170 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001171 break;
1172 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001173}
Kailang Yangea1fb292008-08-26 12:58:38 +02001174
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001175static void alc_init_auto_hp(struct hda_codec *codec)
1176{
1177 struct alc_spec *spec = codec->spec;
1178
1179 if (!spec->autocfg.hp_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001180 return;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001181
Kailang Yangc9b58002007-10-16 14:30:01 +02001182 if (!spec->autocfg.speaker_pins[0]) {
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001183 if (spec->autocfg.line_out_pins[0] &&
1184 spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001185 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001186 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001187 else
1188 return;
1189 }
1190
Takashi Iwai2a2ed0d2009-04-28 13:01:26 +02001191 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1192 spec->autocfg.hp_pins[0]);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001193 snd_hda_codec_write_cache(codec, spec->autocfg.hp_pins[0], 0,
1194 AC_VERB_SET_UNSOLICITED_ENABLE,
1195 AC_USRSP_EN | ALC880_HP_EVENT);
1196 spec->unsol_event = alc_sku_unsol_event;
1197}
1198
Takashi Iwai6c819492009-08-10 18:47:44 +02001199static void alc_init_auto_mic(struct hda_codec *codec)
1200{
1201 struct alc_spec *spec = codec->spec;
1202 struct auto_pin_cfg *cfg = &spec->autocfg;
1203 hda_nid_t fixed, ext;
1204 int i;
1205
1206 /* there must be only two mic inputs exclusively */
1207 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++)
1208 if (cfg->input_pins[i])
1209 return;
1210
1211 fixed = ext = 0;
1212 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++) {
1213 hda_nid_t nid = cfg->input_pins[i];
1214 unsigned int defcfg;
1215 if (!nid)
1216 return;
1217 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1218 switch (get_defcfg_connect(defcfg)) {
1219 case AC_JACK_PORT_FIXED:
1220 if (fixed)
1221 return; /* already occupied */
1222 fixed = nid;
1223 break;
1224 case AC_JACK_PORT_COMPLEX:
1225 if (ext)
1226 return; /* already occupied */
1227 ext = nid;
1228 break;
1229 default:
1230 return; /* invalid entry */
1231 }
1232 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001233 if (!ext || !fixed)
1234 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001235 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1236 return; /* no unsol support */
1237 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1238 ext, fixed);
1239 spec->ext_mic.pin = ext;
1240 spec->int_mic.pin = fixed;
1241 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1242 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1243 spec->auto_mic = 1;
1244 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1245 AC_VERB_SET_UNSOLICITED_ENABLE,
1246 AC_USRSP_EN | ALC880_MIC_EVENT);
1247 spec->unsol_event = alc_sku_unsol_event;
1248}
1249
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001250/* check subsystem ID and set up device-specific initialization;
1251 * return 1 if initialized, 0 if invalid SSID
1252 */
1253/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1254 * 31 ~ 16 : Manufacture ID
1255 * 15 ~ 8 : SKU ID
1256 * 7 ~ 0 : Assembly ID
1257 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1258 */
1259static int alc_subsystem_id(struct hda_codec *codec,
1260 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001261 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001262{
1263 unsigned int ass, tmp, i;
1264 unsigned nid;
1265 struct alc_spec *spec = codec->spec;
1266
1267 ass = codec->subsystem_id & 0xffff;
1268 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1269 goto do_sku;
1270
1271 /* invalid SSID, check the special NID pin defcfg instead */
1272 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001273 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001274 * 29~21 : reserve
1275 * 20 : PCBEEP input
1276 * 19~16 : Check sum (15:1)
1277 * 15~1 : Custom
1278 * 0 : override
1279 */
1280 nid = 0x1d;
1281 if (codec->vendor_id == 0x10ec0260)
1282 nid = 0x17;
1283 ass = snd_hda_codec_get_pincfg(codec, nid);
1284 snd_printd("realtek: No valid SSID, "
1285 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001286 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001287 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001288 return 0;
1289 if ((ass >> 30) != 1) /* no physical connection */
1290 return 0;
1291
1292 /* check sum */
1293 tmp = 0;
1294 for (i = 1; i < 16; i++) {
1295 if ((ass >> i) & 1)
1296 tmp++;
1297 }
1298 if (((ass >> 16) & 0xf) != tmp)
1299 return 0;
1300do_sku:
1301 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1302 ass & 0xffff, codec->vendor_id);
1303 /*
1304 * 0 : override
1305 * 1 : Swap Jack
1306 * 2 : 0 --> Desktop, 1 --> Laptop
1307 * 3~5 : External Amplifier control
1308 * 7~6 : Reserved
1309 */
1310 tmp = (ass & 0x38) >> 3; /* external Amp control */
1311 switch (tmp) {
1312 case 1:
1313 spec->init_amp = ALC_INIT_GPIO1;
1314 break;
1315 case 3:
1316 spec->init_amp = ALC_INIT_GPIO2;
1317 break;
1318 case 7:
1319 spec->init_amp = ALC_INIT_GPIO3;
1320 break;
1321 case 5:
1322 spec->init_amp = ALC_INIT_DEFAULT;
1323 break;
1324 }
1325
1326 /* is laptop or Desktop and enable the function "Mute internal speaker
1327 * when the external headphone out jack is plugged"
1328 */
1329 if (!(ass & 0x8000))
1330 return 1;
1331 /*
1332 * 10~8 : Jack location
1333 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1334 * 14~13: Resvered
1335 * 15 : 1 --> enable the function "Mute internal speaker
1336 * when the external headphone out jack is plugged"
1337 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001339 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1341 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001342 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001343 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001344 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001345 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001346 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001347 else if (tmp == 3)
1348 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001349 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001350 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001351 for (i = 0; i < spec->autocfg.line_outs; i++)
1352 if (spec->autocfg.line_out_pins[i] == nid)
1353 return 1;
1354 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001355 }
1356
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001358 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359 return 1;
1360}
Kailang Yangea1fb292008-08-26 12:58:38 +02001361
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001363 hda_nid_t porta, hda_nid_t porte,
1364 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001365{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001366 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001367 struct alc_spec *spec = codec->spec;
1368 snd_printd("realtek: "
1369 "Enable default setup for auto mode as fallback\n");
1370 spec->init_amp = ALC_INIT_DEFAULT;
1371 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001372 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001373 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374}
1375
Takashi Iwai41e41f12005-06-08 14:48:49 +02001376/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001377 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001378 */
1379
1380struct alc_pincfg {
1381 hda_nid_t nid;
1382 u32 val;
1383};
1384
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001385struct alc_fixup {
1386 const struct alc_pincfg *pins;
1387 const struct hda_verb *verbs;
1388};
1389
1390static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001391 const struct snd_pci_quirk *quirk,
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001392 const struct alc_fixup *fix)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001393{
1394 const struct alc_pincfg *cfg;
1395
1396 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1397 if (!quirk)
1398 return;
1399
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001400 fix += quirk->value;
1401 cfg = fix->pins;
1402 if (cfg) {
1403 for (; cfg->nid; cfg++)
1404 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1405 }
1406 if (fix->verbs)
1407 add_verb(codec->spec, fix->verbs);
Takashi Iwaif95474e2007-07-10 00:47:43 +02001408}
1409
Kailang Yang274693f2009-12-03 10:07:50 +01001410static int alc_read_coef_idx(struct hda_codec *codec,
1411 unsigned int coef_idx)
1412{
1413 unsigned int val;
1414 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1415 coef_idx);
1416 val = snd_hda_codec_read(codec, 0x20, 0,
1417 AC_VERB_GET_PROC_COEF, 0);
1418 return val;
1419}
1420
Takashi Iwaif95474e2007-07-10 00:47:43 +02001421/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001422 * ALC888
1423 */
1424
1425/*
1426 * 2ch mode
1427 */
1428static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1429/* Mic-in jack as mic in */
1430 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1431 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1432/* Line-in jack as Line in */
1433 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1434 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1435/* Line-Out as Front */
1436 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1437 { } /* end */
1438};
1439
1440/*
1441 * 4ch mode
1442 */
1443static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1444/* Mic-in jack as mic in */
1445 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1446 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1447/* Line-in jack as Surround */
1448 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1449 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1450/* Line-Out as Front */
1451 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1452 { } /* end */
1453};
1454
1455/*
1456 * 6ch mode
1457 */
1458static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1459/* Mic-in jack as CLFE */
1460 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1461 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1462/* Line-in jack as Surround */
1463 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1464 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1465/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1466 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1467 { } /* end */
1468};
1469
1470/*
1471 * 8ch mode
1472 */
1473static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1474/* Mic-in jack as CLFE */
1475 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1476 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1477/* Line-in jack as Surround */
1478 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1479 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1480/* Line-Out as Side */
1481 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1482 { } /* end */
1483};
1484
1485static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1486 { 2, alc888_4ST_ch2_intel_init },
1487 { 4, alc888_4ST_ch4_intel_init },
1488 { 6, alc888_4ST_ch6_intel_init },
1489 { 8, alc888_4ST_ch8_intel_init },
1490};
1491
1492/*
1493 * ALC888 Fujitsu Siemens Amillo xa3530
1494 */
1495
1496static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1497/* Front Mic: set to PIN_IN (empty by default) */
1498 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1499/* Connect Internal HP to Front */
1500 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1501 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1502 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1503/* Connect Bass HP to Front */
1504 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1506 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1507/* Connect Line-Out side jack (SPDIF) to Side */
1508 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1510 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1511/* Connect Mic jack to CLFE */
1512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1514 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1515/* Connect Line-in jack to Surround */
1516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1518 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1519/* Connect HP out jack to Front */
1520 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1522 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1523/* Enable unsolicited event for HP jack and Line-out jack */
1524 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1525 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1526 {}
1527};
1528
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001529static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001530{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001531 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001532 unsigned int mute;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001533 hda_nid_t nid;
1534 int i;
1535
1536 spec->jack_present = 0;
1537 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1538 nid = spec->autocfg.hp_pins[i];
1539 if (!nid)
1540 break;
Wu Fengguang864f92b2009-11-18 12:38:02 +08001541 if (snd_hda_jack_detect(codec, nid)) {
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001542 spec->jack_present = 1;
1543 break;
1544 }
1545 }
1546
1547 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001548 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001549 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1550 nid = spec->autocfg.speaker_pins[i];
1551 if (!nid)
1552 break;
1553 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1554 HDA_AMP_MUTE, mute);
1555 }
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001556}
1557
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001558static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1559 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001560{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001561 if (codec->vendor_id == 0x10ec0880)
1562 res >>= 28;
1563 else
1564 res >>= 26;
1565 if (res == ALC880_HP_EVENT)
1566 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001567}
1568
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001569static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001570{
1571 struct alc_spec *spec = codec->spec;
1572
1573 spec->autocfg.hp_pins[0] = 0x15;
1574 spec->autocfg.speaker_pins[0] = 0x14;
1575 spec->autocfg.speaker_pins[1] = 0x16;
1576 spec->autocfg.speaker_pins[2] = 0x17;
1577 spec->autocfg.speaker_pins[3] = 0x19;
1578 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001579}
1580
1581static void alc889_intel_init_hook(struct hda_codec *codec)
1582{
1583 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001584 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001585}
1586
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001587static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001588{
1589 struct alc_spec *spec = codec->spec;
1590
1591 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1592 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1593 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1594 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001595}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001596
1597/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001598 * ALC888 Acer Aspire 4930G model
1599 */
1600
1601static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1602/* Front Mic: set to PIN_IN (empty by default) */
1603 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1604/* Unselect Front Mic by default in input mixer 3 */
1605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001606/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001607 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1608/* Connect Internal HP to front */
1609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1610 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1611 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1612/* Connect HP out to front */
1613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1615 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1616 { }
1617};
1618
Hector Martin3b315d72009-06-02 10:54:19 +02001619/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001620 * ALC888 Acer Aspire 6530G model
1621 */
1622
1623static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
1624/* Bias voltage on for external mic port */
1625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001626/* Front Mic: set to PIN_IN (empty by default) */
1627 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1628/* Unselect Front Mic by default in input mixer 3 */
1629 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001630/* Enable unsolicited event for HP jack */
1631 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1632/* Enable speaker output */
1633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1635/* Enable headphone output */
1636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1637 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1638 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1639 { }
1640};
1641
1642/*
Hector Martin018df412009-06-04 00:13:40 +02001643 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001644 */
1645
Hector Martin018df412009-06-04 00:13:40 +02001646static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001647/* Front Mic: set to PIN_IN (empty by default) */
1648 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1649/* Unselect Front Mic by default in input mixer 3 */
1650 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1651/* Enable unsolicited event for HP jack */
1652 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1653/* Connect Internal Front to Front */
1654 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1655 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1656 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1657/* Connect Internal Rear to Rear */
1658 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1659 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1660 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1661/* Connect Internal CLFE to CLFE */
1662 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1663 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1664 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1665/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001667 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1668 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1669/* Enable all DACs */
1670/* DAC DISABLE/MUTE 1? */
1671/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1672 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1673 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1674/* DAC DISABLE/MUTE 2? */
1675/* some bit here disables the other DACs. Init=0x4900 */
1676 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1677 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001678/* DMIC fix
1679 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1680 * which makes the stereo useless. However, either the mic or the ALC889
1681 * makes the signal become a difference/sum signal instead of standard
1682 * stereo, which is annoying. So instead we flip this bit which makes the
1683 * codec replicate the sum signal to both channels, turning it into a
1684 * normal mono mic.
1685 */
1686/* DMIC_CONTROL? Init value = 0x0001 */
1687 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1688 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001689 { }
1690};
1691
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001692static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001693 /* Front mic only available on one ADC */
1694 {
1695 .num_items = 4,
1696 .items = {
1697 { "Mic", 0x0 },
1698 { "Line", 0x2 },
1699 { "CD", 0x4 },
1700 { "Front Mic", 0xb },
1701 },
1702 },
1703 {
1704 .num_items = 3,
1705 .items = {
1706 { "Mic", 0x0 },
1707 { "Line", 0x2 },
1708 { "CD", 0x4 },
1709 },
1710 }
1711};
1712
Tony Vroond2fd4b02009-06-21 00:40:10 +01001713static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
1714 /* Interal mic only available on one ADC */
1715 {
Tony Vroon684a8842009-06-26 09:27:50 +01001716 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001717 .items = {
1718 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001719 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001720 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001721 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001722 { "Int Mic", 0xb },
1723 },
1724 },
1725 {
Tony Vroon684a8842009-06-26 09:27:50 +01001726 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01001727 .items = {
1728 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01001729 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001730 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01001731 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01001732 },
1733 }
1734};
1735
Hector Martin018df412009-06-04 00:13:40 +02001736static struct hda_input_mux alc889_capture_sources[3] = {
1737 /* Digital mic only available on first "ADC" */
1738 {
1739 .num_items = 5,
1740 .items = {
1741 { "Mic", 0x0 },
1742 { "Line", 0x2 },
1743 { "CD", 0x4 },
1744 { "Front Mic", 0xb },
1745 { "Input Mix", 0xa },
1746 },
1747 },
1748 {
1749 .num_items = 4,
1750 .items = {
1751 { "Mic", 0x0 },
1752 { "Line", 0x2 },
1753 { "CD", 0x4 },
1754 { "Input Mix", 0xa },
1755 },
1756 },
1757 {
1758 .num_items = 4,
1759 .items = {
1760 { "Mic", 0x0 },
1761 { "Line", 0x2 },
1762 { "CD", 0x4 },
1763 { "Input Mix", 0xa },
1764 },
1765 }
1766};
1767
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001768static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001769 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1770 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1771 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1772 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1773 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1774 HDA_OUTPUT),
1775 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1776 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1777 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1778 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1779 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1780 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1781 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1783 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1784 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1785 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1786 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001787 { } /* end */
1788};
1789
Hector Martin556eea92009-12-20 22:51:23 +01001790static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
1791 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1792 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1793 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1794 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1795 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1796 HDA_OUTPUT),
1797 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1798 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1799 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1803 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1805 { } /* end */
1806};
1807
1808
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001809static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001810{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001811 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001812
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001813 spec->autocfg.hp_pins[0] = 0x15;
1814 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01001815 spec->autocfg.speaker_pins[1] = 0x16;
1816 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001817}
1818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001819static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02001820{
1821 struct alc_spec *spec = codec->spec;
1822
1823 spec->autocfg.hp_pins[0] = 0x15;
1824 spec->autocfg.speaker_pins[0] = 0x14;
1825 spec->autocfg.speaker_pins[1] = 0x16;
1826 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02001827}
1828
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001829static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02001830{
1831 struct alc_spec *spec = codec->spec;
1832
1833 spec->autocfg.hp_pins[0] = 0x15;
1834 spec->autocfg.speaker_pins[0] = 0x14;
1835 spec->autocfg.speaker_pins[1] = 0x16;
1836 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02001837}
1838
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001839/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001840 * ALC880 3-stack model
1841 *
1842 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001843 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1844 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 */
1846
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001847static hda_nid_t alc880_dac_nids[4] = {
1848 /* front, rear, clfe, rear_surr */
1849 0x02, 0x05, 0x04, 0x03
1850};
1851
1852static hda_nid_t alc880_adc_nids[3] = {
1853 /* ADC0-2 */
1854 0x07, 0x08, 0x09,
1855};
1856
1857/* The datasheet says the node 0x07 is connected from inputs,
1858 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001859 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001861static hda_nid_t alc880_adc_nids_alt[2] = {
1862 /* ADC1-2 */
1863 0x08, 0x09,
1864};
1865
1866#define ALC880_DIGOUT_NID 0x06
1867#define ALC880_DIGIN_NID 0x0a
1868
1869static struct hda_input_mux alc880_capture_source = {
1870 .num_items = 4,
1871 .items = {
1872 { "Mic", 0x0 },
1873 { "Front Mic", 0x3 },
1874 { "Line", 0x2 },
1875 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001877};
1878
1879/* channel source setting (2/6 channel selection for 3-stack) */
1880/* 2ch mode */
1881static struct hda_verb alc880_threestack_ch2_init[] = {
1882 /* set line-in to input, mute it */
1883 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1884 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1885 /* set mic-in to input vref 80%, mute it */
1886 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1887 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888 { } /* end */
1889};
1890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001891/* 6ch mode */
1892static struct hda_verb alc880_threestack_ch6_init[] = {
1893 /* set line-in to output, unmute it */
1894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1896 /* set mic-in to output, unmute it */
1897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899 { } /* end */
1900};
1901
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001902static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001903 { 2, alc880_threestack_ch2_init },
1904 { 6, alc880_threestack_ch6_init },
1905};
1906
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001907static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001908 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001909 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001910 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001911 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001912 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1913 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001914 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1915 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1922 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1923 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001925 {
1926 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1927 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001928 .info = alc_ch_mode_info,
1929 .get = alc_ch_mode_get,
1930 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001931 },
1932 { } /* end */
1933};
1934
1935/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001936static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1937 struct snd_ctl_elem_info *uinfo)
1938{
1939 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1940 struct alc_spec *spec = codec->spec;
1941 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001942
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001943 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001944 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1945 HDA_INPUT);
1946 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001947 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001948 return err;
1949}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001951static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1952 unsigned int size, unsigned int __user *tlv)
1953{
1954 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1955 struct alc_spec *spec = codec->spec;
1956 int err;
1957
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001958 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001959 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1960 HDA_INPUT);
1961 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001962 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001963 return err;
1964}
1965
1966typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1967 struct snd_ctl_elem_value *ucontrol);
1968
1969static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1970 struct snd_ctl_elem_value *ucontrol,
1971 getput_call_t func)
1972{
1973 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1974 struct alc_spec *spec = codec->spec;
1975 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1976 int err;
1977
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001978 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001979 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1980 3, 0, HDA_INPUT);
1981 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08001982 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001983 return err;
1984}
1985
1986static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1987 struct snd_ctl_elem_value *ucontrol)
1988{
1989 return alc_cap_getput_caller(kcontrol, ucontrol,
1990 snd_hda_mixer_amp_volume_get);
1991}
1992
1993static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1994 struct snd_ctl_elem_value *ucontrol)
1995{
1996 return alc_cap_getput_caller(kcontrol, ucontrol,
1997 snd_hda_mixer_amp_volume_put);
1998}
1999
2000/* capture mixer elements */
2001#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2002
2003static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2004 struct snd_ctl_elem_value *ucontrol)
2005{
2006 return alc_cap_getput_caller(kcontrol, ucontrol,
2007 snd_hda_mixer_amp_switch_get);
2008}
2009
2010static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2011 struct snd_ctl_elem_value *ucontrol)
2012{
2013 return alc_cap_getput_caller(kcontrol, ucontrol,
2014 snd_hda_mixer_amp_switch_put);
2015}
2016
Takashi Iwaia23b6882009-03-23 15:21:36 +01002017#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002018 { \
2019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2020 .name = "Capture Switch", \
2021 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2022 .count = num, \
2023 .info = alc_cap_sw_info, \
2024 .get = alc_cap_sw_get, \
2025 .put = alc_cap_sw_put, \
2026 }, \
2027 { \
2028 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2029 .name = "Capture Volume", \
2030 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2031 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2032 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2033 .count = num, \
2034 .info = alc_cap_vol_info, \
2035 .get = alc_cap_vol_get, \
2036 .put = alc_cap_vol_put, \
2037 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002038 }
2039
2040#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002041 { \
2042 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2043 /* .name = "Capture Source", */ \
2044 .name = "Input Source", \
2045 .count = num, \
2046 .info = alc_mux_enum_info, \
2047 .get = alc_mux_enum_get, \
2048 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002049 }
2050
2051#define DEFINE_CAPMIX(num) \
2052static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2053 _DEFINE_CAPMIX(num), \
2054 _DEFINE_CAPSRC(num), \
2055 { } /* end */ \
2056}
2057
2058#define DEFINE_CAPMIX_NOSRC(num) \
2059static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2060 _DEFINE_CAPMIX(num), \
2061 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002062}
2063
2064/* up to three ADCs */
2065DEFINE_CAPMIX(1);
2066DEFINE_CAPMIX(2);
2067DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002068DEFINE_CAPMIX_NOSRC(1);
2069DEFINE_CAPMIX_NOSRC(2);
2070DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002071
2072/*
2073 * ALC880 5-stack model
2074 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002075 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2076 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2078 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2079 */
2080
2081/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002082static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002083 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002084 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 { } /* end */
2086};
2087
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088/* channel source setting (6/8 channel selection for 5-stack) */
2089/* 6ch mode */
2090static struct hda_verb alc880_fivestack_ch6_init[] = {
2091 /* set line-in to input, mute it */
2092 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2093 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002094 { } /* end */
2095};
2096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002097/* 8ch mode */
2098static struct hda_verb alc880_fivestack_ch8_init[] = {
2099 /* set line-in to output, unmute it */
2100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2102 { } /* end */
2103};
2104
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002105static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002106 { 6, alc880_fivestack_ch6_init },
2107 { 8, alc880_fivestack_ch8_init },
2108};
2109
2110
2111/*
2112 * ALC880 6-stack model
2113 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002114 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2115 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002116 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2117 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2118 */
2119
2120static hda_nid_t alc880_6st_dac_nids[4] = {
2121 /* front, rear, clfe, rear_surr */
2122 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002123};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002124
2125static struct hda_input_mux alc880_6stack_capture_source = {
2126 .num_items = 4,
2127 .items = {
2128 { "Mic", 0x0 },
2129 { "Front Mic", 0x1 },
2130 { "Line", 0x2 },
2131 { "CD", 0x4 },
2132 },
2133};
2134
2135/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002136static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002137 { 8, NULL },
2138};
2139
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002140static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002141 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002142 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002143 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002144 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002145 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2146 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002147 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2148 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002149 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002150 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002151 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2152 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2158 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002159 {
2160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2161 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002162 .info = alc_ch_mode_info,
2163 .get = alc_ch_mode_get,
2164 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002165 },
2166 { } /* end */
2167};
2168
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002169
2170/*
2171 * ALC880 W810 model
2172 *
2173 * W810 has rear IO for:
2174 * Front (DAC 02)
2175 * Surround (DAC 03)
2176 * Center/LFE (DAC 04)
2177 * Digital out (06)
2178 *
2179 * The system also has a pair of internal speakers, and a headphone jack.
2180 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002181 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002182 * There is a variable resistor to control the speaker or headphone
2183 * volume. This is a hardware-only device without a software API.
2184 *
2185 * Plugging headphones in will disable the internal speakers. This is
2186 * implemented in hardware, not via the driver using jack sense. In
2187 * a similar fashion, plugging into the rear socket marked "front" will
2188 * disable both the speakers and headphones.
2189 *
2190 * For input, there's a microphone jack, and an "audio in" jack.
2191 * These may not do anything useful with this driver yet, because I
2192 * haven't setup any initialization verbs for these yet...
2193 */
2194
2195static hda_nid_t alc880_w810_dac_nids[3] = {
2196 /* front, rear/surround, clfe */
2197 0x02, 0x03, 0x04
2198};
2199
2200/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002201static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002202 { 6, NULL }
2203};
2204
2205/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002206static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002209 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002210 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002211 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2212 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2214 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002215 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2216 { } /* end */
2217};
2218
2219
2220/*
2221 * Z710V model
2222 *
2223 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002224 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2225 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002226 */
2227
2228static hda_nid_t alc880_z71v_dac_nids[1] = {
2229 0x02
2230};
2231#define ALC880_Z71V_HP_DAC 0x03
2232
2233/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002234static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 { 2, NULL }
2236};
2237
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002238static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002239 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002240 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002242 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2245 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2246 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2247 { } /* end */
2248};
2249
2250
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002251/*
2252 * ALC880 F1734 model
2253 *
2254 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2255 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2256 */
2257
2258static hda_nid_t alc880_f1734_dac_nids[1] = {
2259 0x03
2260};
2261#define ALC880_F1734_HP_DAC 0x02
2262
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002263static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002264 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002265 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2267 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002268 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2269 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002272 { } /* end */
2273};
2274
Takashi Iwai937b4162008-02-11 14:52:36 +01002275static struct hda_input_mux alc880_f1734_capture_source = {
2276 .num_items = 2,
2277 .items = {
2278 { "Mic", 0x1 },
2279 { "CD", 0x4 },
2280 },
2281};
2282
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002283
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284/*
2285 * ALC880 ASUS model
2286 *
2287 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2288 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2289 * Mic = 0x18, Line = 0x1a
2290 */
2291
2292#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2293#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2294
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002295static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002298 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002299 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002300 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2301 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002302 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2303 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002304 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2305 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2306 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2307 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2308 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2309 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002310 {
2311 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2312 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002313 .info = alc_ch_mode_info,
2314 .get = alc_ch_mode_get,
2315 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002316 },
2317 { } /* end */
2318};
2319
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002320/*
2321 * ALC880 ASUS W1V model
2322 *
2323 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2324 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2325 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2326 */
2327
2328/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002329static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002330 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2331 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002332 { } /* end */
2333};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002334
Kailang Yangdf694da2005-12-05 19:42:22 +01002335/* TCL S700 */
2336static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2337 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2338 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2340 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2341 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2344 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2345 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002346 { } /* end */
2347};
2348
Kailang Yangccc656c2006-10-17 12:32:26 +02002349/* Uniwill */
2350static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002351 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2352 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2353 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2354 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002355 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2356 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2357 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2358 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2361 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2362 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2365 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2366 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002367 {
2368 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2369 .name = "Channel Mode",
2370 .info = alc_ch_mode_info,
2371 .get = alc_ch_mode_get,
2372 .put = alc_ch_mode_put,
2373 },
2374 { } /* end */
2375};
2376
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002377static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2378 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2379 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2381 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2382 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2383 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2384 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2385 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2386 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2387 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2388 { } /* end */
2389};
2390
Kailang Yangccc656c2006-10-17 12:32:26 +02002391static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002392 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2393 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2394 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2395 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2398 { } /* end */
2399};
2400
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002402 * virtual master controls
2403 */
2404
2405/*
2406 * slave controls for virtual master
2407 */
2408static const char *alc_slave_vols[] = {
2409 "Front Playback Volume",
2410 "Surround Playback Volume",
2411 "Center Playback Volume",
2412 "LFE Playback Volume",
2413 "Side Playback Volume",
2414 "Headphone Playback Volume",
2415 "Speaker Playback Volume",
2416 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002417 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002418 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002419 NULL,
2420};
2421
2422static const char *alc_slave_sws[] = {
2423 "Front Playback Switch",
2424 "Surround Playback Switch",
2425 "Center Playback Switch",
2426 "LFE Playback Switch",
2427 "Side Playback Switch",
2428 "Headphone Playback Switch",
2429 "Speaker Playback Switch",
2430 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002431 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002432 "Line-Out Playback Switch",
2433 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002434 NULL,
2435};
2436
2437/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002438 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002440
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002441#define NID_MAPPING (-1)
2442
2443#define SUBDEV_SPEAKER_ (0 << 6)
2444#define SUBDEV_HP_ (1 << 6)
2445#define SUBDEV_LINE_ (2 << 6)
2446#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2447#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2448#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2449
Takashi Iwai603c4012008-07-30 15:01:44 +02002450static void alc_free_kctls(struct hda_codec *codec);
2451
Takashi Iwai67d634c2009-11-16 15:35:59 +01002452#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002453/* additional beep mixers; the actual parameters are overwritten at build */
2454static struct snd_kcontrol_new alc_beep_mixer[] = {
2455 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002456 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002457 { } /* end */
2458};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002459#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002460
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461static int alc_build_controls(struct hda_codec *codec)
2462{
2463 struct alc_spec *spec = codec->spec;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002464 struct snd_kcontrol *kctl;
2465 struct snd_kcontrol_new *knew;
2466 int i, j, err;
2467 unsigned int u;
2468 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469
2470 for (i = 0; i < spec->num_mixers; i++) {
2471 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2472 if (err < 0)
2473 return err;
2474 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002475 if (spec->cap_mixer) {
2476 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2477 if (err < 0)
2478 return err;
2479 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002480 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002481 err = snd_hda_create_spdif_out_ctls(codec,
2482 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 if (err < 0)
2484 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002485 if (!spec->no_analog) {
2486 err = snd_hda_create_spdif_share_sw(codec,
2487 &spec->multiout);
2488 if (err < 0)
2489 return err;
2490 spec->multiout.share_spdif = 1;
2491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492 }
2493 if (spec->dig_in_nid) {
2494 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2495 if (err < 0)
2496 return err;
2497 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002498
Takashi Iwai67d634c2009-11-16 15:35:59 +01002499#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002500 /* create beep controls if needed */
2501 if (spec->beep_amp) {
2502 struct snd_kcontrol_new *knew;
2503 for (knew = alc_beep_mixer; knew->name; knew++) {
2504 struct snd_kcontrol *kctl;
2505 kctl = snd_ctl_new1(knew, codec);
2506 if (!kctl)
2507 return -ENOMEM;
2508 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002509 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002510 if (err < 0)
2511 return err;
2512 }
2513 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002514#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002515
Takashi Iwai2134ea42008-01-10 16:53:55 +01002516 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002517 if (!spec->no_analog &&
2518 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002519 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002520 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002521 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002522 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002523 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002524 if (err < 0)
2525 return err;
2526 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002527 if (!spec->no_analog &&
2528 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002529 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2530 NULL, alc_slave_sws);
2531 if (err < 0)
2532 return err;
2533 }
2534
Takashi Iwai603c4012008-07-30 15:01:44 +02002535 alc_free_kctls(codec); /* no longer needed */
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002536
2537 /* assign Capture Source enums to NID */
2538 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2539 if (!kctl)
2540 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2541 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002542 hda_nid_t *nids = spec->capsrc_nids;
2543 if (!nids)
2544 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002545 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002546 if (err < 0)
2547 return err;
2548 }
2549 if (spec->cap_mixer) {
2550 const char *kname = kctl ? kctl->id.name : NULL;
2551 for (knew = spec->cap_mixer; knew->name; knew++) {
2552 if (kname && strcmp(knew->name, kname) == 0)
2553 continue;
2554 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2555 for (i = 0; kctl && i < kctl->count; i++) {
2556 err = snd_hda_add_nid(codec, kctl, i,
2557 spec->adc_nids[i]);
2558 if (err < 0)
2559 return err;
2560 }
2561 }
2562 }
2563
2564 /* other nid->control mapping */
2565 for (i = 0; i < spec->num_mixers; i++) {
2566 for (knew = spec->mixers[i]; knew->name; knew++) {
2567 if (knew->iface != NID_MAPPING)
2568 continue;
2569 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2570 if (kctl == NULL)
2571 continue;
2572 u = knew->subdevice;
2573 for (j = 0; j < 4; j++, u >>= 8) {
2574 nid = u & 0x3f;
2575 if (nid == 0)
2576 continue;
2577 switch (u & 0xc0) {
2578 case SUBDEV_SPEAKER_:
2579 nid = spec->autocfg.speaker_pins[nid];
2580 break;
2581 case SUBDEV_LINE_:
2582 nid = spec->autocfg.line_out_pins[nid];
2583 break;
2584 case SUBDEV_HP_:
2585 nid = spec->autocfg.hp_pins[nid];
2586 break;
2587 default:
2588 continue;
2589 }
2590 err = snd_hda_add_nid(codec, kctl, 0, nid);
2591 if (err < 0)
2592 return err;
2593 }
2594 u = knew->private_value;
2595 for (j = 0; j < 4; j++, u >>= 8) {
2596 nid = u & 0xff;
2597 if (nid == 0)
2598 continue;
2599 err = snd_hda_add_nid(codec, kctl, 0, nid);
2600 if (err < 0)
2601 return err;
2602 }
2603 }
2604 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 return 0;
2606}
2607
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002608
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609/*
2610 * initialize the codec volumes, etc
2611 */
2612
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002613/*
2614 * generic initialization of ADC, input mixers and output mixers
2615 */
2616static struct hda_verb alc880_volume_init_verbs[] = {
2617 /*
2618 * Unmute ADC0-2 and set the default input to mic-in
2619 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002620 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002621 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002622 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002623 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002624 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002625 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002627 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2628 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002629 * Note: PASD motherboards uses the Line In 2 as the input for front
2630 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002632 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002633 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002641 /*
2642 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002644 /* set vol=0 to output mixers */
2645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2646 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2647 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2648 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2649 /* set up input amps for analog loopback */
2650 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002657 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659
2660 { }
2661};
2662
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663/*
2664 * 3-stack pin configuration:
2665 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2666 */
2667static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2668 /*
2669 * preset connection lists of input pins
2670 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2671 */
2672 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2673 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2674 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2675
2676 /*
2677 * Set pin mode and muting
2678 */
2679 /* set front pin widgets 0x14 for output */
2680 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2681 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2682 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2683 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2684 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2685 /* Mic2 (as headphone out) for HP output */
2686 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2687 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2688 /* Line In pin widget for input */
2689 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2690 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2691 /* Line2 (as front mic) pin widget for input and vref at 80% */
2692 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2693 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2694 /* CD pin widget for input */
2695 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2696
2697 { }
2698};
2699
2700/*
2701 * 5-stack pin configuration:
2702 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2703 * line-in/side = 0x1a, f-mic = 0x1b
2704 */
2705static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2706 /*
2707 * preset connection lists of input pins
2708 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2709 */
2710 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2711 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2712
2713 /*
2714 * Set pin mode and muting
2715 */
2716 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002717 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2718 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2720 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002721 /* unmute pins for output (no gain on this amp) */
2722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2724 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2725 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2726
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002729 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2730 /* Mic2 (as headphone out) for HP output */
2731 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002732 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002733 /* Line In pin widget for input */
2734 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2735 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2736 /* Line2 (as front mic) pin widget for input and vref at 80% */
2737 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2738 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2739 /* CD pin widget for input */
2740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002741
2742 { }
2743};
2744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745/*
2746 * W810 pin configuration:
2747 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2748 */
2749static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750 /* hphone/speaker input selector: front DAC */
2751 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2752
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002753 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2754 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2755 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2756 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2757 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2758 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2759
2760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002762
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763 { }
2764};
2765
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766/*
2767 * Z71V pin configuration:
2768 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2769 */
2770static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002771 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002772 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002773 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002774 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002775
Takashi Iwai16ded522005-06-10 19:58:24 +02002776 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002779 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002780
2781 { }
2782};
2783
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002784/*
2785 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002786 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2787 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002788 */
2789static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2790 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2791
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002793 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002794 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002796 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002797 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002798 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002799 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2800
Takashi Iwai16ded522005-06-10 19:58:24 +02002801 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002802 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002803 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002804 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002805 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002806 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002807 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002808 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002809 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002810
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002811 { }
2812};
Takashi Iwai16ded522005-06-10 19:58:24 +02002813
Kailang Yangccc656c2006-10-17 12:32:26 +02002814/*
2815 * Uniwill pin configuration:
2816 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2817 * line = 0x1a
2818 */
2819static struct hda_verb alc880_uniwill_init_verbs[] = {
2820 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2821
2822 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2823 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2824 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2827 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2828 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2829 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2830 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2832 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2834 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2836
2837 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2839 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2841 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2843 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2844 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2845 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2846
2847 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2848 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2849
2850 { }
2851};
2852
2853/*
2854* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002855* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002856 */
2857static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2858 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2859
2860 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2861 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2863 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2864 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2865 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2866 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2868 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2870 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2872
2873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2875 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2876 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2879
2880 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2881 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2882
2883 { }
2884};
2885
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002886static struct hda_verb alc880_beep_init_verbs[] = {
2887 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2888 { }
2889};
2890
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002891/* auto-toggle front mic */
2892static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2893{
2894 unsigned int present;
2895 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002896
Wu Fengguang864f92b2009-11-18 12:38:02 +08002897 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002898 bits = present ? HDA_AMP_MUTE : 0;
2899 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002900}
2901
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002902static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002903{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002904 struct alc_spec *spec = codec->spec;
2905
2906 spec->autocfg.hp_pins[0] = 0x14;
2907 spec->autocfg.speaker_pins[0] = 0x15;
2908 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002909}
2910
2911static void alc880_uniwill_init_hook(struct hda_codec *codec)
2912{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002913 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002914 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002915}
2916
2917static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2918 unsigned int res)
2919{
2920 /* Looks like the unsol event is incompatible with the standard
2921 * definition. 4bit tag is placed at 28 bit!
2922 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002923 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002924 case ALC880_MIC_EVENT:
2925 alc880_uniwill_mic_automute(codec);
2926 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002927 default:
2928 alc_automute_amp_unsol_event(codec, res);
2929 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002930 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002931}
2932
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002933static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002934{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002935 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002936
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002937 spec->autocfg.hp_pins[0] = 0x14;
2938 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002939}
2940
2941static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2942{
2943 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002944
Kailang Yangccc656c2006-10-17 12:32:26 +02002945 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002946 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2947 present &= HDA_AMP_VOLMASK;
2948 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2949 HDA_AMP_VOLMASK, present);
2950 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2951 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002952}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002953
Kailang Yangccc656c2006-10-17 12:32:26 +02002954static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2955 unsigned int res)
2956{
2957 /* Looks like the unsol event is incompatible with the standard
2958 * definition. 4bit tag is placed at 28 bit!
2959 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002960 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002961 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002962 else
2963 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002964}
2965
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002966/*
2967 * F1734 pin configuration:
2968 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2969 */
2970static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002971 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2973 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2974 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2975 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2976
2977 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2978 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2979 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981
2982 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2983 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002984 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002985 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2987 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2988 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2989 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2990 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002991
Takashi Iwai937b4162008-02-11 14:52:36 +01002992 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2993 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2994
Takashi Iwai16ded522005-06-10 19:58:24 +02002995 { }
2996};
2997
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002998/*
2999 * ASUS pin configuration:
3000 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3001 */
3002static struct hda_verb alc880_pin_asus_init_verbs[] = {
3003 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3004 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3005 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3006 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3007
3008 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3009 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3010 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3013 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3014 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3016
3017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3018 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3019 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3020 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3021 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3022 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3024 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3025 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003026
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003027 { }
3028};
3029
3030/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003031#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3032#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003033#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003034
Kailang Yangdf694da2005-12-05 19:42:22 +01003035/* Clevo m520g init */
3036static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3037 /* headphone output */
3038 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3039 /* line-out */
3040 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3041 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3042 /* Line-in */
3043 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3044 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3045 /* CD */
3046 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3047 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3048 /* Mic1 (rear panel) */
3049 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3050 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3051 /* Mic2 (front panel) */
3052 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3053 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 /* headphone */
3055 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3056 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057 /* change to EAPD mode */
3058 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3059 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3060
3061 { }
3062};
3063
3064static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003065 /* change to EAPD mode */
3066 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3067 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3068
Kailang Yangdf694da2005-12-05 19:42:22 +01003069 /* Headphone output */
3070 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3071 /* Front output*/
3072 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3073 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3074
3075 /* Line In pin widget for input */
3076 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3077 /* CD pin widget for input */
3078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3079 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3080 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3081
3082 /* change to EAPD mode */
3083 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3084 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3085
3086 { }
3087};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088
3089/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003090 * LG m1 express dual
3091 *
3092 * Pin assignment:
3093 * Rear Line-In/Out (blue): 0x14
3094 * Build-in Mic-In: 0x15
3095 * Speaker-out: 0x17
3096 * HP-Out (green): 0x1b
3097 * Mic-In/Out (red): 0x19
3098 * SPDIF-Out: 0x1e
3099 */
3100
3101/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3102static hda_nid_t alc880_lg_dac_nids[3] = {
3103 0x05, 0x02, 0x03
3104};
3105
3106/* seems analog CD is not working */
3107static struct hda_input_mux alc880_lg_capture_source = {
3108 .num_items = 3,
3109 .items = {
3110 { "Mic", 0x1 },
3111 { "Line", 0x5 },
3112 { "Internal Mic", 0x6 },
3113 },
3114};
3115
3116/* 2,4,6 channel modes */
3117static struct hda_verb alc880_lg_ch2_init[] = {
3118 /* set line-in and mic-in to input */
3119 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3120 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3121 { }
3122};
3123
3124static struct hda_verb alc880_lg_ch4_init[] = {
3125 /* set line-in to out and mic-in to input */
3126 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3127 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3128 { }
3129};
3130
3131static struct hda_verb alc880_lg_ch6_init[] = {
3132 /* set line-in and mic-in to output */
3133 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3134 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3135 { }
3136};
3137
3138static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3139 { 2, alc880_lg_ch2_init },
3140 { 4, alc880_lg_ch4_init },
3141 { 6, alc880_lg_ch6_init },
3142};
3143
3144static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003145 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3146 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003147 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3148 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3153 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3154 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3155 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3156 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3157 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3158 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3159 {
3160 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3161 .name = "Channel Mode",
3162 .info = alc_ch_mode_info,
3163 .get = alc_ch_mode_get,
3164 .put = alc_ch_mode_put,
3165 },
3166 { } /* end */
3167};
3168
3169static struct hda_verb alc880_lg_init_verbs[] = {
3170 /* set capture source to mic-in */
3171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3172 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3173 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3174 /* mute all amp mixer inputs */
3175 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003178 /* line-in to input */
3179 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3180 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3181 /* built-in mic */
3182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3183 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3184 /* speaker-out */
3185 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3186 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 /* mic-in to input */
3188 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3189 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3190 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3191 /* HP-out */
3192 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003196 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003197 { }
3198};
3199
3200/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003201static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003202{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003203 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003204
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003205 spec->autocfg.hp_pins[0] = 0x1b;
3206 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003207}
3208
3209/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003210 * LG LW20
3211 *
3212 * Pin assignment:
3213 * Speaker-out: 0x14
3214 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003215 * Built-in Mic-In: 0x19
3216 * Line-In: 0x1b
3217 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003218 * SPDIF-Out: 0x1e
3219 */
3220
Takashi Iwaid6815182006-03-23 16:06:23 +01003221static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003222 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003223 .items = {
3224 { "Mic", 0x0 },
3225 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003226 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003227 },
3228};
3229
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003230#define alc880_lg_lw_modes alc880_threestack_modes
3231
Takashi Iwaid6815182006-03-23 16:06:23 +01003232static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3234 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3235 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3236 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3237 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3238 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3239 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3240 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3245 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3246 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003247 {
3248 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3249 .name = "Channel Mode",
3250 .info = alc_ch_mode_info,
3251 .get = alc_ch_mode_get,
3252 .put = alc_ch_mode_put,
3253 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003254 { } /* end */
3255};
3256
3257static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003258 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3259 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3260 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3261
Takashi Iwaid6815182006-03-23 16:06:23 +01003262 /* set capture source to mic-in */
3263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3264 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3265 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003267 /* speaker-out */
3268 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3269 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3270 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3273 /* mic-in to input */
3274 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3275 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3276 /* built-in mic */
3277 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3278 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3279 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003280 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003281 { }
3282};
3283
3284/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003285static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003286{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003287 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003288
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003289 spec->autocfg.hp_pins[0] = 0x1b;
3290 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003291}
3292
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003293static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3294 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3295 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3296 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3297 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3298 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3299 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3300 { } /* end */
3301};
3302
3303static struct hda_input_mux alc880_medion_rim_capture_source = {
3304 .num_items = 2,
3305 .items = {
3306 { "Mic", 0x0 },
3307 { "Internal Mic", 0x1 },
3308 },
3309};
3310
3311static struct hda_verb alc880_medion_rim_init_verbs[] = {
3312 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3313
3314 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3315 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3316
3317 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3318 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3319 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3320 /* Mic2 (as headphone out) for HP output */
3321 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3322 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3323 /* Internal Speaker */
3324 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3325 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326
3327 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3328 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3329
3330 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3331 { }
3332};
3333
3334/* toggle speaker-output according to the hp-jack state */
3335static void alc880_medion_rim_automute(struct hda_codec *codec)
3336{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003337 struct alc_spec *spec = codec->spec;
3338 alc_automute_amp(codec);
3339 /* toggle EAPD */
3340 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003341 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3342 else
3343 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3344}
3345
3346static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3347 unsigned int res)
3348{
3349 /* Looks like the unsol event is incompatible with the standard
3350 * definition. 4bit tag is placed at 28 bit!
3351 */
3352 if ((res >> 28) == ALC880_HP_EVENT)
3353 alc880_medion_rim_automute(codec);
3354}
3355
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003356static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003357{
3358 struct alc_spec *spec = codec->spec;
3359
3360 spec->autocfg.hp_pins[0] = 0x14;
3361 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003362}
3363
Takashi Iwaicb53c622007-08-10 17:21:45 +02003364#ifdef CONFIG_SND_HDA_POWER_SAVE
3365static struct hda_amp_list alc880_loopbacks[] = {
3366 { 0x0b, HDA_INPUT, 0 },
3367 { 0x0b, HDA_INPUT, 1 },
3368 { 0x0b, HDA_INPUT, 2 },
3369 { 0x0b, HDA_INPUT, 3 },
3370 { 0x0b, HDA_INPUT, 4 },
3371 { } /* end */
3372};
3373
3374static struct hda_amp_list alc880_lg_loopbacks[] = {
3375 { 0x0b, HDA_INPUT, 1 },
3376 { 0x0b, HDA_INPUT, 6 },
3377 { 0x0b, HDA_INPUT, 7 },
3378 { } /* end */
3379};
3380#endif
3381
Takashi Iwaid6815182006-03-23 16:06:23 +01003382/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003383 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003384 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003385
Linus Torvalds1da177e2005-04-16 15:20:36 -07003386static int alc_init(struct hda_codec *codec)
3387{
3388 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003389 unsigned int i;
3390
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003391 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003392 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003393
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003394 for (i = 0; i < spec->num_init_verbs; i++)
3395 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003396
3397 if (spec->init_hook)
3398 spec->init_hook(codec);
3399
Linus Torvalds1da177e2005-04-16 15:20:36 -07003400 return 0;
3401}
3402
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003403static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3404{
3405 struct alc_spec *spec = codec->spec;
3406
3407 if (spec->unsol_event)
3408 spec->unsol_event(codec, res);
3409}
3410
Takashi Iwaicb53c622007-08-10 17:21:45 +02003411#ifdef CONFIG_SND_HDA_POWER_SAVE
3412static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3413{
3414 struct alc_spec *spec = codec->spec;
3415 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3416}
3417#endif
3418
Linus Torvalds1da177e2005-04-16 15:20:36 -07003419/*
3420 * Analog playback callbacks
3421 */
3422static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3423 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003424 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003425{
3426 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003427 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3428 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003429}
3430
3431static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3432 struct hda_codec *codec,
3433 unsigned int stream_tag,
3434 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003435 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436{
3437 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003438 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3439 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003440}
3441
3442static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3443 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003444 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003445{
3446 struct alc_spec *spec = codec->spec;
3447 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3448}
3449
3450/*
3451 * Digital out
3452 */
3453static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3454 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003455 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003456{
3457 struct alc_spec *spec = codec->spec;
3458 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3459}
3460
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003461static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3462 struct hda_codec *codec,
3463 unsigned int stream_tag,
3464 unsigned int format,
3465 struct snd_pcm_substream *substream)
3466{
3467 struct alc_spec *spec = codec->spec;
3468 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3469 stream_tag, format, substream);
3470}
3471
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003472static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3473 struct hda_codec *codec,
3474 struct snd_pcm_substream *substream)
3475{
3476 struct alc_spec *spec = codec->spec;
3477 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3478}
3479
Linus Torvalds1da177e2005-04-16 15:20:36 -07003480static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3481 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003482 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003483{
3484 struct alc_spec *spec = codec->spec;
3485 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3486}
3487
3488/*
3489 * Analog capture
3490 */
Takashi Iwai63300792008-01-24 15:31:36 +01003491static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003492 struct hda_codec *codec,
3493 unsigned int stream_tag,
3494 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003495 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003496{
3497 struct alc_spec *spec = codec->spec;
3498
Takashi Iwai63300792008-01-24 15:31:36 +01003499 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003500 stream_tag, 0, format);
3501 return 0;
3502}
3503
Takashi Iwai63300792008-01-24 15:31:36 +01003504static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003505 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003506 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003507{
3508 struct alc_spec *spec = codec->spec;
3509
Takashi Iwai888afa12008-03-18 09:57:50 +01003510 snd_hda_codec_cleanup_stream(codec,
3511 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003512 return 0;
3513}
3514
3515
3516/*
3517 */
3518static struct hda_pcm_stream alc880_pcm_analog_playback = {
3519 .substreams = 1,
3520 .channels_min = 2,
3521 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003522 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003523 .ops = {
3524 .open = alc880_playback_pcm_open,
3525 .prepare = alc880_playback_pcm_prepare,
3526 .cleanup = alc880_playback_pcm_cleanup
3527 },
3528};
3529
3530static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003531 .substreams = 1,
3532 .channels_min = 2,
3533 .channels_max = 2,
3534 /* NID is set in alc_build_pcms */
3535};
3536
3537static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3538 .substreams = 1,
3539 .channels_min = 2,
3540 .channels_max = 2,
3541 /* NID is set in alc_build_pcms */
3542};
3543
3544static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3545 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003546 .channels_min = 2,
3547 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003548 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003549 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003550 .prepare = alc880_alt_capture_pcm_prepare,
3551 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003552 },
3553};
3554
3555static struct hda_pcm_stream alc880_pcm_digital_playback = {
3556 .substreams = 1,
3557 .channels_min = 2,
3558 .channels_max = 2,
3559 /* NID is set in alc_build_pcms */
3560 .ops = {
3561 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003562 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003563 .prepare = alc880_dig_playback_pcm_prepare,
3564 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003565 },
3566};
3567
3568static struct hda_pcm_stream alc880_pcm_digital_capture = {
3569 .substreams = 1,
3570 .channels_min = 2,
3571 .channels_max = 2,
3572 /* NID is set in alc_build_pcms */
3573};
3574
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003575/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003576static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003577 .substreams = 0,
3578 .channels_min = 0,
3579 .channels_max = 0,
3580};
3581
Linus Torvalds1da177e2005-04-16 15:20:36 -07003582static int alc_build_pcms(struct hda_codec *codec)
3583{
3584 struct alc_spec *spec = codec->spec;
3585 struct hda_pcm *info = spec->pcm_rec;
3586 int i;
3587
3588 codec->num_pcms = 1;
3589 codec->pcm_info = info;
3590
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003591 if (spec->no_analog)
3592 goto skip_analog;
3593
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003594 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3595 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003596 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003597
Takashi Iwai4a471b72005-12-07 13:56:29 +01003598 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003599 if (snd_BUG_ON(!spec->multiout.dac_nids))
3600 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003601 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3602 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3603 }
3604 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003605 if (snd_BUG_ON(!spec->adc_nids))
3606 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003607 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3608 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3609 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003610
Takashi Iwai4a471b72005-12-07 13:56:29 +01003611 if (spec->channel_mode) {
3612 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3613 for (i = 0; i < spec->num_channel_mode; i++) {
3614 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3615 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3616 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003617 }
3618 }
3619
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003620 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003621 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003622 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003623 snprintf(spec->stream_name_digital,
3624 sizeof(spec->stream_name_digital),
3625 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003626 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003627 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003628 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003629 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003630 if (spec->dig_out_type)
3631 info->pcm_type = spec->dig_out_type;
3632 else
3633 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003634 if (spec->multiout.dig_out_nid &&
3635 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003636 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3637 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3638 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003639 if (spec->dig_in_nid &&
3640 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003641 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3642 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3643 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003644 /* FIXME: do we need this for all Realtek codec models? */
3645 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003646 }
3647
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003648 if (spec->no_analog)
3649 return 0;
3650
Takashi Iwaie08a0072006-09-07 17:52:14 +02003651 /* If the use of more than one ADC is requested for the current
3652 * model, configure a second analog capture-only PCM.
3653 */
3654 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003655 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3656 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003657 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003658 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003659 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003660 if (spec->alt_dac_nid) {
3661 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3662 *spec->stream_analog_alt_playback;
3663 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3664 spec->alt_dac_nid;
3665 } else {
3666 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3667 alc_pcm_null_stream;
3668 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3669 }
3670 if (spec->num_adc_nids > 1) {
3671 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3672 *spec->stream_analog_alt_capture;
3673 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3674 spec->adc_nids[1];
3675 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3676 spec->num_adc_nids - 1;
3677 } else {
3678 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3679 alc_pcm_null_stream;
3680 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003681 }
3682 }
3683
Linus Torvalds1da177e2005-04-16 15:20:36 -07003684 return 0;
3685}
3686
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003687static inline void alc_shutup(struct hda_codec *codec)
3688{
3689 snd_hda_shutup_pins(codec);
3690}
3691
Takashi Iwai603c4012008-07-30 15:01:44 +02003692static void alc_free_kctls(struct hda_codec *codec)
3693{
3694 struct alc_spec *spec = codec->spec;
3695
3696 if (spec->kctls.list) {
3697 struct snd_kcontrol_new *kctl = spec->kctls.list;
3698 int i;
3699 for (i = 0; i < spec->kctls.used; i++)
3700 kfree(kctl[i].name);
3701 }
3702 snd_array_free(&spec->kctls);
3703}
3704
Linus Torvalds1da177e2005-04-16 15:20:36 -07003705static void alc_free(struct hda_codec *codec)
3706{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003707 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003708
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003709 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003710 return;
3711
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003712 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003713 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003715 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003716}
3717
Hector Martinf5de24b2009-12-20 22:51:31 +01003718#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003719static void alc_power_eapd(struct hda_codec *codec)
3720{
3721 /* We currently only handle front, HP */
3722 switch (codec->vendor_id) {
3723 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003724 set_eapd(codec, 0x0f, 0);
3725 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003726 break;
3727 case 0x10ec0262:
3728 case 0x10ec0267:
3729 case 0x10ec0268:
3730 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003731 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003732 case 0x10ec0272:
3733 case 0x10ec0660:
3734 case 0x10ec0662:
3735 case 0x10ec0663:
3736 case 0x10ec0862:
3737 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003738 set_eapd(codec, 0x14, 0);
3739 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003740 break;
3741 }
3742}
3743
Hector Martinf5de24b2009-12-20 22:51:31 +01003744static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3745{
3746 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003747 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003748 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003749 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003750 return 0;
3751}
3752#endif
3753
Takashi Iwaie044c392008-10-27 16:56:24 +01003754#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003755static int alc_resume(struct hda_codec *codec)
3756{
Takashi Iwaie044c392008-10-27 16:56:24 +01003757 codec->patch_ops.init(codec);
3758 snd_hda_codec_resume_amp(codec);
3759 snd_hda_codec_resume_cache(codec);
3760 return 0;
3761}
Takashi Iwaie044c392008-10-27 16:56:24 +01003762#endif
3763
Linus Torvalds1da177e2005-04-16 15:20:36 -07003764/*
3765 */
3766static struct hda_codec_ops alc_patch_ops = {
3767 .build_controls = alc_build_controls,
3768 .build_pcms = alc_build_pcms,
3769 .init = alc_init,
3770 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003771 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003772#ifdef SND_HDA_NEEDS_RESUME
3773 .resume = alc_resume,
3774#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003775#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003776 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003777 .check_power_status = alc_check_power_status,
3778#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003779 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003780};
3781
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003782
3783/*
3784 * Test configuration for debugging
3785 *
3786 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3787 * enum controls.
3788 */
3789#ifdef CONFIG_SND_DEBUG
3790static hda_nid_t alc880_test_dac_nids[4] = {
3791 0x02, 0x03, 0x04, 0x05
3792};
3793
3794static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003795 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003796 .items = {
3797 { "In-1", 0x0 },
3798 { "In-2", 0x1 },
3799 { "In-3", 0x2 },
3800 { "In-4", 0x3 },
3801 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003802 { "Front", 0x5 },
3803 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003804 },
3805};
3806
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003807static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003808 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003809 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003810 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003811 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003812};
3813
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003814static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3815 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003816{
3817 static char *texts[] = {
3818 "N/A", "Line Out", "HP Out",
3819 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3820 };
3821 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3822 uinfo->count = 1;
3823 uinfo->value.enumerated.items = 8;
3824 if (uinfo->value.enumerated.item >= 8)
3825 uinfo->value.enumerated.item = 7;
3826 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3827 return 0;
3828}
3829
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003830static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3831 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003832{
3833 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3834 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3835 unsigned int pin_ctl, item = 0;
3836
3837 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3838 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3839 if (pin_ctl & AC_PINCTL_OUT_EN) {
3840 if (pin_ctl & AC_PINCTL_HP_EN)
3841 item = 2;
3842 else
3843 item = 1;
3844 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3845 switch (pin_ctl & AC_PINCTL_VREFEN) {
3846 case AC_PINCTL_VREF_HIZ: item = 3; break;
3847 case AC_PINCTL_VREF_50: item = 4; break;
3848 case AC_PINCTL_VREF_GRD: item = 5; break;
3849 case AC_PINCTL_VREF_80: item = 6; break;
3850 case AC_PINCTL_VREF_100: item = 7; break;
3851 }
3852 }
3853 ucontrol->value.enumerated.item[0] = item;
3854 return 0;
3855}
3856
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003857static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3858 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003859{
3860 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3861 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3862 static unsigned int ctls[] = {
3863 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3864 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3865 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3866 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3867 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3868 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3869 };
3870 unsigned int old_ctl, new_ctl;
3871
3872 old_ctl = snd_hda_codec_read(codec, nid, 0,
3873 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3874 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3875 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003876 int val;
3877 snd_hda_codec_write_cache(codec, nid, 0,
3878 AC_VERB_SET_PIN_WIDGET_CONTROL,
3879 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003880 val = ucontrol->value.enumerated.item[0] >= 3 ?
3881 HDA_AMP_MUTE : 0;
3882 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3883 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003884 return 1;
3885 }
3886 return 0;
3887}
3888
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003889static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3890 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003891{
3892 static char *texts[] = {
3893 "Front", "Surround", "CLFE", "Side"
3894 };
3895 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3896 uinfo->count = 1;
3897 uinfo->value.enumerated.items = 4;
3898 if (uinfo->value.enumerated.item >= 4)
3899 uinfo->value.enumerated.item = 3;
3900 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3901 return 0;
3902}
3903
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003904static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3905 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003906{
3907 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3908 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3909 unsigned int sel;
3910
3911 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3912 ucontrol->value.enumerated.item[0] = sel & 3;
3913 return 0;
3914}
3915
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003916static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3917 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003918{
3919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3920 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3921 unsigned int sel;
3922
3923 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3924 if (ucontrol->value.enumerated.item[0] != sel) {
3925 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003926 snd_hda_codec_write_cache(codec, nid, 0,
3927 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003928 return 1;
3929 }
3930 return 0;
3931}
3932
3933#define PIN_CTL_TEST(xname,nid) { \
3934 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3935 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003936 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003937 .info = alc_test_pin_ctl_info, \
3938 .get = alc_test_pin_ctl_get, \
3939 .put = alc_test_pin_ctl_put, \
3940 .private_value = nid \
3941 }
3942
3943#define PIN_SRC_TEST(xname,nid) { \
3944 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3945 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003946 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003947 .info = alc_test_pin_src_info, \
3948 .get = alc_test_pin_src_get, \
3949 .put = alc_test_pin_src_put, \
3950 .private_value = nid \
3951 }
3952
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003953static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003954 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3955 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3956 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3957 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003958 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3959 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3960 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3961 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003962 PIN_CTL_TEST("Front Pin Mode", 0x14),
3963 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3964 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3965 PIN_CTL_TEST("Side Pin Mode", 0x17),
3966 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3967 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3968 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3969 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3970 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3971 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3972 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3973 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3974 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3975 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3976 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3977 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3978 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3979 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3980 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3981 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3982 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3983 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003984 {
3985 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3986 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003987 .info = alc_ch_mode_info,
3988 .get = alc_ch_mode_get,
3989 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003990 },
3991 { } /* end */
3992};
3993
3994static struct hda_verb alc880_test_init_verbs[] = {
3995 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4000 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4002 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004004 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004005 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4006 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4007 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4008 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004009 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4013 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004014 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004015 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4018 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004019 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004020 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4021 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004022 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4024 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004025 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004026 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4027 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4028 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4029 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004030 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004031 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004032 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004033 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004034 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004035 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004036 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004037 /* Analog input/passthru */
4038 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004043 { }
4044};
4045#endif
4046
Linus Torvalds1da177e2005-04-16 15:20:36 -07004047/*
4048 */
4049
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004050static const char *alc880_models[ALC880_MODEL_LAST] = {
4051 [ALC880_3ST] = "3stack",
4052 [ALC880_TCL_S700] = "tcl",
4053 [ALC880_3ST_DIG] = "3stack-digout",
4054 [ALC880_CLEVO] = "clevo",
4055 [ALC880_5ST] = "5stack",
4056 [ALC880_5ST_DIG] = "5stack-digout",
4057 [ALC880_W810] = "w810",
4058 [ALC880_Z71V] = "z71v",
4059 [ALC880_6ST] = "6stack",
4060 [ALC880_6ST_DIG] = "6stack-digout",
4061 [ALC880_ASUS] = "asus",
4062 [ALC880_ASUS_W1V] = "asus-w1v",
4063 [ALC880_ASUS_DIG] = "asus-dig",
4064 [ALC880_ASUS_DIG2] = "asus-dig2",
4065 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004066 [ALC880_UNIWILL_P53] = "uniwill-p53",
4067 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004068 [ALC880_F1734] = "F1734",
4069 [ALC880_LG] = "lg",
4070 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004071 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004072#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004073 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004074#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004075 [ALC880_AUTO] = "auto",
4076};
4077
4078static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004079 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004080 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4081 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4082 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4083 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4084 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4085 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4086 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4087 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004088 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4089 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004090 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4091 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4092 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4093 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4094 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4095 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4096 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4097 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4098 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4099 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004100 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004101 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4102 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4103 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004104 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004105 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004106 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4107 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004108 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4109 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004110 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4111 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4112 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4113 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004114 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4115 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004116 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004117 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004118 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004119 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004120 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4121 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004122 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004123 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004124 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004125 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004127 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004128 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004129 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004130 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004131 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4132 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004133 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004134 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4135 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4136 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4137 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004138 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4139 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004140 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004141 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004142 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4143 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004144 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4145 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4146 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004147 /* default Intel */
4148 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004149 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4150 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004151 {}
4152};
4153
Takashi Iwai16ded522005-06-10 19:58:24 +02004154/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004155 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004156 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004157static struct alc_config_preset alc880_presets[] = {
4158 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004159 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004160 .init_verbs = { alc880_volume_init_verbs,
4161 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004162 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004164 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4165 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004166 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004167 .input_mux = &alc880_capture_source,
4168 },
4169 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004171 .init_verbs = { alc880_volume_init_verbs,
4172 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004173 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .dac_nids = alc880_dac_nids,
4175 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004176 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4177 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004178 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004179 .input_mux = &alc880_capture_source,
4180 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004181 [ALC880_TCL_S700] = {
4182 .mixers = { alc880_tcl_s700_mixer },
4183 .init_verbs = { alc880_volume_init_verbs,
4184 alc880_pin_tcl_S700_init_verbs,
4185 alc880_gpio2_init_verbs },
4186 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4187 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004188 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4189 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004190 .hp_nid = 0x03,
4191 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4192 .channel_mode = alc880_2_jack_modes,
4193 .input_mux = &alc880_capture_source,
4194 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004195 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004196 .mixers = { alc880_three_stack_mixer,
4197 alc880_five_stack_mixer},
4198 .init_verbs = { alc880_volume_init_verbs,
4199 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004200 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4201 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004202 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4203 .channel_mode = alc880_fivestack_modes,
4204 .input_mux = &alc880_capture_source,
4205 },
4206 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004207 .mixers = { alc880_three_stack_mixer,
4208 alc880_five_stack_mixer },
4209 .init_verbs = { alc880_volume_init_verbs,
4210 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004211 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4212 .dac_nids = alc880_dac_nids,
4213 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004214 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4215 .channel_mode = alc880_fivestack_modes,
4216 .input_mux = &alc880_capture_source,
4217 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004218 [ALC880_6ST] = {
4219 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004220 .init_verbs = { alc880_volume_init_verbs,
4221 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004222 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4223 .dac_nids = alc880_6st_dac_nids,
4224 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4225 .channel_mode = alc880_sixstack_modes,
4226 .input_mux = &alc880_6stack_capture_source,
4227 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004228 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004229 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004230 .init_verbs = { alc880_volume_init_verbs,
4231 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004232 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4233 .dac_nids = alc880_6st_dac_nids,
4234 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004235 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4236 .channel_mode = alc880_sixstack_modes,
4237 .input_mux = &alc880_6stack_capture_source,
4238 },
4239 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004240 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004241 .init_verbs = { alc880_volume_init_verbs,
4242 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004243 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004244 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4245 .dac_nids = alc880_w810_dac_nids,
4246 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004247 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4248 .channel_mode = alc880_w810_modes,
4249 .input_mux = &alc880_capture_source,
4250 },
4251 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004252 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004253 .init_verbs = { alc880_volume_init_verbs,
4254 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004255 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4256 .dac_nids = alc880_z71v_dac_nids,
4257 .dig_out_nid = ALC880_DIGOUT_NID,
4258 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004259 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4260 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004261 .input_mux = &alc880_capture_source,
4262 },
4263 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004264 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004265 .init_verbs = { alc880_volume_init_verbs,
4266 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004267 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4268 .dac_nids = alc880_f1734_dac_nids,
4269 .hp_nid = 0x02,
4270 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4271 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004272 .input_mux = &alc880_f1734_capture_source,
4273 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004274 .setup = alc880_uniwill_p53_setup,
4275 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004276 },
4277 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004278 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004279 .init_verbs = { alc880_volume_init_verbs,
4280 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004281 alc880_gpio1_init_verbs },
4282 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4283 .dac_nids = alc880_asus_dac_nids,
4284 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4285 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004286 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004287 .input_mux = &alc880_capture_source,
4288 },
4289 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004290 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004291 .init_verbs = { alc880_volume_init_verbs,
4292 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004293 alc880_gpio1_init_verbs },
4294 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4295 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004296 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004297 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4298 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004299 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004300 .input_mux = &alc880_capture_source,
4301 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004302 [ALC880_ASUS_DIG2] = {
4303 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004304 .init_verbs = { alc880_volume_init_verbs,
4305 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004306 alc880_gpio2_init_verbs }, /* use GPIO2 */
4307 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4308 .dac_nids = alc880_asus_dac_nids,
4309 .dig_out_nid = ALC880_DIGOUT_NID,
4310 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4311 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004312 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004313 .input_mux = &alc880_capture_source,
4314 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004315 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004316 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004317 .init_verbs = { alc880_volume_init_verbs,
4318 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004319 alc880_gpio1_init_verbs },
4320 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4321 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004322 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004323 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4324 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004325 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004326 .input_mux = &alc880_capture_source,
4327 },
4328 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004329 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004330 .init_verbs = { alc880_volume_init_verbs,
4331 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004332 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4333 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004334 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004335 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4336 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004337 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004338 .input_mux = &alc880_capture_source,
4339 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004340 [ALC880_UNIWILL] = {
4341 .mixers = { alc880_uniwill_mixer },
4342 .init_verbs = { alc880_volume_init_verbs,
4343 alc880_uniwill_init_verbs },
4344 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4345 .dac_nids = alc880_asus_dac_nids,
4346 .dig_out_nid = ALC880_DIGOUT_NID,
4347 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4348 .channel_mode = alc880_threestack_modes,
4349 .need_dac_fix = 1,
4350 .input_mux = &alc880_capture_source,
4351 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004352 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004353 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004354 },
4355 [ALC880_UNIWILL_P53] = {
4356 .mixers = { alc880_uniwill_p53_mixer },
4357 .init_verbs = { alc880_volume_init_verbs,
4358 alc880_uniwill_p53_init_verbs },
4359 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4360 .dac_nids = alc880_asus_dac_nids,
4361 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004362 .channel_mode = alc880_threestack_modes,
4363 .input_mux = &alc880_capture_source,
4364 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004365 .setup = alc880_uniwill_p53_setup,
4366 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004367 },
4368 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004369 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004370 .init_verbs = { alc880_volume_init_verbs,
4371 alc880_uniwill_p53_init_verbs,
4372 alc880_beep_init_verbs },
4373 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4374 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004375 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004376 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4377 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004378 .input_mux = &alc880_capture_source,
4379 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004380 .setup = alc880_uniwill_p53_setup,
4381 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004382 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004383 [ALC880_CLEVO] = {
4384 .mixers = { alc880_three_stack_mixer },
4385 .init_verbs = { alc880_volume_init_verbs,
4386 alc880_pin_clevo_init_verbs },
4387 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4388 .dac_nids = alc880_dac_nids,
4389 .hp_nid = 0x03,
4390 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4391 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004392 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004393 .input_mux = &alc880_capture_source,
4394 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004395 [ALC880_LG] = {
4396 .mixers = { alc880_lg_mixer },
4397 .init_verbs = { alc880_volume_init_verbs,
4398 alc880_lg_init_verbs },
4399 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4400 .dac_nids = alc880_lg_dac_nids,
4401 .dig_out_nid = ALC880_DIGOUT_NID,
4402 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4403 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004404 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004405 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004406 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004407 .setup = alc880_lg_setup,
4408 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004409#ifdef CONFIG_SND_HDA_POWER_SAVE
4410 .loopbacks = alc880_lg_loopbacks,
4411#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004412 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004413 [ALC880_LG_LW] = {
4414 .mixers = { alc880_lg_lw_mixer },
4415 .init_verbs = { alc880_volume_init_verbs,
4416 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004417 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004418 .dac_nids = alc880_dac_nids,
4419 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004420 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4421 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004422 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004423 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004424 .setup = alc880_lg_lw_setup,
4425 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004426 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004427 [ALC880_MEDION_RIM] = {
4428 .mixers = { alc880_medion_rim_mixer },
4429 .init_verbs = { alc880_volume_init_verbs,
4430 alc880_medion_rim_init_verbs,
4431 alc_gpio2_init_verbs },
4432 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4433 .dac_nids = alc880_dac_nids,
4434 .dig_out_nid = ALC880_DIGOUT_NID,
4435 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4436 .channel_mode = alc880_2_jack_modes,
4437 .input_mux = &alc880_medion_rim_capture_source,
4438 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004439 .setup = alc880_medion_rim_setup,
4440 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004441 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004442#ifdef CONFIG_SND_DEBUG
4443 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004444 .mixers = { alc880_test_mixer },
4445 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004446 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4447 .dac_nids = alc880_test_dac_nids,
4448 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004449 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4450 .channel_mode = alc880_test_modes,
4451 .input_mux = &alc880_test_capture_source,
4452 },
4453#endif
4454};
4455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004456/*
4457 * Automatic parse of I/O pins from the BIOS configuration
4458 */
4459
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004460enum {
4461 ALC_CTL_WIDGET_VOL,
4462 ALC_CTL_WIDGET_MUTE,
4463 ALC_CTL_BIND_MUTE,
4464};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004465static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004466 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4467 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004468 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004469};
4470
4471/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004472static int add_control(struct alc_spec *spec, int type, const char *name,
4473 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004474{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004475 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004476
Takashi Iwai603c4012008-07-30 15:01:44 +02004477 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4478 knew = snd_array_new(&spec->kctls);
4479 if (!knew)
4480 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004481 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004482 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004483 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004484 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004485 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004486 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004487 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 return 0;
4489}
4490
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004491static int add_control_with_pfx(struct alc_spec *spec, int type,
4492 const char *pfx, const char *dir,
4493 const char *sfx, unsigned long val)
4494{
4495 char name[32];
4496 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4497 return add_control(spec, type, name, val);
4498}
4499
4500#define add_pb_vol_ctrl(spec, type, pfx, val) \
4501 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4502#define add_pb_sw_ctrl(spec, type, pfx, val) \
4503 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4504
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004505#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4506#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4507#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4508#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004509#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4510#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4511#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4512#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4513#define ALC880_PIN_CD_NID 0x1c
4514
4515/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004516static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4517 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004518{
4519 hda_nid_t nid;
4520 int assigned[4];
4521 int i, j;
4522
4523 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004524 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004525
4526 /* check the pins hardwired to audio widget */
4527 for (i = 0; i < cfg->line_outs; i++) {
4528 nid = cfg->line_out_pins[i];
4529 if (alc880_is_fixed_pin(nid)) {
4530 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004531 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004532 assigned[idx] = 1;
4533 }
4534 }
4535 /* left pins can be connect to any audio widget */
4536 for (i = 0; i < cfg->line_outs; i++) {
4537 nid = cfg->line_out_pins[i];
4538 if (alc880_is_fixed_pin(nid))
4539 continue;
4540 /* search for an empty channel */
4541 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004542 if (!assigned[j]) {
4543 spec->multiout.dac_nids[i] =
4544 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004545 assigned[j] = 1;
4546 break;
4547 }
4548 }
4549 }
4550 spec->multiout.num_dacs = cfg->line_outs;
4551 return 0;
4552}
4553
4554/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004555static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4556 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004557{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004558 static const char *chname[4] = {
4559 "Front", "Surround", NULL /*CLFE*/, "Side"
4560 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004561 hda_nid_t nid;
4562 int i, err;
4563
4564 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004565 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004566 continue;
4567 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4568 if (i == 2) {
4569 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004570 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4571 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004572 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4573 HDA_OUTPUT));
4574 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004575 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004576 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4577 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004578 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4579 HDA_OUTPUT));
4580 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004581 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004582 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4583 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004584 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4585 HDA_INPUT));
4586 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004587 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004588 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4589 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004590 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4591 HDA_INPUT));
4592 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004593 return err;
4594 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004595 const char *pfx;
4596 if (cfg->line_outs == 1 &&
4597 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4598 pfx = "Speaker";
4599 else
4600 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004601 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004602 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4603 HDA_OUTPUT));
4604 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004605 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004606 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004607 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4608 HDA_INPUT));
4609 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004610 return err;
4611 }
4612 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 return 0;
4614}
4615
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004616/* add playback controls for speaker and HP outputs */
4617static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4618 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004619{
4620 hda_nid_t nid;
4621 int err;
4622
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004623 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004624 return 0;
4625
4626 if (alc880_is_fixed_pin(pin)) {
4627 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004628 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004629 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004630 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004631 else
4632 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004633 /* control HP volume/switch on the output mixer amp */
4634 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004635 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004636 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4637 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004638 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004639 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004640 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4641 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 return err;
4643 } else if (alc880_is_multi_pin(pin)) {
4644 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004645 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004646 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004647 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4648 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004649 return err;
4650 }
4651 return 0;
4652}
4653
4654/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004655static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4656 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004657 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004658{
Kailang Yangdf694da2005-12-05 19:42:22 +01004659 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004660
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004661 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004662 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4663 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004664 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004665 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004666 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4667 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004668 return err;
4669 return 0;
4670}
4671
Takashi Iwai05f5f472009-08-25 13:10:18 +02004672static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004673{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004674 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4675 return (pincap & AC_PINCAP_IN) != 0;
4676}
4677
4678/* create playback/capture controls for input pins */
4679static int alc_auto_create_input_ctls(struct hda_codec *codec,
4680 const struct auto_pin_cfg *cfg,
4681 hda_nid_t mixer,
4682 hda_nid_t cap1, hda_nid_t cap2)
4683{
4684 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004685 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004686 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004687
4688 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004689 hda_nid_t pin;
4690
4691 pin = cfg->input_pins[i];
4692 if (!alc_is_input_pin(codec, pin))
4693 continue;
4694
4695 if (mixer) {
4696 idx = get_connection_index(codec, mixer, pin);
4697 if (idx >= 0) {
4698 err = new_analog_input(spec, pin,
4699 auto_pin_cfg_labels[i],
4700 idx, mixer);
4701 if (err < 0)
4702 return err;
4703 }
4704 }
4705
4706 if (!cap1)
4707 continue;
4708 idx = get_connection_index(codec, cap1, pin);
4709 if (idx < 0 && cap2)
4710 idx = get_connection_index(codec, cap2, pin);
4711 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 imux->items[imux->num_items].label =
4713 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004714 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004715 imux->num_items++;
4716 }
4717 }
4718 return 0;
4719}
4720
Takashi Iwai05f5f472009-08-25 13:10:18 +02004721static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4722 const struct auto_pin_cfg *cfg)
4723{
4724 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4725}
4726
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004727static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4728 unsigned int pin_type)
4729{
4730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4731 pin_type);
4732 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004733 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4734 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004735}
4736
Kailang Yangdf694da2005-12-05 19:42:22 +01004737static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4738 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004739 int dac_idx)
4740{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004741 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004742 /* need the manual connection? */
4743 if (alc880_is_multi_pin(nid)) {
4744 struct alc_spec *spec = codec->spec;
4745 int idx = alc880_multi_pin_idx(nid);
4746 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4747 AC_VERB_SET_CONNECT_SEL,
4748 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4749 }
4750}
4751
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004752static int get_pin_type(int line_out_type)
4753{
4754 if (line_out_type == AUTO_PIN_HP_OUT)
4755 return PIN_HP;
4756 else
4757 return PIN_OUT;
4758}
4759
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004760static void alc880_auto_init_multi_out(struct hda_codec *codec)
4761{
4762 struct alc_spec *spec = codec->spec;
4763 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004764
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004765 for (i = 0; i < spec->autocfg.line_outs; i++) {
4766 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004767 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4768 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004769 }
4770}
4771
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004772static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004773{
4774 struct alc_spec *spec = codec->spec;
4775 hda_nid_t pin;
4776
Takashi Iwai82bc9552006-03-21 11:24:42 +01004777 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004778 if (pin) /* connect to front */
4779 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004780 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004781 if (pin) /* connect to front */
4782 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4783}
4784
4785static void alc880_auto_init_analog_input(struct hda_codec *codec)
4786{
4787 struct alc_spec *spec = codec->spec;
4788 int i;
4789
4790 for (i = 0; i < AUTO_PIN_LAST; i++) {
4791 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004792 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004793 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004794 if (nid != ALC880_PIN_CD_NID &&
4795 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004796 snd_hda_codec_write(codec, nid, 0,
4797 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004798 AMP_OUT_MUTE);
4799 }
4800 }
4801}
4802
4803/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004804/* return 1 if successful, 0 if the proper config is not found,
4805 * or a negative error code
4806 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004807static int alc880_parse_auto_config(struct hda_codec *codec)
4808{
4809 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004810 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004811 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004812
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004813 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4814 alc880_ignore);
4815 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004816 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004817 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004818 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004819
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4821 if (err < 0)
4822 return err;
4823 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4824 if (err < 0)
4825 return err;
4826 err = alc880_auto_create_extra_out(spec,
4827 spec->autocfg.speaker_pins[0],
4828 "Speaker");
4829 if (err < 0)
4830 return err;
4831 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4832 "Headphone");
4833 if (err < 0)
4834 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004835 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004836 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004837 return err;
4838
4839 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4840
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004841 /* check multiple SPDIF-out (for recent codecs) */
4842 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4843 hda_nid_t dig_nid;
4844 err = snd_hda_get_connections(codec,
4845 spec->autocfg.dig_out_pins[i],
4846 &dig_nid, 1);
4847 if (err < 0)
4848 continue;
4849 if (!i)
4850 spec->multiout.dig_out_nid = dig_nid;
4851 else {
4852 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004853 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004854 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004855 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004856 }
4857 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004858 if (spec->autocfg.dig_in_pin)
4859 spec->dig_in_nid = ALC880_DIGIN_NID;
4860
Takashi Iwai603c4012008-07-30 15:01:44 +02004861 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004862 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004863
Takashi Iwaid88897e2008-10-31 15:01:37 +01004864 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004865
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004866 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004867 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004868
Kailang Yang6227cdc2010-02-25 08:36:52 +01004869 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871 return 1;
4872}
4873
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004874/* additional initialization for auto-configuration model */
4875static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004876{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004877 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004878 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004879 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004880 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004881 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004882 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004883}
4884
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004885/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4886 * one of two digital mic pins, e.g. on ALC272
4887 */
4888static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004889{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004890 struct alc_spec *spec = codec->spec;
4891 int i;
4892
4893 for (i = 0; i < spec->num_adc_nids; i++) {
4894 hda_nid_t cap = spec->capsrc_nids ?
4895 spec->capsrc_nids[i] : spec->adc_nids[i];
4896 int iidx, eidx;
4897
4898 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4899 if (iidx < 0)
4900 continue;
4901 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4902 if (eidx < 0)
4903 continue;
4904 spec->int_mic.mux_idx = iidx;
4905 spec->ext_mic.mux_idx = eidx;
4906 if (spec->capsrc_nids)
4907 spec->capsrc_nids += i;
4908 spec->adc_nids += i;
4909 spec->num_adc_nids = 1;
4910 return;
4911 }
4912 snd_printd(KERN_INFO "hda_codec: %s: "
4913 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4914 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4915 spec->auto_mic = 0; /* disable auto-mic to be sure */
4916}
4917
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004918/* choose the ADC/MUX containing the input pin and initialize the setup */
4919static void fixup_single_adc(struct hda_codec *codec)
4920{
4921 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01004922 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004923 int i;
4924
4925 /* search for the input pin; there must be only one */
4926 for (i = 0; i < AUTO_PIN_LAST; i++) {
4927 if (spec->autocfg.input_pins[i]) {
4928 pin = spec->autocfg.input_pins[i];
4929 break;
4930 }
4931 }
4932 if (!pin)
4933 return;
4934
4935 /* set the default connection to that pin */
4936 for (i = 0; i < spec->num_adc_nids; i++) {
4937 hda_nid_t cap = spec->capsrc_nids ?
4938 spec->capsrc_nids[i] : spec->adc_nids[i];
4939 int idx;
4940
4941 idx = get_connection_index(codec, cap, pin);
4942 if (idx < 0)
4943 continue;
4944 /* use only this ADC */
4945 if (spec->capsrc_nids)
4946 spec->capsrc_nids += i;
4947 spec->adc_nids += i;
4948 spec->num_adc_nids = 1;
4949 /* select or unmute this route */
4950 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4951 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4952 HDA_AMP_MUTE, 0);
4953 } else {
4954 snd_hda_codec_write_cache(codec, cap, 0,
4955 AC_VERB_SET_CONNECT_SEL, idx);
4956 }
4957 return;
4958 }
4959}
4960
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004961static void set_capture_mixer(struct hda_codec *codec)
4962{
4963 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004964 static struct snd_kcontrol_new *caps[2][3] = {
4965 { alc_capture_mixer_nosrc1,
4966 alc_capture_mixer_nosrc2,
4967 alc_capture_mixer_nosrc3 },
4968 { alc_capture_mixer1,
4969 alc_capture_mixer2,
4970 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004971 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004972 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004973 int mux = 0;
4974 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004975 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004976 else if (spec->input_mux) {
4977 if (spec->input_mux->num_items > 1)
4978 mux = 1;
4979 else if (spec->input_mux->num_items == 1)
4980 fixup_single_adc(codec);
4981 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004982 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4983 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004984}
4985
Takashi Iwai67d634c2009-11-16 15:35:59 +01004986#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004987#define set_beep_amp(spec, nid, idx, dir) \
4988 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004989#else
4990#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4991#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004992
4993/*
4994 * OK, here we have finally the patch for ALC880
4995 */
4996
Linus Torvalds1da177e2005-04-16 15:20:36 -07004997static int patch_alc880(struct hda_codec *codec)
4998{
4999 struct alc_spec *spec;
5000 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005001 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005002
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005004 if (spec == NULL)
5005 return -ENOMEM;
5006
5007 codec->spec = spec;
5008
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005009 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5010 alc880_models,
5011 alc880_cfg_tbl);
5012 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005013 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5014 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005015 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005016 }
5017
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005018 if (board_config == ALC880_AUTO) {
5019 /* automatic parse from the BIOS config */
5020 err = alc880_parse_auto_config(codec);
5021 if (err < 0) {
5022 alc_free(codec);
5023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005024 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005025 printk(KERN_INFO
5026 "hda_codec: Cannot set up configuration "
5027 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005028 board_config = ALC880_3ST;
5029 }
5030 }
5031
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005032 err = snd_hda_attach_beep_device(codec, 0x1);
5033 if (err < 0) {
5034 alc_free(codec);
5035 return err;
5036 }
5037
Kailang Yangdf694da2005-12-05 19:42:22 +01005038 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005039 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005040
Linus Torvalds1da177e2005-04-16 15:20:36 -07005041 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5042 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005043 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005044
Linus Torvalds1da177e2005-04-16 15:20:36 -07005045 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5046 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5047
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005048 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005050 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005051 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005052 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 if (wcap != AC_WID_AUD_IN) {
5054 spec->adc_nids = alc880_adc_nids_alt;
5055 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005056 } else {
5057 spec->adc_nids = alc880_adc_nids;
5058 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005059 }
5060 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005061 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005062 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005063
Takashi Iwai2134ea42008-01-10 16:53:55 +01005064 spec->vmaster_nid = 0x0c;
5065
Linus Torvalds1da177e2005-04-16 15:20:36 -07005066 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005067 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005068 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005069#ifdef CONFIG_SND_HDA_POWER_SAVE
5070 if (!spec->loopback.amplist)
5071 spec->loopback.amplist = alc880_loopbacks;
5072#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005073
5074 return 0;
5075}
5076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005077
Linus Torvalds1da177e2005-04-16 15:20:36 -07005078/*
5079 * ALC260 support
5080 */
5081
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005082static hda_nid_t alc260_dac_nids[1] = {
5083 /* front */
5084 0x02,
5085};
5086
5087static hda_nid_t alc260_adc_nids[1] = {
5088 /* ADC0 */
5089 0x04,
5090};
5091
Kailang Yangdf694da2005-12-05 19:42:22 +01005092static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005093 /* ADC1 */
5094 0x05,
5095};
5096
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005097/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5098 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5099 */
5100static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005101 /* ADC0, ADC1 */
5102 0x04, 0x05
5103};
5104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005105#define ALC260_DIGOUT_NID 0x03
5106#define ALC260_DIGIN_NID 0x06
5107
5108static struct hda_input_mux alc260_capture_source = {
5109 .num_items = 4,
5110 .items = {
5111 { "Mic", 0x0 },
5112 { "Front Mic", 0x1 },
5113 { "Line", 0x2 },
5114 { "CD", 0x4 },
5115 },
5116};
5117
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005118/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005119 * headphone jack and the internal CD lines since these are the only pins at
5120 * which audio can appear. For flexibility, also allow the option of
5121 * recording the mixer output on the second ADC (ADC0 doesn't have a
5122 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005123 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005124static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5125 {
5126 .num_items = 3,
5127 .items = {
5128 { "Mic/Line", 0x0 },
5129 { "CD", 0x4 },
5130 { "Headphone", 0x2 },
5131 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005132 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005133 {
5134 .num_items = 4,
5135 .items = {
5136 { "Mic/Line", 0x0 },
5137 { "CD", 0x4 },
5138 { "Headphone", 0x2 },
5139 { "Mixer", 0x5 },
5140 },
5141 },
5142
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005143};
5144
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005145/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5146 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005147 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005148static struct hda_input_mux alc260_acer_capture_sources[2] = {
5149 {
5150 .num_items = 4,
5151 .items = {
5152 { "Mic", 0x0 },
5153 { "Line", 0x2 },
5154 { "CD", 0x4 },
5155 { "Headphone", 0x5 },
5156 },
5157 },
5158 {
5159 .num_items = 5,
5160 .items = {
5161 { "Mic", 0x0 },
5162 { "Line", 0x2 },
5163 { "CD", 0x4 },
5164 { "Headphone", 0x6 },
5165 { "Mixer", 0x5 },
5166 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005167 },
5168};
Michael Schwingencc959482009-02-22 18:58:45 +01005169
5170/* Maxdata Favorit 100XS */
5171static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5172 {
5173 .num_items = 2,
5174 .items = {
5175 { "Line/Mic", 0x0 },
5176 { "CD", 0x4 },
5177 },
5178 },
5179 {
5180 .num_items = 3,
5181 .items = {
5182 { "Line/Mic", 0x0 },
5183 { "CD", 0x4 },
5184 { "Mixer", 0x5 },
5185 },
5186 },
5187};
5188
Linus Torvalds1da177e2005-04-16 15:20:36 -07005189/*
5190 * This is just place-holder, so there's something for alc_build_pcms to look
5191 * at when it calculates the maximum number of channels. ALC260 has no mixer
5192 * element which allows changing the channel mode, so the verb list is
5193 * never used.
5194 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005195static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005196 { 2, NULL },
5197};
5198
Kailang Yangdf694da2005-12-05 19:42:22 +01005199
5200/* Mixer combinations
5201 *
5202 * basic: base_output + input + pc_beep + capture
5203 * HP: base_output + input + capture_alt
5204 * HP_3013: hp_3013 + input + capture
5205 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005206 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005207 */
5208
5209static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005210 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005211 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005212 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5213 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5214 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5215 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5216 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005217};
Kailang Yangdf694da2005-12-05 19:42:22 +01005218
5219static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005220 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5221 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5222 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5223 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5225 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005228 { } /* end */
5229};
5230
Takashi Iwaibec15c32008-01-28 18:16:30 +01005231/* update HP, line and mono out pins according to the master switch */
5232static void alc260_hp_master_update(struct hda_codec *codec,
5233 hda_nid_t hp, hda_nid_t line,
5234 hda_nid_t mono)
5235{
5236 struct alc_spec *spec = codec->spec;
5237 unsigned int val = spec->master_sw ? PIN_HP : 0;
5238 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005239 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005240 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005241 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005242 val);
5243 /* mono (speaker) depending on the HP jack sense */
5244 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005245 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005246 val);
5247}
5248
5249static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5250 struct snd_ctl_elem_value *ucontrol)
5251{
5252 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5253 struct alc_spec *spec = codec->spec;
5254 *ucontrol->value.integer.value = spec->master_sw;
5255 return 0;
5256}
5257
5258static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5259 struct snd_ctl_elem_value *ucontrol)
5260{
5261 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5262 struct alc_spec *spec = codec->spec;
5263 int val = !!*ucontrol->value.integer.value;
5264 hda_nid_t hp, line, mono;
5265
5266 if (val == spec->master_sw)
5267 return 0;
5268 spec->master_sw = val;
5269 hp = (kcontrol->private_value >> 16) & 0xff;
5270 line = (kcontrol->private_value >> 8) & 0xff;
5271 mono = kcontrol->private_value & 0xff;
5272 alc260_hp_master_update(codec, hp, line, mono);
5273 return 1;
5274}
5275
5276static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5277 {
5278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5279 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005280 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005281 .info = snd_ctl_boolean_mono_info,
5282 .get = alc260_hp_master_sw_get,
5283 .put = alc260_hp_master_sw_put,
5284 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5285 },
5286 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5287 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5289 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5290 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5291 HDA_OUTPUT),
5292 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5293 { } /* end */
5294};
5295
5296static struct hda_verb alc260_hp_unsol_verbs[] = {
5297 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5298 {},
5299};
5300
5301static void alc260_hp_automute(struct hda_codec *codec)
5302{
5303 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005304
Wu Fengguang864f92b2009-11-18 12:38:02 +08005305 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005306 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5307}
5308
5309static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5310{
5311 if ((res >> 26) == ALC880_HP_EVENT)
5312 alc260_hp_automute(codec);
5313}
5314
Kailang Yangdf694da2005-12-05 19:42:22 +01005315static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005316 {
5317 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5318 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005319 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005320 .info = snd_ctl_boolean_mono_info,
5321 .get = alc260_hp_master_sw_get,
5322 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005323 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005324 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005325 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5326 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5327 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5328 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5329 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5330 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005331 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5332 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005333 { } /* end */
5334};
5335
Kailang Yang3f878302008-08-26 13:02:23 +02005336static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5337 .ops = &snd_hda_bind_vol,
5338 .values = {
5339 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5340 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5341 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5342 0
5343 },
5344};
5345
5346static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5347 .ops = &snd_hda_bind_sw,
5348 .values = {
5349 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5350 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5351 0
5352 },
5353};
5354
5355static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5356 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5357 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5358 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5359 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5360 { } /* end */
5361};
5362
Takashi Iwaibec15c32008-01-28 18:16:30 +01005363static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5364 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5365 {},
5366};
5367
5368static void alc260_hp_3013_automute(struct hda_codec *codec)
5369{
5370 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005371
Wu Fengguang864f92b2009-11-18 12:38:02 +08005372 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005373 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005374}
5375
5376static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5377 unsigned int res)
5378{
5379 if ((res >> 26) == ALC880_HP_EVENT)
5380 alc260_hp_3013_automute(codec);
5381}
5382
Kailang Yang3f878302008-08-26 13:02:23 +02005383static void alc260_hp_3012_automute(struct hda_codec *codec)
5384{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005385 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005386
Kailang Yang3f878302008-08-26 13:02:23 +02005387 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5388 bits);
5389 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5390 bits);
5391 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5392 bits);
5393}
5394
5395static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5396 unsigned int res)
5397{
5398 if ((res >> 26) == ALC880_HP_EVENT)
5399 alc260_hp_3012_automute(codec);
5400}
5401
5402/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005403 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5404 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005405static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005406 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005407 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005408 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005409 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5410 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5411 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5412 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005413 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005414 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5415 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005416 { } /* end */
5417};
5418
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005419/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5420 * versions of the ALC260 don't act on requests to enable mic bias from NID
5421 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5422 * datasheet doesn't mention this restriction. At this stage it's not clear
5423 * whether this behaviour is intentional or is a hardware bug in chip
5424 * revisions available in early 2006. Therefore for now allow the
5425 * "Headphone Jack Mode" control to span all choices, but if it turns out
5426 * that the lack of mic bias for this NID is intentional we could change the
5427 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5428 *
5429 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5430 * don't appear to make the mic bias available from the "line" jack, even
5431 * though the NID used for this jack (0x14) can supply it. The theory is
5432 * that perhaps Acer have included blocking capacitors between the ALC260
5433 * and the output jack. If this turns out to be the case for all such
5434 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5435 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005436 *
5437 * The C20x Tablet series have a mono internal speaker which is controlled
5438 * via the chip's Mono sum widget and pin complex, so include the necessary
5439 * controls for such models. On models without a "mono speaker" the control
5440 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005441 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005442static struct snd_kcontrol_new alc260_acer_mixer[] = {
5443 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5444 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005445 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005446 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005447 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005448 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005449 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005450 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5451 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5452 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5453 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5454 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5455 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5456 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5457 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005458 { } /* end */
5459};
5460
Michael Schwingencc959482009-02-22 18:58:45 +01005461/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5462 */
5463static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5464 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5465 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5466 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5467 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5468 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5469 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5470 { } /* end */
5471};
5472
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005473/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5474 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5475 */
5476static struct snd_kcontrol_new alc260_will_mixer[] = {
5477 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5478 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5479 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5480 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5481 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5482 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5483 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5484 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5485 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5486 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005487 { } /* end */
5488};
5489
5490/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5491 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5492 */
5493static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5494 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5495 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5497 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5498 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5499 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5500 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5501 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5502 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5503 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5504 { } /* end */
5505};
5506
Kailang Yangdf694da2005-12-05 19:42:22 +01005507/*
5508 * initialization verbs
5509 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005510static struct hda_verb alc260_init_verbs[] = {
5511 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005512 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005513 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005514 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005515 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005516 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005518 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005519 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005520 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005522 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005523 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005524 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005525 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005526 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005527 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005528 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5529 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005530 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005531 /* set connection select to line in (default select for this ADC) */
5532 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005533 /* mute capture amp left and right */
5534 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5535 /* set connection select to line in (default select for this ADC) */
5536 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005537 /* set vol=0 Line-Out mixer amp left and right */
5538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5539 /* unmute pin widget amp left and right (no gain on this amp) */
5540 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5541 /* set vol=0 HP mixer amp left and right */
5542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5543 /* unmute pin widget amp left and right (no gain on this amp) */
5544 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5545 /* set vol=0 Mono mixer amp left and right */
5546 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5547 /* unmute pin widget amp left and right (no gain on this amp) */
5548 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5549 /* unmute LINE-2 out pin */
5550 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005551 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5552 * Line In 2 = 0x03
5553 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005554 /* mute analog inputs */
5555 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005560 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005561 /* mute Front out path */
5562 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5564 /* mute Headphone out path */
5565 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5567 /* mute Mono out path */
5568 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005570 { }
5571};
5572
Takashi Iwai474167d2006-05-17 17:17:43 +02005573#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005574static struct hda_verb alc260_hp_init_verbs[] = {
5575 /* Headphone and output */
5576 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5577 /* mono output */
5578 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5579 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5580 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5581 /* Mic2 (front panel) pin widget for input and vref at 80% */
5582 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5583 /* Line In pin widget for input */
5584 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5585 /* Line-2 pin widget for output */
5586 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5587 /* CD pin widget for input */
5588 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5589 /* unmute amp left and right */
5590 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5591 /* set connection select to line in (default select for this ADC) */
5592 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5593 /* unmute Line-Out mixer amp left and right (volume = 0) */
5594 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5595 /* mute pin widget amp left and right (no gain on this amp) */
5596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5597 /* unmute HP mixer amp left and right (volume = 0) */
5598 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5599 /* mute pin widget amp left and right (no gain on this amp) */
5600 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005601 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5602 * Line In 2 = 0x03
5603 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005604 /* mute analog inputs */
5605 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5606 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005610 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5611 /* Unmute Front out path */
5612 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5614 /* Unmute Headphone out path */
5615 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5617 /* Unmute Mono out path */
5618 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5620 { }
5621};
Takashi Iwai474167d2006-05-17 17:17:43 +02005622#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005623
5624static struct hda_verb alc260_hp_3013_init_verbs[] = {
5625 /* Line out and output */
5626 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5627 /* mono output */
5628 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5629 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5630 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5631 /* Mic2 (front panel) pin widget for input and vref at 80% */
5632 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5633 /* Line In pin widget for input */
5634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5635 /* Headphone pin widget for output */
5636 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5637 /* CD pin widget for input */
5638 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5639 /* unmute amp left and right */
5640 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5641 /* set connection select to line in (default select for this ADC) */
5642 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5643 /* unmute Line-Out mixer amp left and right (volume = 0) */
5644 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5645 /* mute pin widget amp left and right (no gain on this amp) */
5646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5647 /* unmute HP mixer amp left and right (volume = 0) */
5648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5649 /* mute pin widget amp left and right (no gain on this amp) */
5650 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005651 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5652 * Line In 2 = 0x03
5653 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005654 /* mute analog inputs */
5655 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005660 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5661 /* Unmute Front out path */
5662 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5664 /* Unmute Headphone out path */
5665 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5666 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5667 /* Unmute Mono out path */
5668 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5669 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5670 { }
5671};
5672
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005673/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005674 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5675 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005676 */
5677static struct hda_verb alc260_fujitsu_init_verbs[] = {
5678 /* Disable all GPIOs */
5679 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5680 /* Internal speaker is connected to headphone pin */
5681 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5682 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5683 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005684 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5685 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5686 /* Ensure all other unused pins are disabled and muted. */
5687 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5688 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005689 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005690 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005691 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005692 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5693 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5694 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005695
Jonathan Woithef7ace402006-02-28 11:46:14 +01005696 /* Disable digital (SPDIF) pins */
5697 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5698 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005699
Kailang Yangea1fb292008-08-26 12:58:38 +02005700 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005701 * when acting as an output.
5702 */
5703 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5704
5705 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005706 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5707 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5709 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5710 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5711 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5712 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5713 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5714 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005715
Jonathan Woithef7ace402006-02-28 11:46:14 +01005716 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5717 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5718 /* Unmute Line1 pin widget output buffer since it starts as an output.
5719 * If the pin mode is changed by the user the pin mode control will
5720 * take care of enabling the pin's input/output buffers as needed.
5721 * Therefore there's no need to enable the input buffer at this
5722 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005723 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005724 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005725 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005726 * mixer ctrl)
5727 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005728 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005729
Jonathan Woithef7ace402006-02-28 11:46:14 +01005730 /* Mute capture amp left and right */
5731 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005732 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005733 * in (on mic1 pin)
5734 */
5735 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005736
Jonathan Woithef7ace402006-02-28 11:46:14 +01005737 /* Do the same for the second ADC: mute capture input amp and
5738 * set ADC connection to line in (on mic1 pin)
5739 */
5740 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5741 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005742
Jonathan Woithef7ace402006-02-28 11:46:14 +01005743 /* Mute all inputs to mixer widget (even unconnected ones) */
5744 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5745 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005752
5753 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005754};
5755
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005756/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5757 * similar laptops (adapted from Fujitsu init verbs).
5758 */
5759static struct hda_verb alc260_acer_init_verbs[] = {
5760 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5761 * the headphone jack. Turn this on and rely on the standard mute
5762 * methods whenever the user wants to turn these outputs off.
5763 */
5764 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5765 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5766 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5767 /* Internal speaker/Headphone jack is connected to Line-out pin */
5768 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5769 /* Internal microphone/Mic jack is connected to Mic1 pin */
5770 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5771 /* Line In jack is connected to Line1 pin */
5772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005773 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5774 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005775 /* Ensure all other unused pins are disabled and muted. */
5776 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5777 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005778 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5779 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5780 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5782 /* Disable digital (SPDIF) pins */
5783 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5784 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5785
Kailang Yangea1fb292008-08-26 12:58:38 +02005786 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005787 * bus when acting as outputs.
5788 */
5789 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5790 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5791
5792 /* Start with output sum widgets muted and their output gains at min */
5793 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5796 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5798 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5799 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5800 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5801 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005803 /* Unmute Line-out pin widget amp left and right
5804 * (no equiv mixer ctrl)
5805 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005806 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005807 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5808 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005809 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5810 * inputs. If the pin mode is changed by the user the pin mode control
5811 * will take care of enabling the pin's input/output buffers as needed.
5812 * Therefore there's no need to enable the input buffer at this
5813 * stage.
5814 */
5815 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5817
5818 /* Mute capture amp left and right */
5819 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5820 /* Set ADC connection select to match default mixer setting - mic
5821 * (on mic1 pin)
5822 */
5823 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5824
5825 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005826 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005827 */
5828 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005829 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005830
5831 /* Mute all inputs to mixer widget (even unconnected ones) */
5832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5836 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5838 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5840
5841 { }
5842};
5843
Michael Schwingencc959482009-02-22 18:58:45 +01005844/* Initialisation sequence for Maxdata Favorit 100XS
5845 * (adapted from Acer init verbs).
5846 */
5847static struct hda_verb alc260_favorit100_init_verbs[] = {
5848 /* GPIO 0 enables the output jack.
5849 * Turn this on and rely on the standard mute
5850 * methods whenever the user wants to turn these outputs off.
5851 */
5852 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5853 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5854 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5855 /* Line/Mic input jack is connected to Mic1 pin */
5856 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5857 /* Ensure all other unused pins are disabled and muted. */
5858 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5859 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5860 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5861 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5862 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5863 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5866 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5867 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5868 /* Disable digital (SPDIF) pins */
5869 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5870 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5871
5872 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5873 * bus when acting as outputs.
5874 */
5875 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5876 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5877
5878 /* Start with output sum widgets muted and their output gains at min */
5879 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5882 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5884 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5885 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5886 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5887 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5888
5889 /* Unmute Line-out pin widget amp left and right
5890 * (no equiv mixer ctrl)
5891 */
5892 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5893 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5894 * inputs. If the pin mode is changed by the user the pin mode control
5895 * will take care of enabling the pin's input/output buffers as needed.
5896 * Therefore there's no need to enable the input buffer at this
5897 * stage.
5898 */
5899 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5900
5901 /* Mute capture amp left and right */
5902 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5903 /* Set ADC connection select to match default mixer setting - mic
5904 * (on mic1 pin)
5905 */
5906 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5907
5908 /* Do similar with the second ADC: mute capture input amp and
5909 * set ADC connection to mic to match ALSA's default state.
5910 */
5911 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5912 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5913
5914 /* Mute all inputs to mixer widget (even unconnected ones) */
5915 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5922 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5923
5924 { }
5925};
5926
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005927static struct hda_verb alc260_will_verbs[] = {
5928 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5929 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5930 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5931 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5932 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5933 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5934 {}
5935};
5936
5937static struct hda_verb alc260_replacer_672v_verbs[] = {
5938 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5939 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5940 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5941
5942 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5943 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5944 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5945
5946 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5947 {}
5948};
5949
5950/* toggle speaker-output according to the hp-jack state */
5951static void alc260_replacer_672v_automute(struct hda_codec *codec)
5952{
5953 unsigned int present;
5954
5955 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005956 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005957 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005958 snd_hda_codec_write_cache(codec, 0x01, 0,
5959 AC_VERB_SET_GPIO_DATA, 1);
5960 snd_hda_codec_write_cache(codec, 0x0f, 0,
5961 AC_VERB_SET_PIN_WIDGET_CONTROL,
5962 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005963 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005964 snd_hda_codec_write_cache(codec, 0x01, 0,
5965 AC_VERB_SET_GPIO_DATA, 0);
5966 snd_hda_codec_write_cache(codec, 0x0f, 0,
5967 AC_VERB_SET_PIN_WIDGET_CONTROL,
5968 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005969 }
5970}
5971
5972static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5973 unsigned int res)
5974{
5975 if ((res >> 26) == ALC880_HP_EVENT)
5976 alc260_replacer_672v_automute(codec);
5977}
5978
Kailang Yang3f878302008-08-26 13:02:23 +02005979static struct hda_verb alc260_hp_dc7600_verbs[] = {
5980 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5981 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5982 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5983 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5984 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5985 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5986 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5987 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5988 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5989 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5990 {}
5991};
5992
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005993/* Test configuration for debugging, modelled after the ALC880 test
5994 * configuration.
5995 */
5996#ifdef CONFIG_SND_DEBUG
5997static hda_nid_t alc260_test_dac_nids[1] = {
5998 0x02,
5999};
6000static hda_nid_t alc260_test_adc_nids[2] = {
6001 0x04, 0x05,
6002};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006003/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006004 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006005 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006006 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006007static struct hda_input_mux alc260_test_capture_sources[2] = {
6008 {
6009 .num_items = 7,
6010 .items = {
6011 { "MIC1 pin", 0x0 },
6012 { "MIC2 pin", 0x1 },
6013 { "LINE1 pin", 0x2 },
6014 { "LINE2 pin", 0x3 },
6015 { "CD pin", 0x4 },
6016 { "LINE-OUT pin", 0x5 },
6017 { "HP-OUT pin", 0x6 },
6018 },
6019 },
6020 {
6021 .num_items = 8,
6022 .items = {
6023 { "MIC1 pin", 0x0 },
6024 { "MIC2 pin", 0x1 },
6025 { "LINE1 pin", 0x2 },
6026 { "LINE2 pin", 0x3 },
6027 { "CD pin", 0x4 },
6028 { "Mixer", 0x5 },
6029 { "LINE-OUT pin", 0x6 },
6030 { "HP-OUT pin", 0x7 },
6031 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006032 },
6033};
6034static struct snd_kcontrol_new alc260_test_mixer[] = {
6035 /* Output driver widgets */
6036 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6037 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6038 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6039 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6040 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6041 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6042
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006043 /* Modes for retasking pin widgets
6044 * Note: the ALC260 doesn't seem to act on requests to enable mic
6045 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6046 * mention this restriction. At this stage it's not clear whether
6047 * this behaviour is intentional or is a hardware bug in chip
6048 * revisions available at least up until early 2006. Therefore for
6049 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6050 * choices, but if it turns out that the lack of mic bias for these
6051 * NIDs is intentional we could change their modes from
6052 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6053 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006054 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6055 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6056 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6057 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6058 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6059 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6060
6061 /* Loopback mixer controls */
6062 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6063 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6064 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6065 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6066 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6067 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6068 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6069 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6070 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6071 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006072 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6073 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6074 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6075 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006076
6077 /* Controls for GPIO pins, assuming they are configured as outputs */
6078 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6079 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6080 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6081 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6082
Jonathan Woithe92621f12006-02-28 11:47:47 +01006083 /* Switches to allow the digital IO pins to be enabled. The datasheet
6084 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006085 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006086 */
6087 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6088 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6089
Jonathan Woithef8225f62008-01-08 12:16:54 +01006090 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6091 * this output to turn on an external amplifier.
6092 */
6093 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6094 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6095
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006096 { } /* end */
6097};
6098static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006099 /* Enable all GPIOs as outputs with an initial value of 0 */
6100 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6101 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6102 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6103
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006104 /* Enable retasking pins as output, initially without power amp */
6105 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6106 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6108 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6109 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6110 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6111
Jonathan Woithe92621f12006-02-28 11:47:47 +01006112 /* Disable digital (SPDIF) pins initially, but users can enable
6113 * them via a mixer switch. In the case of SPDIF-out, this initverb
6114 * payload also sets the generation to 0, output to be in "consumer"
6115 * PCM format, copyright asserted, no pre-emphasis and no validity
6116 * control.
6117 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006118 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6119 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6120
Kailang Yangea1fb292008-08-26 12:58:38 +02006121 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006122 * OUT1 sum bus when acting as an output.
6123 */
6124 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6125 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6126 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6127 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6128
6129 /* Start with output sum widgets muted and their output gains at min */
6130 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6136 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6137 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6138 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6139
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006140 /* Unmute retasking pin widget output buffers since the default
6141 * state appears to be output. As the pin mode is changed by the
6142 * user the pin mode control will take care of enabling the pin's
6143 * input/output buffers as needed.
6144 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006145 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6146 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6148 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6149 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6150 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6151 /* Also unmute the mono-out pin widget */
6152 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6153
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006154 /* Mute capture amp left and right */
6155 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006156 /* Set ADC connection select to match default mixer setting (mic1
6157 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006158 */
6159 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6160
6161 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006162 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006163 */
6164 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6165 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6166
6167 /* Mute all inputs to mixer widget (even unconnected ones) */
6168 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6176
6177 { }
6178};
6179#endif
6180
Takashi Iwai63300792008-01-24 15:31:36 +01006181#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6182#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006183
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006184#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6185#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6186
Kailang Yangdf694da2005-12-05 19:42:22 +01006187/*
6188 * for BIOS auto-configuration
6189 */
6190
6191static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006192 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006193{
6194 hda_nid_t nid_vol;
6195 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006196 int err;
6197
6198 if (nid >= 0x0f && nid < 0x11) {
6199 nid_vol = nid - 0x7;
6200 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6201 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6202 } else if (nid == 0x11) {
6203 nid_vol = nid - 0x7;
6204 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6205 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6206 } else if (nid >= 0x12 && nid <= 0x15) {
6207 nid_vol = 0x08;
6208 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6209 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6210 } else
6211 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006212
Takashi Iwai863b4512008-10-21 17:01:47 +02006213 if (!(*vol_bits & (1 << nid_vol))) {
6214 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006215 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006216 if (err < 0)
6217 return err;
6218 *vol_bits |= (1 << nid_vol);
6219 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006220 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006221 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006222 return err;
6223 return 1;
6224}
6225
6226/* add playback controls from the parsed DAC table */
6227static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6228 const struct auto_pin_cfg *cfg)
6229{
6230 hda_nid_t nid;
6231 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006232 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006233
6234 spec->multiout.num_dacs = 1;
6235 spec->multiout.dac_nids = spec->private_dac_nids;
6236 spec->multiout.dac_nids[0] = 0x02;
6237
6238 nid = cfg->line_out_pins[0];
6239 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006240 const char *pfx;
6241 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6242 pfx = "Master";
6243 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6244 pfx = "Speaker";
6245 else
6246 pfx = "Front";
6247 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006248 if (err < 0)
6249 return err;
6250 }
6251
Takashi Iwai82bc9552006-03-21 11:24:42 +01006252 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006253 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006254 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006255 if (err < 0)
6256 return err;
6257 }
6258
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006259 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006260 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006261 err = alc260_add_playback_controls(spec, nid, "Headphone",
6262 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006263 if (err < 0)
6264 return err;
6265 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006266 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006267}
6268
6269/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006270static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006271 const struct auto_pin_cfg *cfg)
6272{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006273 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006274}
6275
6276static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6277 hda_nid_t nid, int pin_type,
6278 int sel_idx)
6279{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006280 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006281 /* need the manual connection? */
6282 if (nid >= 0x12) {
6283 int idx = nid - 0x12;
6284 snd_hda_codec_write(codec, idx + 0x0b, 0,
6285 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006286 }
6287}
6288
6289static void alc260_auto_init_multi_out(struct hda_codec *codec)
6290{
6291 struct alc_spec *spec = codec->spec;
6292 hda_nid_t nid;
6293
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006294 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006295 if (nid) {
6296 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6297 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6298 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006299
Takashi Iwai82bc9552006-03-21 11:24:42 +01006300 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006301 if (nid)
6302 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6303
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006304 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006305 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006306 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006307}
Kailang Yangdf694da2005-12-05 19:42:22 +01006308
6309#define ALC260_PIN_CD_NID 0x16
6310static void alc260_auto_init_analog_input(struct hda_codec *codec)
6311{
6312 struct alc_spec *spec = codec->spec;
6313 int i;
6314
6315 for (i = 0; i < AUTO_PIN_LAST; i++) {
6316 hda_nid_t nid = spec->autocfg.input_pins[i];
6317 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006318 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006319 if (nid != ALC260_PIN_CD_NID &&
6320 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006321 snd_hda_codec_write(codec, nid, 0,
6322 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006323 AMP_OUT_MUTE);
6324 }
6325 }
6326}
6327
6328/*
6329 * generic initialization of ADC, input mixers and output mixers
6330 */
6331static struct hda_verb alc260_volume_init_verbs[] = {
6332 /*
6333 * Unmute ADC0-1 and set the default input to mic-in
6334 */
6335 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6336 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6337 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6338 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006339
Kailang Yangdf694da2005-12-05 19:42:22 +01006340 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6341 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006342 * Note: PASD motherboards uses the Line In 2 as the input for
6343 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006344 */
6345 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006346 /* mute analog inputs */
6347 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006352
6353 /*
6354 * Set up output mixers (0x08 - 0x0a)
6355 */
6356 /* set vol=0 to output mixers */
6357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6358 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6359 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6360 /* set up input amps for analog loopback */
6361 /* Amp Indices: DAC = 0, mixer = 1 */
6362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6364 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6366 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006368
Kailang Yangdf694da2005-12-05 19:42:22 +01006369 { }
6370};
6371
6372static int alc260_parse_auto_config(struct hda_codec *codec)
6373{
6374 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006375 int err;
6376 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6377
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006378 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6379 alc260_ignore);
6380 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006381 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006382 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6383 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006384 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006385 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006386 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006387 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006388 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006389 return err;
6390
6391 spec->multiout.max_channels = 2;
6392
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006393 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006394 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006395 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006396 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006397
Takashi Iwaid88897e2008-10-31 15:01:37 +01006398 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006399
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006400 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006401 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006402
Kailang Yang6227cdc2010-02-25 08:36:52 +01006403 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006404
Kailang Yangdf694da2005-12-05 19:42:22 +01006405 return 1;
6406}
6407
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006408/* additional initialization for auto-configuration model */
6409static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006410{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006411 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006412 alc260_auto_init_multi_out(codec);
6413 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006414 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006415 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006416}
6417
Takashi Iwaicb53c622007-08-10 17:21:45 +02006418#ifdef CONFIG_SND_HDA_POWER_SAVE
6419static struct hda_amp_list alc260_loopbacks[] = {
6420 { 0x07, HDA_INPUT, 0 },
6421 { 0x07, HDA_INPUT, 1 },
6422 { 0x07, HDA_INPUT, 2 },
6423 { 0x07, HDA_INPUT, 3 },
6424 { 0x07, HDA_INPUT, 4 },
6425 { } /* end */
6426};
6427#endif
6428
Kailang Yangdf694da2005-12-05 19:42:22 +01006429/*
6430 * ALC260 configurations
6431 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006432static const char *alc260_models[ALC260_MODEL_LAST] = {
6433 [ALC260_BASIC] = "basic",
6434 [ALC260_HP] = "hp",
6435 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006436 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006437 [ALC260_FUJITSU_S702X] = "fujitsu",
6438 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006439 [ALC260_WILL] = "will",
6440 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006441 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006442#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006443 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006444#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006445 [ALC260_AUTO] = "auto",
6446};
6447
6448static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006449 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006450 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006451 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006452 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006453 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006454 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006455 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006456 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006457 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006458 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6459 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6460 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6461 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6462 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6463 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6464 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6465 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6466 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006467 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006468 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006469 {}
6470};
6471
Kailang Yangdf694da2005-12-05 19:42:22 +01006472static struct alc_config_preset alc260_presets[] = {
6473 [ALC260_BASIC] = {
6474 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006475 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006476 .init_verbs = { alc260_init_verbs },
6477 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6478 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006479 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006480 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006481 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6482 .channel_mode = alc260_modes,
6483 .input_mux = &alc260_capture_source,
6484 },
6485 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006486 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006487 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006488 .init_verbs = { alc260_init_verbs,
6489 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006490 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6491 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006492 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6493 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006494 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6495 .channel_mode = alc260_modes,
6496 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006497 .unsol_event = alc260_hp_unsol_event,
6498 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006499 },
Kailang Yang3f878302008-08-26 13:02:23 +02006500 [ALC260_HP_DC7600] = {
6501 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006502 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006503 .init_verbs = { alc260_init_verbs,
6504 alc260_hp_dc7600_verbs },
6505 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6506 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006507 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6508 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006509 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6510 .channel_mode = alc260_modes,
6511 .input_mux = &alc260_capture_source,
6512 .unsol_event = alc260_hp_3012_unsol_event,
6513 .init_hook = alc260_hp_3012_automute,
6514 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006515 [ALC260_HP_3013] = {
6516 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006517 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006518 .init_verbs = { alc260_hp_3013_init_verbs,
6519 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006520 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6521 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006522 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6523 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006524 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6525 .channel_mode = alc260_modes,
6526 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006527 .unsol_event = alc260_hp_3013_unsol_event,
6528 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006529 },
6530 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006531 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006532 .init_verbs = { alc260_fujitsu_init_verbs },
6533 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6534 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006535 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6536 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006537 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6538 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006539 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6540 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006541 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006542 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006543 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006544 .init_verbs = { alc260_acer_init_verbs },
6545 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6546 .dac_nids = alc260_dac_nids,
6547 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6548 .adc_nids = alc260_dual_adc_nids,
6549 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6550 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006551 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6552 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006553 },
Michael Schwingencc959482009-02-22 18:58:45 +01006554 [ALC260_FAVORIT100] = {
6555 .mixers = { alc260_favorit100_mixer },
6556 .init_verbs = { alc260_favorit100_init_verbs },
6557 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6558 .dac_nids = alc260_dac_nids,
6559 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6560 .adc_nids = alc260_dual_adc_nids,
6561 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6562 .channel_mode = alc260_modes,
6563 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6564 .input_mux = alc260_favorit100_capture_sources,
6565 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006566 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006567 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006568 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6569 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6570 .dac_nids = alc260_dac_nids,
6571 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6572 .adc_nids = alc260_adc_nids,
6573 .dig_out_nid = ALC260_DIGOUT_NID,
6574 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6575 .channel_mode = alc260_modes,
6576 .input_mux = &alc260_capture_source,
6577 },
6578 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006579 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006580 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6581 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6582 .dac_nids = alc260_dac_nids,
6583 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6584 .adc_nids = alc260_adc_nids,
6585 .dig_out_nid = ALC260_DIGOUT_NID,
6586 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6587 .channel_mode = alc260_modes,
6588 .input_mux = &alc260_capture_source,
6589 .unsol_event = alc260_replacer_672v_unsol_event,
6590 .init_hook = alc260_replacer_672v_automute,
6591 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006592#ifdef CONFIG_SND_DEBUG
6593 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006594 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006595 .init_verbs = { alc260_test_init_verbs },
6596 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6597 .dac_nids = alc260_test_dac_nids,
6598 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6599 .adc_nids = alc260_test_adc_nids,
6600 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6601 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006602 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6603 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006604 },
6605#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006606};
6607
Linus Torvalds1da177e2005-04-16 15:20:36 -07006608static int patch_alc260(struct hda_codec *codec)
6609{
6610 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006611 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006612
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006613 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006614 if (spec == NULL)
6615 return -ENOMEM;
6616
6617 codec->spec = spec;
6618
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006619 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6620 alc260_models,
6621 alc260_cfg_tbl);
6622 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006623 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006624 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006625 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006626 }
6627
Kailang Yangdf694da2005-12-05 19:42:22 +01006628 if (board_config == ALC260_AUTO) {
6629 /* automatic parse from the BIOS config */
6630 err = alc260_parse_auto_config(codec);
6631 if (err < 0) {
6632 alc_free(codec);
6633 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006634 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006635 printk(KERN_INFO
6636 "hda_codec: Cannot set up configuration "
6637 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006638 board_config = ALC260_BASIC;
6639 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006641
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006642 err = snd_hda_attach_beep_device(codec, 0x1);
6643 if (err < 0) {
6644 alc_free(codec);
6645 return err;
6646 }
6647
Kailang Yangdf694da2005-12-05 19:42:22 +01006648 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006649 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006650
Linus Torvalds1da177e2005-04-16 15:20:36 -07006651 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6652 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6653
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006654 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6655 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6656
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006657 if (!spec->adc_nids && spec->input_mux) {
6658 /* check whether NID 0x04 is valid */
6659 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006660 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006661 /* get type */
6662 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6663 spec->adc_nids = alc260_adc_nids_alt;
6664 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6665 } else {
6666 spec->adc_nids = alc260_adc_nids;
6667 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6668 }
6669 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006670 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006671 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006672
Takashi Iwai2134ea42008-01-10 16:53:55 +01006673 spec->vmaster_nid = 0x08;
6674
Linus Torvalds1da177e2005-04-16 15:20:36 -07006675 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006677 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006678#ifdef CONFIG_SND_HDA_POWER_SAVE
6679 if (!spec->loopback.amplist)
6680 spec->loopback.amplist = alc260_loopbacks;
6681#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006682
6683 return 0;
6684}
6685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006686
Linus Torvalds1da177e2005-04-16 15:20:36 -07006687/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006688 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006689 *
6690 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6691 * configuration. Each pin widget can choose any input DACs and a mixer.
6692 * Each ADC is connected from a mixer of all inputs. This makes possible
6693 * 6-channel independent captures.
6694 *
6695 * In addition, an independent DAC for the multi-playback (not used in this
6696 * driver yet).
6697 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006698#define ALC882_DIGOUT_NID 0x06
6699#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006700#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6701#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6702#define ALC1200_DIGOUT_NID 0x10
6703
Linus Torvalds1da177e2005-04-16 15:20:36 -07006704
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006705static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006706 { 8, NULL }
6707};
6708
Takashi Iwai4953550a2009-06-30 15:28:30 +02006709/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006710static hda_nid_t alc882_dac_nids[4] = {
6711 /* front, rear, clfe, rear_surr */
6712 0x02, 0x03, 0x04, 0x05
6713};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006714#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006715
Takashi Iwai4953550a2009-06-30 15:28:30 +02006716/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006717#define alc882_adc_nids alc880_adc_nids
6718#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006719#define alc883_adc_nids alc882_adc_nids_alt
6720static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6721static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6722#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006723
Takashi Iwaie1406342008-02-11 18:32:32 +01006724static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6725static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006726#define alc883_capsrc_nids alc882_capsrc_nids_alt
6727static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6728#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006729
Linus Torvalds1da177e2005-04-16 15:20:36 -07006730/* input MUX */
6731/* FIXME: should be a matrix-type input source selection */
6732
6733static struct hda_input_mux alc882_capture_source = {
6734 .num_items = 4,
6735 .items = {
6736 { "Mic", 0x0 },
6737 { "Front Mic", 0x1 },
6738 { "Line", 0x2 },
6739 { "CD", 0x4 },
6740 },
6741};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006742
Takashi Iwai4953550a2009-06-30 15:28:30 +02006743#define alc883_capture_source alc882_capture_source
6744
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006745static struct hda_input_mux alc889_capture_source = {
6746 .num_items = 3,
6747 .items = {
6748 { "Front Mic", 0x0 },
6749 { "Mic", 0x3 },
6750 { "Line", 0x2 },
6751 },
6752};
6753
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006754static struct hda_input_mux mb5_capture_source = {
6755 .num_items = 3,
6756 .items = {
6757 { "Mic", 0x1 },
6758 { "Line", 0x2 },
6759 { "CD", 0x4 },
6760 },
6761};
6762
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006763static struct hda_input_mux macmini3_capture_source = {
6764 .num_items = 2,
6765 .items = {
6766 { "Line", 0x2 },
6767 { "CD", 0x4 },
6768 },
6769};
6770
Takashi Iwai4953550a2009-06-30 15:28:30 +02006771static struct hda_input_mux alc883_3stack_6ch_intel = {
6772 .num_items = 4,
6773 .items = {
6774 { "Mic", 0x1 },
6775 { "Front Mic", 0x0 },
6776 { "Line", 0x2 },
6777 { "CD", 0x4 },
6778 },
6779};
6780
6781static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6782 .num_items = 2,
6783 .items = {
6784 { "Mic", 0x1 },
6785 { "Line", 0x2 },
6786 },
6787};
6788
6789static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6790 .num_items = 4,
6791 .items = {
6792 { "Mic", 0x0 },
6793 { "iMic", 0x1 },
6794 { "Line", 0x2 },
6795 { "CD", 0x4 },
6796 },
6797};
6798
6799static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6800 .num_items = 2,
6801 .items = {
6802 { "Mic", 0x0 },
6803 { "Int Mic", 0x1 },
6804 },
6805};
6806
6807static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6808 .num_items = 3,
6809 .items = {
6810 { "Mic", 0x0 },
6811 { "Front Mic", 0x1 },
6812 { "Line", 0x4 },
6813 },
6814};
6815
6816static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6817 .num_items = 2,
6818 .items = {
6819 { "Mic", 0x0 },
6820 { "Line", 0x2 },
6821 },
6822};
6823
6824static struct hda_input_mux alc889A_mb31_capture_source = {
6825 .num_items = 2,
6826 .items = {
6827 { "Mic", 0x0 },
6828 /* Front Mic (0x01) unused */
6829 { "Line", 0x2 },
6830 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006831 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006832 },
6833};
6834
6835/*
6836 * 2ch mode
6837 */
6838static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6839 { 2, NULL }
6840};
6841
Kailang Yangdf694da2005-12-05 19:42:22 +01006842/*
Kailang Yang272a5272007-05-14 11:00:38 +02006843 * 2ch mode
6844 */
6845static struct hda_verb alc882_3ST_ch2_init[] = {
6846 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6847 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6850 { } /* end */
6851};
6852
6853/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006854 * 4ch mode
6855 */
6856static struct hda_verb alc882_3ST_ch4_init[] = {
6857 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6858 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6859 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6860 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6861 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6862 { } /* end */
6863};
6864
6865/*
Kailang Yang272a5272007-05-14 11:00:38 +02006866 * 6ch mode
6867 */
6868static struct hda_verb alc882_3ST_ch6_init[] = {
6869 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6870 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6871 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6872 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6873 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6874 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6875 { } /* end */
6876};
6877
Takashi Iwai4953550a2009-06-30 15:28:30 +02006878static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006879 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006880 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006881 { 6, alc882_3ST_ch6_init },
6882};
6883
Takashi Iwai4953550a2009-06-30 15:28:30 +02006884#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6885
Kailang Yang272a5272007-05-14 11:00:38 +02006886/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306887 * 2ch mode
6888 */
6889static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6890 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6891 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6892 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6895 { } /* end */
6896};
6897
6898/*
6899 * 4ch mode
6900 */
6901static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6902 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6903 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6904 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6905 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6906 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6907 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6908 { } /* end */
6909};
6910
6911/*
6912 * 6ch mode
6913 */
6914static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6915 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6916 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6917 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6918 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6919 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6920 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6921 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6922 { } /* end */
6923};
6924
6925static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6926 { 2, alc883_3ST_ch2_clevo_init },
6927 { 4, alc883_3ST_ch4_clevo_init },
6928 { 6, alc883_3ST_ch6_clevo_init },
6929};
6930
6931
6932/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 * 6ch mode
6934 */
6935static struct hda_verb alc882_sixstack_ch6_init[] = {
6936 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6937 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6938 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6939 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6940 { } /* end */
6941};
6942
6943/*
6944 * 8ch mode
6945 */
6946static struct hda_verb alc882_sixstack_ch8_init[] = {
6947 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6948 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6949 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6950 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6951 { } /* end */
6952};
6953
6954static struct hda_channel_mode alc882_sixstack_modes[2] = {
6955 { 6, alc882_sixstack_ch6_init },
6956 { 8, alc882_sixstack_ch8_init },
6957};
6958
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08006959
6960/* Macbook Air 2,1 */
6961
6962static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
6963 { 2, NULL },
6964};
6965
Takashi Iwai87350ad2007-08-16 18:19:38 +02006966/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006967 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006968 */
6969
6970/*
6971 * 2ch mode
6972 */
6973static struct hda_verb alc885_mbp_ch2_init[] = {
6974 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6975 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6976 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6977 { } /* end */
6978};
6979
6980/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006981 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006982 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006983static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006984 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6985 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6986 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6987 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6988 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6989 { } /* end */
6990};
6991
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006992static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006993 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006994 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006995};
6996
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006997/*
6998 * 2ch
6999 * Speakers/Woofer/HP = Front
7000 * LineIn = Input
7001 */
7002static struct hda_verb alc885_mb5_ch2_init[] = {
7003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7005 { } /* end */
7006};
7007
7008/*
7009 * 6ch mode
7010 * Speakers/HP = Front
7011 * Woofer = LFE
7012 * LineIn = Surround
7013 */
7014static struct hda_verb alc885_mb5_ch6_init[] = {
7015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7018 { } /* end */
7019};
7020
7021static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7022 { 2, alc885_mb5_ch2_init },
7023 { 6, alc885_mb5_ch6_init },
7024};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007025
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007026#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007027
7028/*
7029 * 2ch mode
7030 */
7031static struct hda_verb alc883_4ST_ch2_init[] = {
7032 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7033 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7034 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7035 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7036 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7037 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7038 { } /* end */
7039};
7040
7041/*
7042 * 4ch mode
7043 */
7044static struct hda_verb alc883_4ST_ch4_init[] = {
7045 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7046 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7047 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7048 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7049 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7050 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7051 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7052 { } /* end */
7053};
7054
7055/*
7056 * 6ch mode
7057 */
7058static struct hda_verb alc883_4ST_ch6_init[] = {
7059 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7060 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7061 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7062 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7063 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7064 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7065 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7066 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7067 { } /* end */
7068};
7069
7070/*
7071 * 8ch mode
7072 */
7073static struct hda_verb alc883_4ST_ch8_init[] = {
7074 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7075 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7076 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7077 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7078 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7079 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7080 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7081 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7082 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7083 { } /* end */
7084};
7085
7086static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7087 { 2, alc883_4ST_ch2_init },
7088 { 4, alc883_4ST_ch4_init },
7089 { 6, alc883_4ST_ch6_init },
7090 { 8, alc883_4ST_ch8_init },
7091};
7092
7093
7094/*
7095 * 2ch mode
7096 */
7097static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7098 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7099 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7100 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7101 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7102 { } /* end */
7103};
7104
7105/*
7106 * 4ch mode
7107 */
7108static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7109 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7110 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7111 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7112 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7113 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7114 { } /* end */
7115};
7116
7117/*
7118 * 6ch mode
7119 */
7120static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7121 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7122 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7123 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7124 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7125 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7126 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7127 { } /* end */
7128};
7129
7130static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7131 { 2, alc883_3ST_ch2_intel_init },
7132 { 4, alc883_3ST_ch4_intel_init },
7133 { 6, alc883_3ST_ch6_intel_init },
7134};
7135
7136/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007137 * 2ch mode
7138 */
7139static struct hda_verb alc889_ch2_intel_init[] = {
7140 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7141 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7142 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7143 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7144 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7145 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7146 { } /* end */
7147};
7148
7149/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007150 * 6ch mode
7151 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007152static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007153 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7154 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7155 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7156 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7157 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007158 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7159 { } /* end */
7160};
7161
7162/*
7163 * 8ch mode
7164 */
7165static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007166 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7167 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7168 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7169 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7170 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007171 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7172 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007173 { } /* end */
7174};
7175
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007176static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7177 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007178 { 6, alc889_ch6_intel_init },
7179 { 8, alc889_ch8_intel_init },
7180};
7181
7182/*
7183 * 6ch mode
7184 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007185static struct hda_verb alc883_sixstack_ch6_init[] = {
7186 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7187 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7188 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7189 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7190 { } /* end */
7191};
7192
7193/*
7194 * 8ch mode
7195 */
7196static struct hda_verb alc883_sixstack_ch8_init[] = {
7197 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7198 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7199 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7200 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7201 { } /* end */
7202};
7203
7204static struct hda_channel_mode alc883_sixstack_modes[2] = {
7205 { 6, alc883_sixstack_ch6_init },
7206 { 8, alc883_sixstack_ch8_init },
7207};
7208
7209
Linus Torvalds1da177e2005-04-16 15:20:36 -07007210/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7211 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7212 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007213static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007214 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007215 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007216 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007217 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007218 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7219 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007220 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7221 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007222 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007223 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7225 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7226 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7227 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7228 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007233 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007234 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007235 { } /* end */
7236};
7237
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007238/* Macbook Air 2,1 same control for HP and internal Speaker */
7239
7240static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7241 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7242 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7243 { }
7244};
7245
7246
Takashi Iwai87350ad2007-08-16 18:19:38 +02007247static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007248 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7249 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7250 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7251 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7252 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7254 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007255 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7256 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007257 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007258 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7259 { } /* end */
7260};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007261
7262static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7264 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7265 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7266 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7267 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7268 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307269 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7270 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007271 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7272 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7273 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7274 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7275 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7276 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7277 { } /* end */
7278};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007279
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007280static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7281 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7282 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7283 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7284 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7285 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7286 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7287 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7288 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7289 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7290 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7291 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7292 { } /* end */
7293};
7294
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007295static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7296 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7297 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7298 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7299 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7300 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7301 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7303 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7305 { } /* end */
7306};
7307
7308
Kailang Yangbdd148a2007-05-08 15:19:08 +02007309static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7310 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7311 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7312 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7313 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7314 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7315 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7316 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7317 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007319 { } /* end */
7320};
7321
Kailang Yang272a5272007-05-14 11:00:38 +02007322static struct snd_kcontrol_new alc882_targa_mixer[] = {
7323 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7326 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7327 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7328 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7329 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7331 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007332 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007333 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7334 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007335 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007336 { } /* end */
7337};
7338
7339/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7340 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7341 */
7342static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7343 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7344 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7346 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7347 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7348 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7351 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7352 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007355 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007356 { } /* end */
7357};
7358
Takashi Iwai914759b2007-09-06 14:52:04 +02007359static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7360 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7361 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7368 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007370 { } /* end */
7371};
7372
Kailang Yangdf694da2005-12-05 19:42:22 +01007373static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7374 {
7375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7376 .name = "Channel Mode",
7377 .info = alc_ch_mode_info,
7378 .get = alc_ch_mode_get,
7379 .put = alc_ch_mode_put,
7380 },
7381 { } /* end */
7382};
7383
Takashi Iwai4953550a2009-06-30 15:28:30 +02007384static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007385 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007388 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007391 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007394 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007395 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007398 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007399 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007400 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007401 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007402 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007403 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007405 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007406 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007407 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007408 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007409 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007410 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007411 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007412 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007413 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007414 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007416 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7417 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007418 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007419 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7420 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007421 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007422 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7423 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7424 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7425 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7426 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007427 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007428 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007429
7430 /* FIXME: use matrix-type input source selection */
7431 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007432 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007433 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007434 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007436 /* ADC2: mute amp left and right */
7437 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007438 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007439 /* ADC3: mute amp left and right */
7440 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007441 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007442
7443 { }
7444};
7445
Takashi Iwai4953550a2009-06-30 15:28:30 +02007446static struct hda_verb alc882_adc1_init_verbs[] = {
7447 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7452 /* ADC1: mute amp left and right */
7453 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7454 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7455 { }
7456};
7457
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007458static struct hda_verb alc882_eapd_verbs[] = {
7459 /* change to EAPD mode */
7460 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007461 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007462 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007463};
7464
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007465static struct hda_verb alc889_eapd_verbs[] = {
7466 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7467 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7468 { }
7469};
7470
Wu Fengguang6732bd02009-07-30 09:19:14 +02007471static struct hda_verb alc_hp15_unsol_verbs[] = {
7472 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7474 {}
7475};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007476
7477static struct hda_verb alc885_init_verbs[] = {
7478 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007479 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007481 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007482 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007484 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007485 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007487 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007488 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007490
7491 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7495 /* Front Pin: output 0 (0x0c) */
7496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7498 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7499 /* Rear Pin: output 1 (0x0d) */
7500 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7501 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7502 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7503 /* CLFE Pin: output 2 (0x0e) */
7504 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7505 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7506 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7507 /* Side Pin: output 3 (0x0f) */
7508 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7509 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7510 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7511 /* Mic (rear) pin: input vref at 80% */
7512 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7513 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7514 /* Front Mic pin: input vref at 80% */
7515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7516 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7517 /* Line In pin: input */
7518 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7519 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7520
7521 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7522 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007523 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007524 /* Input mixer2 */
7525 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007526 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007528 /* ADC2: mute amp left and right */
7529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7530 /* ADC3: mute amp left and right */
7531 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7532
7533 { }
7534};
7535
7536static struct hda_verb alc885_init_input_verbs[] = {
7537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7540 { }
7541};
7542
7543
7544/* Unmute Selector 24h and set the default input to front mic */
7545static struct hda_verb alc889_init_input_verbs[] = {
7546 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7547 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7548 { }
7549};
7550
7551
Takashi Iwai4953550a2009-06-30 15:28:30 +02007552#define alc883_init_verbs alc882_base_init_verbs
7553
Tobin Davis9102cd12006-12-15 10:02:12 +01007554/* Mac Pro test */
7555static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7556 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7557 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7558 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7559 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7560 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007561 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007562 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7563 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007564 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007565 { } /* end */
7566};
7567
7568static struct hda_verb alc882_macpro_init_verbs[] = {
7569 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7573 /* Front Pin: output 0 (0x0c) */
7574 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7577 /* Front Mic pin: input vref at 80% */
7578 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7579 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7580 /* Speaker: output */
7581 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7582 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7583 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7584 /* Headphone output (output 0 - 0x0c) */
7585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7586 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7587 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7588
7589 /* FIXME: use matrix-type input source selection */
7590 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7591 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7596 /* Input mixer2 */
7597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7601 /* Input mixer3 */
7602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7606 /* ADC1: mute amp left and right */
7607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7608 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7609 /* ADC2: mute amp left and right */
7610 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7611 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7612 /* ADC3: mute amp left and right */
7613 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7614 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7615
7616 { }
7617};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007618
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007619/* Macbook 5,1 */
7620static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007621 /* DACs */
7622 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7623 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7624 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7625 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007626 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007630 /* Surround mixer */
7631 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7634 /* LFE mixer */
7635 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7637 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7638 /* HP mixer */
7639 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7642 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7644 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007645 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7646 /* LFE Pin (0x0e) */
7647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7649 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7650 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7652 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007653 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307654 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007655 /* Front Mic pin: input vref at 80% */
7656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7658 /* Line In pin */
7659 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7661
7662 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7666 { }
7667};
7668
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007669/* Macmini 3,1 */
7670static struct hda_verb alc885_macmini3_init_verbs[] = {
7671 /* DACs */
7672 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7673 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7674 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7675 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7676 /* Front mixer */
7677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7680 /* Surround mixer */
7681 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7684 /* LFE mixer */
7685 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7686 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7688 /* HP mixer */
7689 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7692 /* Front Pin (0x0c) */
7693 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7694 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7695 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7696 /* LFE Pin (0x0e) */
7697 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7698 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7699 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7700 /* HP Pin (0x0f) */
7701 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7702 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7703 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7704 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7705 /* Line In pin */
7706 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7707 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7708
7709 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7710 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7712 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7713 { }
7714};
7715
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007716
7717static struct hda_verb alc885_mba21_init_verbs[] = {
7718 /*Internal and HP Speaker Mixer*/
7719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7722 /*Internal Speaker Pin (0x0c)*/
7723 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7724 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7725 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7726 /* HP Pin: output 0 (0x0e) */
7727 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7728 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7729 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7730 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7731 /* Line in (is hp when jack connected)*/
7732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7734
7735 { }
7736 };
7737
7738
Takashi Iwai87350ad2007-08-16 18:19:38 +02007739/* Macbook Pro rev3 */
7740static struct hda_verb alc885_mbp3_init_verbs[] = {
7741 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7745 /* Rear mixer */
7746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007749 /* HP mixer */
7750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007753 /* Front Pin: output 0 (0x0c) */
7754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7756 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007757 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007758 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007759 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7760 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007761 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7762 /* Mic (rear) pin: input vref at 80% */
7763 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7764 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7765 /* Front Mic pin: input vref at 80% */
7766 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7767 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7768 /* Line In pin: use output 1 when in LineOut mode */
7769 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7770 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7771 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7772
7773 /* FIXME: use matrix-type input source selection */
7774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7775 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7776 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7780 /* Input mixer2 */
7781 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7785 /* Input mixer3 */
7786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7790 /* ADC1: mute amp left and right */
7791 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7792 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7793 /* ADC2: mute amp left and right */
7794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7795 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7796 /* ADC3: mute amp left and right */
7797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7798 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7799
7800 { }
7801};
7802
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007803/* iMac 9,1 */
7804static struct hda_verb alc885_imac91_init_verbs[] = {
7805 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7806 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7809 /* Rear mixer */
7810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7813 /* HP Pin: output 0 (0x0c) */
7814 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7815 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7816 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7817 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7818 /* Internal Speakers: output 0 (0x0d) */
7819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7820 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7822 /* Mic (rear) pin: input vref at 80% */
7823 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7824 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7825 /* Front Mic pin: input vref at 80% */
7826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7828 /* Line In pin: use output 1 when in LineOut mode */
7829 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7830 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7831 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7832
7833 /* FIXME: use matrix-type input source selection */
7834 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7835 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7840 /* Input mixer2 */
7841 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7844 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7845 /* Input mixer3 */
7846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7850 /* ADC1: mute amp left and right */
7851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7852 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7853 /* ADC2: mute amp left and right */
7854 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7855 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7856 /* ADC3: mute amp left and right */
7857 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7858 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7859
7860 { }
7861};
7862
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007863/* iMac 24 mixer. */
7864static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7865 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7866 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7867 { } /* end */
7868};
7869
7870/* iMac 24 init verbs. */
7871static struct hda_verb alc885_imac24_init_verbs[] = {
7872 /* Internal speakers: output 0 (0x0c) */
7873 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7874 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7875 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7876 /* Internal speakers: output 0 (0x0c) */
7877 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7878 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7879 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7880 /* Headphone: output 0 (0x0c) */
7881 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7882 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7883 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7884 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7885 /* Front Mic: input vref at 80% */
7886 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7887 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7888 { }
7889};
7890
7891/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007892static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007893{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007894 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007895
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007896 spec->autocfg.hp_pins[0] = 0x14;
7897 spec->autocfg.speaker_pins[0] = 0x18;
7898 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007899}
7900
Takashi Iwai9d54f082010-02-22 08:34:40 +01007901#define alc885_mb5_setup alc885_imac24_setup
7902#define alc885_macmini3_setup alc885_imac24_setup
7903
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007904/* Macbook Air 2,1 */
7905static void alc885_mba21_setup(struct hda_codec *codec)
7906{
7907 struct alc_spec *spec = codec->spec;
7908
7909 spec->autocfg.hp_pins[0] = 0x14;
7910 spec->autocfg.speaker_pins[0] = 0x18;
7911}
7912
7913
7914
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007915static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007916{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007917 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007918
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007919 spec->autocfg.hp_pins[0] = 0x15;
7920 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007921}
7922
Takashi Iwai9d54f082010-02-22 08:34:40 +01007923static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307924{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007925 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307926
Takashi Iwai9d54f082010-02-22 08:34:40 +01007927 spec->autocfg.hp_pins[0] = 0x14;
7928 spec->autocfg.speaker_pins[0] = 0x15;
7929 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007930}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007931
Kailang Yang272a5272007-05-14 11:00:38 +02007932static struct hda_verb alc882_targa_verbs[] = {
7933 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7935
7936 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7937 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007938
Kailang Yang272a5272007-05-14 11:00:38 +02007939 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7940 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7941 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7942
7943 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007944 { } /* end */
7945};
7946
7947/* toggle speaker-output according to the hp-jack state */
7948static void alc882_targa_automute(struct hda_codec *codec)
7949{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007950 struct alc_spec *spec = codec->spec;
7951 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007952 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007953 spec->jack_present ? 1 : 3);
7954}
7955
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007956static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007957{
7958 struct alc_spec *spec = codec->spec;
7959
7960 spec->autocfg.hp_pins[0] = 0x14;
7961 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007962}
7963
7964static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7965{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007966 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007967 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007968}
7969
7970static struct hda_verb alc882_asus_a7j_verbs[] = {
7971 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7973
7974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7975 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7976 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007977
Kailang Yang272a5272007-05-14 11:00:38 +02007978 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7979 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7980 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7981
7982 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7983 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7984 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7985 { } /* end */
7986};
7987
Takashi Iwai914759b2007-09-06 14:52:04 +02007988static struct hda_verb alc882_asus_a7m_verbs[] = {
7989 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7991
7992 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7993 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7994 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007995
Takashi Iwai914759b2007-09-06 14:52:04 +02007996 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7997 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7998 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7999
8000 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8001 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8002 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8003 { } /* end */
8004};
8005
Tobin Davis9102cd12006-12-15 10:02:12 +01008006static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8007{
8008 unsigned int gpiostate, gpiomask, gpiodir;
8009
8010 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8011 AC_VERB_GET_GPIO_DATA, 0);
8012
8013 if (!muted)
8014 gpiostate |= (1 << pin);
8015 else
8016 gpiostate &= ~(1 << pin);
8017
8018 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8019 AC_VERB_GET_GPIO_MASK, 0);
8020 gpiomask |= (1 << pin);
8021
8022 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8023 AC_VERB_GET_GPIO_DIRECTION, 0);
8024 gpiodir |= (1 << pin);
8025
8026
8027 snd_hda_codec_write(codec, codec->afg, 0,
8028 AC_VERB_SET_GPIO_MASK, gpiomask);
8029 snd_hda_codec_write(codec, codec->afg, 0,
8030 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8031
8032 msleep(1);
8033
8034 snd_hda_codec_write(codec, codec->afg, 0,
8035 AC_VERB_SET_GPIO_DATA, gpiostate);
8036}
8037
Takashi Iwai7debbe52007-08-16 15:01:03 +02008038/* set up GPIO at initialization */
8039static void alc885_macpro_init_hook(struct hda_codec *codec)
8040{
8041 alc882_gpio_mute(codec, 0, 0);
8042 alc882_gpio_mute(codec, 1, 0);
8043}
8044
8045/* set up GPIO and update auto-muting at initialization */
8046static void alc885_imac24_init_hook(struct hda_codec *codec)
8047{
8048 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008049 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008050}
8051
Kailang Yangdf694da2005-12-05 19:42:22 +01008052/*
8053 * generic initialization of ADC, input mixers and output mixers
8054 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008055static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008056 /*
8057 * Unmute ADC0-2 and set the default input to mic-in
8058 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008059 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8060 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8061 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8062 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8063
Kailang Yangdf694da2005-12-05 19:42:22 +01008064 /*
8065 * Set up output mixers (0x0c - 0x0f)
8066 */
8067 /* set vol=0 to output mixers */
8068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8071 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8072 /* set up input amps for analog loopback */
8073 /* Amp Indices: DAC = 0, mixer = 1 */
8074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8076 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8078 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8080 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8082 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8083 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8084
8085 /* FIXME: use matrix-type input source selection */
8086 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008087 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008089 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008091 { }
8092};
8093
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008094/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8095static struct hda_verb alc889A_mb31_ch2_init[] = {
8096 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8097 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8098 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8099 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8100 { } /* end */
8101};
8102
8103/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8104static struct hda_verb alc889A_mb31_ch4_init[] = {
8105 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8106 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8107 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8109 { } /* end */
8110};
8111
8112/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8113static struct hda_verb alc889A_mb31_ch5_init[] = {
8114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8115 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8118 { } /* end */
8119};
8120
8121/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8122static struct hda_verb alc889A_mb31_ch6_init[] = {
8123 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8124 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8125 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8126 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8127 { } /* end */
8128};
8129
8130static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8131 { 2, alc889A_mb31_ch2_init },
8132 { 4, alc889A_mb31_ch4_init },
8133 { 5, alc889A_mb31_ch5_init },
8134 { 6, alc889A_mb31_ch6_init },
8135};
8136
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008137static struct hda_verb alc883_medion_eapd_verbs[] = {
8138 /* eanable EAPD on medion laptop */
8139 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8140 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8141 { }
8142};
8143
Takashi Iwai4953550a2009-06-30 15:28:30 +02008144#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008145
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008146static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8147 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8148 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8149 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8150 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8151 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8152 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8153 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8155 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8158 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008160 { } /* end */
8161};
8162
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008163static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008164 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8165 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8166 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8167 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8168 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8170 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8171 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8173 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008174 { } /* end */
8175};
8176
Jiang zhefb97dc62008-03-06 11:07:11 +01008177static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8179 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8181 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8182 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8183 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8184 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8185 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8186 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8187 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008188 { } /* end */
8189};
8190
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008191static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8192 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8193 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8194 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8195 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8196 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8197 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8198 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008200 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8202 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008203 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008205 { } /* end */
8206};
8207
8208static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8209 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8210 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8211 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8212 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8213 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8214 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8215 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8216 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8218 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8219 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8220 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8221 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008223 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008224 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8225 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008226 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008228 { } /* end */
8229};
8230
Jiang zhe17bba1b2008-06-04 12:11:07 +02008231static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8232 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8233 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8234 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8235 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8236 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8237 HDA_OUTPUT),
8238 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8239 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8240 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8241 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8248 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8249 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008252 { } /* end */
8253};
8254
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008255static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8256 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8258 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8259 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8260 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8261 HDA_OUTPUT),
8262 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8263 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8264 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8265 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8266 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8267 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8271 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8274 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8275 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8276 { } /* end */
8277};
8278
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008279static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008280 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008281 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008282 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008283 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008284 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8285 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008286 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8287 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8289 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8290 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8291 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8292 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008294 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008295 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8296 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008297 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008298 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008299 { } /* end */
8300};
8301
Sasha Alexandrc2592492009-06-16 14:52:54 -04008302static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008303 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008304 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008306 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008307 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8308 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8309 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8310 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8311 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8312 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008320 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008321};
Kailang Yangccc656c2006-10-17 12:32:26 +02008322
Sasha Alexandrc2592492009-06-16 14:52:54 -04008323static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008327 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008328 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8329 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8330 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008331 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008333 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8334 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8335 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008336 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008337};
Kailang Yangccc656c2006-10-17 12:32:26 +02008338
Takashi Iwaib99dba32009-09-17 18:23:00 +02008339static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8340 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8341 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8342 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8343 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8344 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8345 { } /* end */
8346};
8347
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008348static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8349 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8350 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008351 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8352 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008353 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8355 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8356 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008357 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008358};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008359
Kailang Yang272a5272007-05-14 11:00:38 +02008360static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8361 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8362 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8363 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8368 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8369 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008370 { } /* end */
8371};
8372
8373static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8374 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8375 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8376 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8379 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8380 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8381 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8382 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008383 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008384};
Kailang Yang272a5272007-05-14 11:00:38 +02008385
Tobin Davis2880a862007-08-07 11:50:26 +02008386static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008387 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8388 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008389 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008390 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8391 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008392 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8393 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008395 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008396};
Tobin Davis2880a862007-08-07 11:50:26 +02008397
Tony Vroond2fd4b02009-06-21 00:40:10 +01008398static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8399 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8400 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8401 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8402 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008403 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8404 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008405 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8406 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8407 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8410 { } /* end */
8411};
8412
Kailang Yange2757d52008-08-26 13:17:46 +02008413static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8414 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8415 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8416 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8417 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8418 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8419 0x0d, 1, 0x0, HDA_OUTPUT),
8420 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8421 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8422 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8423 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8424 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008425 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8426 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8427 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8428 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8429 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8430 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8431 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8432 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8433 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8434 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008435 { } /* end */
8436};
8437
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008438static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8439 /* Output mixers */
8440 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8441 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8442 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8443 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8444 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8445 HDA_OUTPUT),
8446 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8447 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8448 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8449 /* Output switches */
8450 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8451 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8452 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8453 /* Boost mixers */
8454 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8455 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8456 /* Input mixers */
8457 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8458 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8459 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8460 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8461 { } /* end */
8462};
8463
Guido Günther3e1647c52009-06-05 00:47:26 +02008464static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8466 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8467 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8468 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8469 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8470 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8471 { } /* end */
8472};
8473
Kailang Yange2757d52008-08-26 13:17:46 +02008474static struct hda_bind_ctls alc883_bind_cap_vol = {
8475 .ops = &snd_hda_bind_vol,
8476 .values = {
8477 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8478 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8479 0
8480 },
8481};
8482
8483static struct hda_bind_ctls alc883_bind_cap_switch = {
8484 .ops = &snd_hda_bind_sw,
8485 .values = {
8486 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8487 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8488 0
8489 },
8490};
8491
8492static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8493 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8494 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8495 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8496 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8497 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8498 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8499 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8500 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008501 { } /* end */
8502};
8503
8504static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008505 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8506 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8507 {
8508 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8509 /* .name = "Capture Source", */
8510 .name = "Input Source",
8511 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008512 .info = alc_mux_enum_info,
8513 .get = alc_mux_enum_get,
8514 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008515 },
8516 { } /* end */
8517};
8518
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008519static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8520 {
8521 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8522 .name = "Channel Mode",
8523 .info = alc_ch_mode_info,
8524 .get = alc_ch_mode_get,
8525 .put = alc_ch_mode_put,
8526 },
8527 { } /* end */
8528};
8529
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008530/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008531static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008532{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008533 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008534
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008535 spec->autocfg.hp_pins[0] = 0x15;
8536 spec->autocfg.speaker_pins[0] = 0x14;
8537 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008538}
8539
8540/* auto-toggle front mic */
8541/*
8542static void alc883_mitac_mic_automute(struct hda_codec *codec)
8543{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008544 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008545
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008546 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8547}
8548*/
8549
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008550static struct hda_verb alc883_mitac_verbs[] = {
8551 /* HP */
8552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8553 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8554 /* Subwoofer */
8555 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8556 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8557
8558 /* enable unsolicited event */
8559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8560 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8561
8562 { } /* end */
8563};
8564
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308565static struct hda_verb alc883_clevo_m540r_verbs[] = {
8566 /* HP */
8567 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8569 /* Int speaker */
8570 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8571
8572 /* enable unsolicited event */
8573 /*
8574 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8575 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8576 */
8577
8578 { } /* end */
8579};
8580
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008581static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008582 /* HP */
8583 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8585 /* Int speaker */
8586 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8587 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8588
8589 /* enable unsolicited event */
8590 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008591 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008592
8593 { } /* end */
8594};
8595
Jiang zhefb97dc62008-03-06 11:07:11 +01008596static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8597 /* HP */
8598 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8600 /* Subwoofer */
8601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8602 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8603
8604 /* enable unsolicited event */
8605 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8606
8607 { } /* end */
8608};
8609
Sasha Alexandrc2592492009-06-16 14:52:54 -04008610static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008611 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8613
8614 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8615 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008616
David Heidelberger64a8be72009-06-08 16:15:18 +02008617/* Connect Line-Out side jack (SPDIF) to Side */
8618 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8619 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8620 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8621/* Connect Mic jack to CLFE */
8622 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8623 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8624 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8625/* Connect Line-in jack to Surround */
8626 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8628 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8629/* Connect HP out jack to Front */
8630 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8632 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008633
8634 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008635
8636 { } /* end */
8637};
8638
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008639static struct hda_verb alc883_lenovo_101e_verbs[] = {
8640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8641 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8642 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8643 { } /* end */
8644};
8645
Kailang Yang272a5272007-05-14 11:00:38 +02008646static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8647 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8649 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8650 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8651 { } /* end */
8652};
8653
8654static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8655 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8657 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8660 { } /* end */
8661};
8662
Kailang Yang189609a2007-08-20 11:31:23 +02008663static struct hda_verb alc883_haier_w66_verbs[] = {
8664 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8666
8667 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8668
8669 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8670 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8671 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8673 { } /* end */
8674};
8675
Kailang Yange2757d52008-08-26 13:17:46 +02008676static struct hda_verb alc888_lenovo_sky_verbs[] = {
8677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8679 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8680 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8682 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8683 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8684 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8685 { } /* end */
8686};
8687
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008688static struct hda_verb alc888_6st_dell_verbs[] = {
8689 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8690 { }
8691};
8692
Guido Günther3e1647c52009-06-05 00:47:26 +02008693static struct hda_verb alc883_vaiott_verbs[] = {
8694 /* HP */
8695 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8696 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8697
8698 /* enable unsolicited event */
8699 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8700
8701 { } /* end */
8702};
8703
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008704static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008705{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008706 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008707
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008708 spec->autocfg.hp_pins[0] = 0x1b;
8709 spec->autocfg.speaker_pins[0] = 0x14;
8710 spec->autocfg.speaker_pins[1] = 0x16;
8711 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008712}
8713
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008714static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008715 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008716 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8717 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008718 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008719 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008720};
8721
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008722/*
8723 * 2ch mode
8724 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008725static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008726 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8727 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8728 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8729 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008730 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008731};
8732
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008733/*
8734 * 4ch mode
8735 */
8736static struct hda_verb alc888_3st_hp_4ch_init[] = {
8737 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8738 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8739 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8740 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8741 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8742 { } /* end */
8743};
8744
8745/*
8746 * 6ch mode
8747 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008748static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008749 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8750 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008751 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008752 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8753 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008754 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8755 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008756};
8757
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008758static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008759 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008760 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008761 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008762};
8763
Kailang Yang272a5272007-05-14 11:00:38 +02008764/* toggle front-jack and RCA according to the hp-jack state */
8765static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8766{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008767 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008768
Takashi Iwai47fd8302007-08-10 17:11:07 +02008769 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8770 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8771 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8772 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008773}
8774
8775/* toggle RCA according to the front-jack state */
8776static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8777{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008778 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008779
Takashi Iwai47fd8302007-08-10 17:11:07 +02008780 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8781 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008782}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008783
Kailang Yang272a5272007-05-14 11:00:38 +02008784static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8785 unsigned int res)
8786{
8787 if ((res >> 26) == ALC880_HP_EVENT)
8788 alc888_lenovo_ms7195_front_automute(codec);
8789 if ((res >> 26) == ALC880_FRONT_EVENT)
8790 alc888_lenovo_ms7195_rca_automute(codec);
8791}
8792
8793static struct hda_verb alc883_medion_md2_verbs[] = {
8794 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8796
8797 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8798
8799 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8800 { } /* end */
8801};
8802
8803/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008804static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008805{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008806 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008807
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008808 spec->autocfg.hp_pins[0] = 0x14;
8809 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008810}
8811
Kailang Yangccc656c2006-10-17 12:32:26 +02008812/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008813#define alc883_targa_init_hook alc882_targa_init_hook
8814#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008815
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008816static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8817{
8818 unsigned int present;
8819
Takashi Iwaid56757a2009-11-18 08:00:14 +01008820 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008821 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8822 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8823}
8824
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008825static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008826{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008827 struct alc_spec *spec = codec->spec;
8828
8829 spec->autocfg.hp_pins[0] = 0x15;
8830 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008831}
8832
8833static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8834{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008835 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008836 alc883_clevo_m720_mic_automute(codec);
8837}
8838
8839static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008840 unsigned int res)
8841{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008842 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008843 case ALC880_MIC_EVENT:
8844 alc883_clevo_m720_mic_automute(codec);
8845 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008846 default:
8847 alc_automute_amp_unsol_event(codec, res);
8848 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008849 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008850}
8851
Jiang zhefb97dc62008-03-06 11:07:11 +01008852/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008853static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008854{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008855 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008856
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008857 spec->autocfg.hp_pins[0] = 0x14;
8858 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008859}
8860
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008861static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008862{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008863 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008864
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008865 spec->autocfg.hp_pins[0] = 0x1b;
8866 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008867}
8868
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008869static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8870{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008871 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008872
Takashi Iwai47fd8302007-08-10 17:11:07 +02008873 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8874 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008875}
8876
8877static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8878{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008879 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008880
Takashi Iwai47fd8302007-08-10 17:11:07 +02008881 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8882 HDA_AMP_MUTE, bits);
8883 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8884 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008885}
8886
8887static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8888 unsigned int res)
8889{
8890 if ((res >> 26) == ALC880_HP_EVENT)
8891 alc883_lenovo_101e_all_automute(codec);
8892 if ((res >> 26) == ALC880_FRONT_EVENT)
8893 alc883_lenovo_101e_ispeaker_automute(codec);
8894}
8895
Takashi Iwai676a9b52007-08-16 15:23:35 +02008896/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008897static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008898{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008899 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008900
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008901 spec->autocfg.hp_pins[0] = 0x14;
8902 spec->autocfg.speaker_pins[0] = 0x15;
8903 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008904}
8905
Kailang Yangd1a991a2007-08-15 16:21:59 +02008906static struct hda_verb alc883_acer_eapd_verbs[] = {
8907 /* HP Pin: output 0 (0x0c) */
8908 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8910 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8911 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008912 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8913 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008914 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008915 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8916 /* eanable EAPD on medion laptop */
8917 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8918 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008919 /* enable unsolicited event */
8920 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008921 { }
8922};
8923
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008924static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8925 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8926 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8927 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8928 { } /* end */
8929};
8930
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008931static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008932{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008933 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008934
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008935 spec->autocfg.hp_pins[0] = 0x1b;
8936 spec->autocfg.speaker_pins[0] = 0x14;
8937 spec->autocfg.speaker_pins[1] = 0x15;
8938 spec->autocfg.speaker_pins[2] = 0x16;
8939 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008940}
8941
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008942static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008943{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008944 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008945
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008946 spec->autocfg.hp_pins[0] = 0x1b;
8947 spec->autocfg.speaker_pins[0] = 0x14;
8948 spec->autocfg.speaker_pins[1] = 0x15;
8949 spec->autocfg.speaker_pins[2] = 0x16;
8950 spec->autocfg.speaker_pins[3] = 0x17;
8951 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008952}
8953
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008954static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02008955{
8956 struct alc_spec *spec = codec->spec;
8957
8958 spec->autocfg.hp_pins[0] = 0x15;
8959 spec->autocfg.speaker_pins[0] = 0x14;
8960 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02008961}
8962
Kailang Yange2757d52008-08-26 13:17:46 +02008963static struct hda_verb alc888_asus_m90v_verbs[] = {
8964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8965 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8967 /* enable unsolicited event */
8968 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8969 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8970 { } /* end */
8971};
8972
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008973static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008974{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008975 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008976
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008977 spec->autocfg.hp_pins[0] = 0x1b;
8978 spec->autocfg.speaker_pins[0] = 0x14;
8979 spec->autocfg.speaker_pins[1] = 0x15;
8980 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008981 spec->ext_mic.pin = 0x18;
8982 spec->int_mic.pin = 0x19;
8983 spec->ext_mic.mux_idx = 0;
8984 spec->int_mic.mux_idx = 1;
8985 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008986}
8987
8988static struct hda_verb alc888_asus_eee1601_verbs[] = {
8989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8990 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8991 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8992 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8994 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8995 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8996 /* enable unsolicited event */
8997 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8998 { } /* end */
8999};
9000
Kailang Yange2757d52008-08-26 13:17:46 +02009001static void alc883_eee1601_inithook(struct hda_codec *codec)
9002{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009003 struct alc_spec *spec = codec->spec;
9004
9005 spec->autocfg.hp_pins[0] = 0x14;
9006 spec->autocfg.speaker_pins[0] = 0x1b;
9007 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009008}
9009
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009010static struct hda_verb alc889A_mb31_verbs[] = {
9011 /* Init rear pin (used as headphone output) */
9012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9013 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9014 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9015 /* Init line pin (used as output in 4ch and 6ch mode) */
9016 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9017 /* Init line 2 pin (used as headphone out by default) */
9018 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9019 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9020 { } /* end */
9021};
9022
9023/* Mute speakers according to the headphone jack state */
9024static void alc889A_mb31_automute(struct hda_codec *codec)
9025{
9026 unsigned int present;
9027
9028 /* Mute only in 2ch or 4ch mode */
9029 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9030 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009031 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009032 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9033 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9034 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9035 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9036 }
9037}
9038
9039static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9040{
9041 if ((res >> 26) == ALC880_HP_EVENT)
9042 alc889A_mb31_automute(codec);
9043}
9044
Takashi Iwai4953550a2009-06-30 15:28:30 +02009045
Takashi Iwaicb53c622007-08-10 17:21:45 +02009046#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009047#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009048#endif
9049
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009050/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009051#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9052#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9053#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9054#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9055
9056static hda_nid_t alc883_slave_dig_outs[] = {
9057 ALC1200_DIGOUT_NID, 0,
9058};
9059
9060static hda_nid_t alc1200_slave_dig_outs[] = {
9061 ALC883_DIGOUT_NID, 0,
9062};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009063
9064/*
9065 * configuration and preset
9066 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009067static const char *alc882_models[ALC882_MODEL_LAST] = {
9068 [ALC882_3ST_DIG] = "3stack-dig",
9069 [ALC882_6ST_DIG] = "6stack-dig",
9070 [ALC882_ARIMA] = "arima",
9071 [ALC882_W2JC] = "w2jc",
9072 [ALC882_TARGA] = "targa",
9073 [ALC882_ASUS_A7J] = "asus-a7j",
9074 [ALC882_ASUS_A7M] = "asus-a7m",
9075 [ALC885_MACPRO] = "macpro",
9076 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009077 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009078 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009079 [ALC885_MBP3] = "mbp3",
9080 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009081 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009082 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009083 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9084 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009085 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009086 [ALC883_TARGA_DIG] = "targa-dig",
9087 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009088 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009089 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009090 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009091 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009092 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009093 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009094 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009095 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009096 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009097 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009098 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009099 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9100 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009101 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009102 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009103 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009104 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009105 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309106 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009107 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009108 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009109 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009110 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009111 [ALC889A_INTEL] = "intel-alc889a",
9112 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009113 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009114 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009115 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009116 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009117};
9118
Takashi Iwai4953550a2009-06-30 15:28:30 +02009119static struct snd_pci_quirk alc882_cfg_tbl[] = {
9120 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9121
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009122 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009123 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009124 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009125 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9126 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009127 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009128 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9129 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009130 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009131 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009132 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9133 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009134 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9135 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009136 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9137 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009138 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009139 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009140 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009141 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009142 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9143 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009144 /* default Acer -- disabled as it causes more problems.
9145 * model=auto should work fine now
9146 */
9147 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009148
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009149 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009150
Tobin Davisfebe3372007-06-12 11:27:46 +02009151 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009152 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9153 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009154 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009155 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009156 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009157
9158 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9159 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9160 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009161 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009162 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9163 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9164 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009165 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009166 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009167 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009168 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009169
9170 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009171 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009172 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009173 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009174 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9175 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009176 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009177 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009178 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9179
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009180 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9181 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9182 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009183 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009184 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009185 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009186 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009187 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009188 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9189 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9190 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9191 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9192 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9193 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009194 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009195 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9196 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9197 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009198 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009199 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009200 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9201 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009202 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009203 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009204 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009205 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009206 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009207 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009208 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009209 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009210 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009211
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009212 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009213 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9214 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309215 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009216 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009217 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009218 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009219 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009220 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009221 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009222 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009223 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009224 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009225 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009226 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9227 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009228 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009229 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009230 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009231 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009232 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009233
Jiang zhe17bba1b2008-06-04 12:11:07 +02009234 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9235 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009236 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009237 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9238 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9239 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009240 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009241
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009242 {}
9243};
9244
Takashi Iwai4953550a2009-06-30 15:28:30 +02009245/* codec SSID table for Intel Mac */
9246static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9247 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9248 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9249 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9250 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9251 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9252 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9253 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9254 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9255 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9256 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009257 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009258 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009259 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9260 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009261 */
9262 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009263 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009264 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009265 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009266};
9267
Takashi Iwai4953550a2009-06-30 15:28:30 +02009268static struct alc_config_preset alc882_presets[] = {
9269 [ALC882_3ST_DIG] = {
9270 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009271 .init_verbs = { alc882_base_init_verbs,
9272 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009273 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9274 .dac_nids = alc882_dac_nids,
9275 .dig_out_nid = ALC882_DIGOUT_NID,
9276 .dig_in_nid = ALC882_DIGIN_NID,
9277 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9278 .channel_mode = alc882_ch_modes,
9279 .need_dac_fix = 1,
9280 .input_mux = &alc882_capture_source,
9281 },
9282 [ALC882_6ST_DIG] = {
9283 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009284 .init_verbs = { alc882_base_init_verbs,
9285 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009286 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9287 .dac_nids = alc882_dac_nids,
9288 .dig_out_nid = ALC882_DIGOUT_NID,
9289 .dig_in_nid = ALC882_DIGIN_NID,
9290 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9291 .channel_mode = alc882_sixstack_modes,
9292 .input_mux = &alc882_capture_source,
9293 },
9294 [ALC882_ARIMA] = {
9295 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009296 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9297 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009298 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9299 .dac_nids = alc882_dac_nids,
9300 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9301 .channel_mode = alc882_sixstack_modes,
9302 .input_mux = &alc882_capture_source,
9303 },
9304 [ALC882_W2JC] = {
9305 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009306 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9307 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009308 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9309 .dac_nids = alc882_dac_nids,
9310 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9311 .channel_mode = alc880_threestack_modes,
9312 .need_dac_fix = 1,
9313 .input_mux = &alc882_capture_source,
9314 .dig_out_nid = ALC882_DIGOUT_NID,
9315 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009316 [ALC885_MBA21] = {
9317 .mixers = { alc885_mba21_mixer },
9318 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9319 .num_dacs = 2,
9320 .dac_nids = alc882_dac_nids,
9321 .channel_mode = alc885_mba21_ch_modes,
9322 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9323 .input_mux = &alc882_capture_source,
9324 .unsol_event = alc_automute_amp_unsol_event,
9325 .setup = alc885_mba21_setup,
9326 .init_hook = alc_automute_amp,
9327 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009328 [ALC885_MBP3] = {
9329 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9330 .init_verbs = { alc885_mbp3_init_verbs,
9331 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009332 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009333 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009334 .hp_nid = 0x04,
9335 .channel_mode = alc885_mbp_4ch_modes,
9336 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009337 .input_mux = &alc882_capture_source,
9338 .dig_out_nid = ALC882_DIGOUT_NID,
9339 .dig_in_nid = ALC882_DIGIN_NID,
9340 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009341 .setup = alc885_mbp3_setup,
9342 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009343 },
9344 [ALC885_MB5] = {
9345 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9346 .init_verbs = { alc885_mb5_init_verbs,
9347 alc880_gpio1_init_verbs },
9348 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9349 .dac_nids = alc882_dac_nids,
9350 .channel_mode = alc885_mb5_6ch_modes,
9351 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9352 .input_mux = &mb5_capture_source,
9353 .dig_out_nid = ALC882_DIGOUT_NID,
9354 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009355 .unsol_event = alc_automute_amp_unsol_event,
9356 .setup = alc885_mb5_setup,
9357 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009358 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009359 [ALC885_MACMINI3] = {
9360 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9361 .init_verbs = { alc885_macmini3_init_verbs,
9362 alc880_gpio1_init_verbs },
9363 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9364 .dac_nids = alc882_dac_nids,
9365 .channel_mode = alc885_macmini3_6ch_modes,
9366 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9367 .input_mux = &macmini3_capture_source,
9368 .dig_out_nid = ALC882_DIGOUT_NID,
9369 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009370 .unsol_event = alc_automute_amp_unsol_event,
9371 .setup = alc885_macmini3_setup,
9372 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009373 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009374 [ALC885_MACPRO] = {
9375 .mixers = { alc882_macpro_mixer },
9376 .init_verbs = { alc882_macpro_init_verbs },
9377 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9378 .dac_nids = alc882_dac_nids,
9379 .dig_out_nid = ALC882_DIGOUT_NID,
9380 .dig_in_nid = ALC882_DIGIN_NID,
9381 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9382 .channel_mode = alc882_ch_modes,
9383 .input_mux = &alc882_capture_source,
9384 .init_hook = alc885_macpro_init_hook,
9385 },
9386 [ALC885_IMAC24] = {
9387 .mixers = { alc885_imac24_mixer },
9388 .init_verbs = { alc885_imac24_init_verbs },
9389 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9390 .dac_nids = alc882_dac_nids,
9391 .dig_out_nid = ALC882_DIGOUT_NID,
9392 .dig_in_nid = ALC882_DIGIN_NID,
9393 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9394 .channel_mode = alc882_ch_modes,
9395 .input_mux = &alc882_capture_source,
9396 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009397 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009398 .init_hook = alc885_imac24_init_hook,
9399 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009400 [ALC885_IMAC91] = {
9401 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9402 .init_verbs = { alc885_imac91_init_verbs,
9403 alc880_gpio1_init_verbs },
9404 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9405 .dac_nids = alc882_dac_nids,
9406 .channel_mode = alc885_mbp_4ch_modes,
9407 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9408 .input_mux = &alc882_capture_source,
9409 .dig_out_nid = ALC882_DIGOUT_NID,
9410 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009411 .unsol_event = alc_automute_amp_unsol_event,
9412 .setup = alc885_imac91_setup,
9413 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009414 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009415 [ALC882_TARGA] = {
9416 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009417 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009418 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009419 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9420 .dac_nids = alc882_dac_nids,
9421 .dig_out_nid = ALC882_DIGOUT_NID,
9422 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9423 .adc_nids = alc882_adc_nids,
9424 .capsrc_nids = alc882_capsrc_nids,
9425 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9426 .channel_mode = alc882_3ST_6ch_modes,
9427 .need_dac_fix = 1,
9428 .input_mux = &alc882_capture_source,
9429 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009430 .setup = alc882_targa_setup,
9431 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009432 },
9433 [ALC882_ASUS_A7J] = {
9434 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009435 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9436 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009437 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9438 .dac_nids = alc882_dac_nids,
9439 .dig_out_nid = ALC882_DIGOUT_NID,
9440 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9441 .adc_nids = alc882_adc_nids,
9442 .capsrc_nids = alc882_capsrc_nids,
9443 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9444 .channel_mode = alc882_3ST_6ch_modes,
9445 .need_dac_fix = 1,
9446 .input_mux = &alc882_capture_source,
9447 },
9448 [ALC882_ASUS_A7M] = {
9449 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009450 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9451 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009452 alc882_asus_a7m_verbs },
9453 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9454 .dac_nids = alc882_dac_nids,
9455 .dig_out_nid = ALC882_DIGOUT_NID,
9456 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9457 .channel_mode = alc880_threestack_modes,
9458 .need_dac_fix = 1,
9459 .input_mux = &alc882_capture_source,
9460 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009461 [ALC883_3ST_2ch_DIG] = {
9462 .mixers = { alc883_3ST_2ch_mixer },
9463 .init_verbs = { alc883_init_verbs },
9464 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9465 .dac_nids = alc883_dac_nids,
9466 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009467 .dig_in_nid = ALC883_DIGIN_NID,
9468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9469 .channel_mode = alc883_3ST_2ch_modes,
9470 .input_mux = &alc883_capture_source,
9471 },
9472 [ALC883_3ST_6ch_DIG] = {
9473 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9474 .init_verbs = { alc883_init_verbs },
9475 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9476 .dac_nids = alc883_dac_nids,
9477 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009478 .dig_in_nid = ALC883_DIGIN_NID,
9479 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9480 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009481 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009482 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009483 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009484 [ALC883_3ST_6ch] = {
9485 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9486 .init_verbs = { alc883_init_verbs },
9487 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9488 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009489 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9490 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009491 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009492 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009493 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009494 [ALC883_3ST_6ch_INTEL] = {
9495 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9496 .init_verbs = { alc883_init_verbs },
9497 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9498 .dac_nids = alc883_dac_nids,
9499 .dig_out_nid = ALC883_DIGOUT_NID,
9500 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009501 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009502 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9503 .channel_mode = alc883_3ST_6ch_intel_modes,
9504 .need_dac_fix = 1,
9505 .input_mux = &alc883_3stack_6ch_intel,
9506 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009507 [ALC889A_INTEL] = {
9508 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009509 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9510 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9512 .dac_nids = alc883_dac_nids,
9513 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9514 .adc_nids = alc889_adc_nids,
9515 .dig_out_nid = ALC883_DIGOUT_NID,
9516 .dig_in_nid = ALC883_DIGIN_NID,
9517 .slave_dig_outs = alc883_slave_dig_outs,
9518 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9519 .channel_mode = alc889_8ch_intel_modes,
9520 .capsrc_nids = alc889_capsrc_nids,
9521 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009522 .setup = alc889_automute_setup,
9523 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009524 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009525 .need_dac_fix = 1,
9526 },
9527 [ALC889_INTEL] = {
9528 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9529 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009530 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9532 .dac_nids = alc883_dac_nids,
9533 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9534 .adc_nids = alc889_adc_nids,
9535 .dig_out_nid = ALC883_DIGOUT_NID,
9536 .dig_in_nid = ALC883_DIGIN_NID,
9537 .slave_dig_outs = alc883_slave_dig_outs,
9538 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9539 .channel_mode = alc889_8ch_intel_modes,
9540 .capsrc_nids = alc889_capsrc_nids,
9541 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009542 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009543 .init_hook = alc889_intel_init_hook,
9544 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009545 .need_dac_fix = 1,
9546 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009547 [ALC883_6ST_DIG] = {
9548 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9549 .init_verbs = { alc883_init_verbs },
9550 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9551 .dac_nids = alc883_dac_nids,
9552 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009553 .dig_in_nid = ALC883_DIGIN_NID,
9554 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9555 .channel_mode = alc883_sixstack_modes,
9556 .input_mux = &alc883_capture_source,
9557 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009558 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009559 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009560 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9561 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9563 .dac_nids = alc883_dac_nids,
9564 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009565 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9566 .channel_mode = alc883_3ST_6ch_modes,
9567 .need_dac_fix = 1,
9568 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009569 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009570 .setup = alc882_targa_setup,
9571 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009572 },
9573 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009574 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009575 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9576 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009577 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9578 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009579 .adc_nids = alc883_adc_nids_alt,
9580 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009581 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009582 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009583 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9584 .channel_mode = alc883_3ST_2ch_modes,
9585 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009586 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009587 .setup = alc882_targa_setup,
9588 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009589 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009590 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009591 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9592 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009593 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009594 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009595 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9596 .dac_nids = alc883_dac_nids,
9597 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9598 .adc_nids = alc883_adc_nids_rev,
9599 .capsrc_nids = alc883_capsrc_nids_rev,
9600 .dig_out_nid = ALC883_DIGOUT_NID,
9601 .dig_in_nid = ALC883_DIGIN_NID,
9602 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9603 .channel_mode = alc883_4ST_8ch_modes,
9604 .need_dac_fix = 1,
9605 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009606 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009607 .setup = alc882_targa_setup,
9608 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009609 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009610 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009611 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009612 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9613 * and the headphone jack. Turn this on and rely on the
9614 * standard mute methods whenever the user wants to turn
9615 * these outputs off.
9616 */
9617 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9618 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9619 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009620 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9621 .channel_mode = alc883_3ST_2ch_modes,
9622 .input_mux = &alc883_capture_source,
9623 },
Tobin Davis2880a862007-08-07 11:50:26 +02009624 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009625 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009626 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009627 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9628 .dac_nids = alc883_dac_nids,
9629 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9631 .channel_mode = alc883_3ST_2ch_modes,
9632 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009633 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009634 .setup = alc883_acer_aspire_setup,
9635 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009636 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009637 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009638 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009639 alc883_chmode_mixer },
9640 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9641 alc888_acer_aspire_4930g_verbs },
9642 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9643 .dac_nids = alc883_dac_nids,
9644 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9645 .adc_nids = alc883_adc_nids_rev,
9646 .capsrc_nids = alc883_capsrc_nids_rev,
9647 .dig_out_nid = ALC883_DIGOUT_NID,
9648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9649 .channel_mode = alc883_3ST_6ch_modes,
9650 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009651 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009652 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009653 ARRAY_SIZE(alc888_2_capture_sources),
9654 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009655 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009656 .setup = alc888_acer_aspire_4930g_setup,
9657 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009658 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009659 [ALC888_ACER_ASPIRE_6530G] = {
9660 .mixers = { alc888_acer_aspire_6530_mixer },
9661 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9662 alc888_acer_aspire_6530g_verbs },
9663 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9664 .dac_nids = alc883_dac_nids,
9665 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9666 .adc_nids = alc883_adc_nids_rev,
9667 .capsrc_nids = alc883_capsrc_nids_rev,
9668 .dig_out_nid = ALC883_DIGOUT_NID,
9669 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9670 .channel_mode = alc883_3ST_2ch_modes,
9671 .num_mux_defs =
9672 ARRAY_SIZE(alc888_2_capture_sources),
9673 .input_mux = alc888_acer_aspire_6530_sources,
9674 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009675 .setup = alc888_acer_aspire_6530g_setup,
9676 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009677 },
Hector Martin3b315d72009-06-02 10:54:19 +02009678 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009679 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009680 alc883_chmode_mixer },
9681 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009682 alc889_acer_aspire_8930g_verbs,
9683 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009684 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9685 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009686 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9687 .adc_nids = alc889_adc_nids,
9688 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009689 .dig_out_nid = ALC883_DIGOUT_NID,
9690 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9691 .channel_mode = alc883_3ST_6ch_modes,
9692 .need_dac_fix = 1,
9693 .const_channel_count = 6,
9694 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009695 ARRAY_SIZE(alc889_capture_sources),
9696 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009697 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009698 .setup = alc889_acer_aspire_8930g_setup,
9699 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009700#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009701 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009702#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009703 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009704 [ALC888_ACER_ASPIRE_7730G] = {
9705 .mixers = { alc883_3ST_6ch_mixer,
9706 alc883_chmode_mixer },
9707 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9708 alc888_acer_aspire_7730G_verbs },
9709 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9710 .dac_nids = alc883_dac_nids,
9711 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9712 .adc_nids = alc883_adc_nids_rev,
9713 .capsrc_nids = alc883_capsrc_nids_rev,
9714 .dig_out_nid = ALC883_DIGOUT_NID,
9715 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9716 .channel_mode = alc883_3ST_6ch_modes,
9717 .need_dac_fix = 1,
9718 .const_channel_count = 6,
9719 .input_mux = &alc883_capture_source,
9720 .unsol_event = alc_automute_amp_unsol_event,
9721 .setup = alc888_acer_aspire_6530g_setup,
9722 .init_hook = alc_automute_amp,
9723 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009724 [ALC883_MEDION] = {
9725 .mixers = { alc883_fivestack_mixer,
9726 alc883_chmode_mixer },
9727 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009728 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009729 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9730 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009731 .adc_nids = alc883_adc_nids_alt,
9732 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009733 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009734 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9735 .channel_mode = alc883_sixstack_modes,
9736 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009737 },
Kailang Yang272a5272007-05-14 11:00:38 +02009738 [ALC883_MEDION_MD2] = {
9739 .mixers = { alc883_medion_md2_mixer},
9740 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9741 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9742 .dac_nids = alc883_dac_nids,
9743 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009744 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9745 .channel_mode = alc883_3ST_2ch_modes,
9746 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009747 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009748 .setup = alc883_medion_md2_setup,
9749 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009750 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009751 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009752 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009753 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9754 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9755 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009756 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9757 .channel_mode = alc883_3ST_2ch_modes,
9758 .input_mux = &alc883_capture_source,
9759 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309760 [ALC883_CLEVO_M540R] = {
9761 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9762 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9763 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9764 .dac_nids = alc883_dac_nids,
9765 .dig_out_nid = ALC883_DIGOUT_NID,
9766 .dig_in_nid = ALC883_DIGIN_NID,
9767 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9768 .channel_mode = alc883_3ST_6ch_clevo_modes,
9769 .need_dac_fix = 1,
9770 .input_mux = &alc883_capture_source,
9771 /* This machine has the hardware HP auto-muting, thus
9772 * we need no software mute via unsol event
9773 */
9774 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009775 [ALC883_CLEVO_M720] = {
9776 .mixers = { alc883_clevo_m720_mixer },
9777 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009778 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9779 .dac_nids = alc883_dac_nids,
9780 .dig_out_nid = ALC883_DIGOUT_NID,
9781 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9782 .channel_mode = alc883_3ST_2ch_modes,
9783 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009784 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009785 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009786 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009787 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009788 [ALC883_LENOVO_101E_2ch] = {
9789 .mixers = { alc883_lenovo_101e_2ch_mixer},
9790 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9791 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9792 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009793 .adc_nids = alc883_adc_nids_alt,
9794 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009795 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009796 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9797 .channel_mode = alc883_3ST_2ch_modes,
9798 .input_mux = &alc883_lenovo_101e_capture_source,
9799 .unsol_event = alc883_lenovo_101e_unsol_event,
9800 .init_hook = alc883_lenovo_101e_all_automute,
9801 },
Kailang Yang272a5272007-05-14 11:00:38 +02009802 [ALC883_LENOVO_NB0763] = {
9803 .mixers = { alc883_lenovo_nb0763_mixer },
9804 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9805 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9806 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009807 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9808 .channel_mode = alc883_3ST_2ch_modes,
9809 .need_dac_fix = 1,
9810 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009811 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009812 .setup = alc883_medion_md2_setup,
9813 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009814 },
9815 [ALC888_LENOVO_MS7195_DIG] = {
9816 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9817 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9818 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9819 .dac_nids = alc883_dac_nids,
9820 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009821 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9822 .channel_mode = alc883_3ST_6ch_modes,
9823 .need_dac_fix = 1,
9824 .input_mux = &alc883_capture_source,
9825 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9826 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009827 },
9828 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009829 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009830 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9831 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9832 .dac_nids = alc883_dac_nids,
9833 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009834 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9835 .channel_mode = alc883_3ST_2ch_modes,
9836 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009837 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009838 .setup = alc883_haier_w66_setup,
9839 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009840 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009841 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009842 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009843 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009844 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9845 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009846 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9847 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009848 .need_dac_fix = 1,
9849 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009850 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009851 .setup = alc888_3st_hp_setup,
9852 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009853 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009854 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009855 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009856 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9858 .dac_nids = alc883_dac_nids,
9859 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009860 .dig_in_nid = ALC883_DIGIN_NID,
9861 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9862 .channel_mode = alc883_sixstack_modes,
9863 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009864 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009865 .setup = alc888_6st_dell_setup,
9866 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009867 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009868 [ALC883_MITAC] = {
9869 .mixers = { alc883_mitac_mixer },
9870 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9871 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9872 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009873 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9874 .channel_mode = alc883_3ST_2ch_modes,
9875 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009876 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009877 .setup = alc883_mitac_setup,
9878 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009879 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009880 [ALC883_FUJITSU_PI2515] = {
9881 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9882 .init_verbs = { alc883_init_verbs,
9883 alc883_2ch_fujitsu_pi2515_verbs},
9884 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9885 .dac_nids = alc883_dac_nids,
9886 .dig_out_nid = ALC883_DIGOUT_NID,
9887 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9888 .channel_mode = alc883_3ST_2ch_modes,
9889 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009890 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009891 .setup = alc883_2ch_fujitsu_pi2515_setup,
9892 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009893 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009894 [ALC888_FUJITSU_XA3530] = {
9895 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9896 .init_verbs = { alc883_init_verbs,
9897 alc888_fujitsu_xa3530_verbs },
9898 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9899 .dac_nids = alc883_dac_nids,
9900 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9901 .adc_nids = alc883_adc_nids_rev,
9902 .capsrc_nids = alc883_capsrc_nids_rev,
9903 .dig_out_nid = ALC883_DIGOUT_NID,
9904 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9905 .channel_mode = alc888_4ST_8ch_intel_modes,
9906 .num_mux_defs =
9907 ARRAY_SIZE(alc888_2_capture_sources),
9908 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009909 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009910 .setup = alc888_fujitsu_xa3530_setup,
9911 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009912 },
Kailang Yange2757d52008-08-26 13:17:46 +02009913 [ALC888_LENOVO_SKY] = {
9914 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9915 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9916 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9917 .dac_nids = alc883_dac_nids,
9918 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009919 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9920 .channel_mode = alc883_sixstack_modes,
9921 .need_dac_fix = 1,
9922 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009923 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009924 .setup = alc888_lenovo_sky_setup,
9925 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009926 },
9927 [ALC888_ASUS_M90V] = {
9928 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9929 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9930 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9931 .dac_nids = alc883_dac_nids,
9932 .dig_out_nid = ALC883_DIGOUT_NID,
9933 .dig_in_nid = ALC883_DIGIN_NID,
9934 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9935 .channel_mode = alc883_3ST_6ch_modes,
9936 .need_dac_fix = 1,
9937 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009938 .unsol_event = alc_sku_unsol_event,
9939 .setup = alc883_mode2_setup,
9940 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009941 },
9942 [ALC888_ASUS_EEE1601] = {
9943 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009944 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009945 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9946 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9947 .dac_nids = alc883_dac_nids,
9948 .dig_out_nid = ALC883_DIGOUT_NID,
9949 .dig_in_nid = ALC883_DIGIN_NID,
9950 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9951 .channel_mode = alc883_3ST_2ch_modes,
9952 .need_dac_fix = 1,
9953 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009954 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009955 .init_hook = alc883_eee1601_inithook,
9956 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009957 [ALC1200_ASUS_P5Q] = {
9958 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9959 .init_verbs = { alc883_init_verbs },
9960 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9961 .dac_nids = alc883_dac_nids,
9962 .dig_out_nid = ALC1200_DIGOUT_NID,
9963 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009964 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009965 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9966 .channel_mode = alc883_sixstack_modes,
9967 .input_mux = &alc883_capture_source,
9968 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009969 [ALC889A_MB31] = {
9970 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9971 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9972 alc880_gpio1_init_verbs },
9973 .adc_nids = alc883_adc_nids,
9974 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009975 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009976 .dac_nids = alc883_dac_nids,
9977 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9978 .channel_mode = alc889A_mb31_6ch_modes,
9979 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9980 .input_mux = &alc889A_mb31_capture_source,
9981 .dig_out_nid = ALC883_DIGOUT_NID,
9982 .unsol_event = alc889A_mb31_unsol_event,
9983 .init_hook = alc889A_mb31_automute,
9984 },
Guido Günther3e1647c52009-06-05 00:47:26 +02009985 [ALC883_SONY_VAIO_TT] = {
9986 .mixers = { alc883_vaiott_mixer },
9987 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9988 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9989 .dac_nids = alc883_dac_nids,
9990 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9991 .channel_mode = alc883_3ST_2ch_modes,
9992 .input_mux = &alc883_capture_source,
9993 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009994 .setup = alc883_vaiott_setup,
9995 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +02009996 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009997};
9998
9999
10000/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010001 * Pin config fixes
10002 */
10003enum {
10004 PINFIX_ABIT_AW9D_MAX
10005};
10006
10007static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10008 { 0x15, 0x01080104 }, /* side */
10009 { 0x16, 0x01011012 }, /* rear */
10010 { 0x17, 0x01016011 }, /* clfe */
10011 { }
10012};
10013
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010014static const struct alc_fixup alc882_fixups[] = {
10015 [PINFIX_ABIT_AW9D_MAX] = {
10016 .pins = alc882_abit_aw9d_pinfix
10017 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010018};
10019
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010020static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010021 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10022 {}
10023};
10024
10025/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010026 * BIOS auto configuration
10027 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010028static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10029 const struct auto_pin_cfg *cfg)
10030{
10031 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10032}
10033
Takashi Iwai4953550a2009-06-30 15:28:30 +020010034static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010035 hda_nid_t nid, int pin_type,
10036 int dac_idx)
10037{
10038 /* set as output */
10039 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010040 int idx;
10041
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010042 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010043 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10044 idx = 4;
10045 else
10046 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010047 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10048
10049}
10050
Takashi Iwai4953550a2009-06-30 15:28:30 +020010051static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010052{
10053 struct alc_spec *spec = codec->spec;
10054 int i;
10055
10056 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010057 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010058 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010059 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010060 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010061 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062 }
10063}
10064
Takashi Iwai4953550a2009-06-30 15:28:30 +020010065static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010066{
10067 struct alc_spec *spec = codec->spec;
10068 hda_nid_t pin;
10069
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010070 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010071 if (pin) /* connect to front */
10072 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010073 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010074 pin = spec->autocfg.speaker_pins[0];
10075 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010076 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010077}
10078
Takashi Iwai4953550a2009-06-30 15:28:30 +020010079static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010080{
10081 struct alc_spec *spec = codec->spec;
10082 int i;
10083
10084 for (i = 0; i < AUTO_PIN_LAST; i++) {
10085 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010086 if (!nid)
10087 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010088 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010089 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10090 snd_hda_codec_write(codec, nid, 0,
10091 AC_VERB_SET_AMP_GAIN_MUTE,
10092 AMP_OUT_MUTE);
10093 }
10094}
10095
10096static void alc882_auto_init_input_src(struct hda_codec *codec)
10097{
10098 struct alc_spec *spec = codec->spec;
10099 int c;
10100
10101 for (c = 0; c < spec->num_adc_nids; c++) {
10102 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10103 hda_nid_t nid = spec->capsrc_nids[c];
10104 unsigned int mux_idx;
10105 const struct hda_input_mux *imux;
10106 int conns, mute, idx, item;
10107
10108 conns = snd_hda_get_connections(codec, nid, conn_list,
10109 ARRAY_SIZE(conn_list));
10110 if (conns < 0)
10111 continue;
10112 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10113 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010114 if (!imux->num_items && mux_idx > 0)
10115 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010116 for (idx = 0; idx < conns; idx++) {
10117 /* if the current connection is the selected one,
10118 * unmute it as default - otherwise mute it
10119 */
10120 mute = AMP_IN_MUTE(idx);
10121 for (item = 0; item < imux->num_items; item++) {
10122 if (imux->items[item].index == idx) {
10123 if (spec->cur_mux[c] == item)
10124 mute = AMP_IN_UNMUTE(idx);
10125 break;
10126 }
10127 }
10128 /* check if we have a selector or mixer
10129 * we could check for the widget type instead, but
10130 * just check for Amp-In presence (in case of mixer
10131 * without amp-in there is something wrong, this
10132 * function shouldn't be used or capsrc nid is wrong)
10133 */
10134 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010135 snd_hda_codec_write(codec, nid, 0,
10136 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010137 mute);
10138 else if (mute != AMP_IN_MUTE(idx))
10139 snd_hda_codec_write(codec, nid, 0,
10140 AC_VERB_SET_CONNECT_SEL,
10141 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010142 }
10143 }
10144}
10145
Takashi Iwai4953550a2009-06-30 15:28:30 +020010146/* add mic boosts if needed */
10147static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010148{
10149 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010150 int err;
10151 hda_nid_t nid;
10152
10153 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10154 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10155 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10156 "Mic Boost",
10157 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10158 if (err < 0)
10159 return err;
10160 }
10161 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10162 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10163 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10164 "Front Mic Boost",
10165 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10166 if (err < 0)
10167 return err;
10168 }
10169 return 0;
10170}
10171
10172/* almost identical with ALC880 parser... */
10173static int alc882_parse_auto_config(struct hda_codec *codec)
10174{
10175 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010176 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10177 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010178
Takashi Iwai05f5f472009-08-25 13:10:18 +020010179 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10180 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010181 if (err < 0)
10182 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010183 if (!spec->autocfg.line_outs)
10184 return 0; /* can't find valid BIOS pin config */
10185
10186 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10187 if (err < 0)
10188 return err;
10189 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10190 if (err < 0)
10191 return err;
10192 err = alc880_auto_create_extra_out(spec,
10193 spec->autocfg.speaker_pins[0],
10194 "Speaker");
10195 if (err < 0)
10196 return err;
10197 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10198 "Headphone");
10199 if (err < 0)
10200 return err;
10201 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10202 if (err < 0)
10203 return err;
10204
10205 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10206
10207 /* check multiple SPDIF-out (for recent codecs) */
10208 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10209 hda_nid_t dig_nid;
10210 err = snd_hda_get_connections(codec,
10211 spec->autocfg.dig_out_pins[i],
10212 &dig_nid, 1);
10213 if (err < 0)
10214 continue;
10215 if (!i)
10216 spec->multiout.dig_out_nid = dig_nid;
10217 else {
10218 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010219 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010220 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010221 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010222 }
10223 }
10224 if (spec->autocfg.dig_in_pin)
10225 spec->dig_in_nid = ALC880_DIGIN_NID;
10226
10227 if (spec->kctls.list)
10228 add_mixer(spec, spec->kctls.list);
10229
10230 add_verb(spec, alc883_auto_init_verbs);
10231 /* if ADC 0x07 is available, initialize it, too */
10232 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10233 add_verb(spec, alc882_adc1_init_verbs);
10234
10235 spec->num_mux_defs = 1;
10236 spec->input_mux = &spec->private_imux[0];
10237
Kailang Yang6227cdc2010-02-25 08:36:52 +010010238 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010239
10240 err = alc_auto_add_mic_boost(codec);
10241 if (err < 0)
10242 return err;
10243
Takashi Iwai776e1842007-08-29 15:07:11 +020010244 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010245}
10246
10247/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010248static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010249{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010250 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010251 alc882_auto_init_multi_out(codec);
10252 alc882_auto_init_hp_out(codec);
10253 alc882_auto_init_analog_input(codec);
10254 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010255 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010256 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010257}
10258
Takashi Iwai4953550a2009-06-30 15:28:30 +020010259static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010260{
10261 struct alc_spec *spec;
10262 int err, board_config;
10263
10264 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10265 if (spec == NULL)
10266 return -ENOMEM;
10267
10268 codec->spec = spec;
10269
Takashi Iwai4953550a2009-06-30 15:28:30 +020010270 switch (codec->vendor_id) {
10271 case 0x10ec0882:
10272 case 0x10ec0885:
10273 break;
10274 default:
10275 /* ALC883 and variants */
10276 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10277 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010278 }
10279
Takashi Iwai4953550a2009-06-30 15:28:30 +020010280 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10281 alc882_models,
10282 alc882_cfg_tbl);
10283
10284 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10285 board_config = snd_hda_check_board_codec_sid_config(codec,
10286 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10287
10288 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010289 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010290 codec->chip_name);
10291 board_config = ALC882_AUTO;
10292 }
10293
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010294 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010295
10296 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010297 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010298 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010299 if (err < 0) {
10300 alc_free(codec);
10301 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010302 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010303 printk(KERN_INFO
10304 "hda_codec: Cannot set up configuration "
10305 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010306 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010307 }
10308 }
10309
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010310 err = snd_hda_attach_beep_device(codec, 0x1);
10311 if (err < 0) {
10312 alc_free(codec);
10313 return err;
10314 }
10315
Takashi Iwai4953550a2009-06-30 15:28:30 +020010316 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010317 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010318
Takashi Iwai4953550a2009-06-30 15:28:30 +020010319 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10320 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10321 /* FIXME: setup DAC5 */
10322 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10323 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10324
10325 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10326 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10327
10328 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010329 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010330
10331 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010332 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010333 spec->num_adc_nids = 0;
10334 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010335 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010336 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010337 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010338 hda_nid_t nid = alc882_adc_nids[i];
10339 unsigned int wcap = get_wcaps(codec, nid);
10340 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010341 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010342 if (wcap != AC_WID_AUD_IN)
10343 continue;
10344 spec->private_adc_nids[spec->num_adc_nids] = nid;
10345 err = snd_hda_get_connections(codec, nid, &cap, 1);
10346 if (err < 0)
10347 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010348 err = snd_hda_get_connections(codec, cap, items,
10349 ARRAY_SIZE(items));
10350 if (err < 0)
10351 continue;
10352 for (j = 0; j < imux->num_items; j++)
10353 if (imux->items[j].index >= err)
10354 break;
10355 if (j < imux->num_items)
10356 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010357 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10358 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010359 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010360 spec->adc_nids = spec->private_adc_nids;
10361 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010362 }
10363
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010364 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010365 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010366
Takashi Iwai2134ea42008-01-10 16:53:55 +010010367 spec->vmaster_nid = 0x0c;
10368
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010369 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010370 if (board_config == ALC882_AUTO)
10371 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010372#ifdef CONFIG_SND_HDA_POWER_SAVE
10373 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010374 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010375#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010376
10377 return 0;
10378}
10379
Takashi Iwai4953550a2009-06-30 15:28:30 +020010380
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010381/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010382 * ALC262 support
10383 */
10384
10385#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10386#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10387
10388#define alc262_dac_nids alc260_dac_nids
10389#define alc262_adc_nids alc882_adc_nids
10390#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010391#define alc262_capsrc_nids alc882_capsrc_nids
10392#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010393
10394#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010395#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010396
Kailang Yang4e555fe2008-08-26 13:05:55 +020010397static hda_nid_t alc262_dmic_adc_nids[1] = {
10398 /* ADC0 */
10399 0x09
10400};
10401
10402static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10403
Kailang Yangdf694da2005-12-05 19:42:22 +010010404static struct snd_kcontrol_new alc262_base_mixer[] = {
10405 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10406 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10407 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10408 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10409 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10410 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10412 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010413 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010414 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10415 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010416 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010417 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10418 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10419 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10420 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010421 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010422};
10423
Takashi Iwaice875f02008-01-28 18:17:43 +010010424/* update HP, line and mono-out pins according to the master switch */
10425static void alc262_hp_master_update(struct hda_codec *codec)
10426{
10427 struct alc_spec *spec = codec->spec;
10428 int val = spec->master_sw;
10429
10430 /* HP & line-out */
10431 snd_hda_codec_write_cache(codec, 0x1b, 0,
10432 AC_VERB_SET_PIN_WIDGET_CONTROL,
10433 val ? PIN_HP : 0);
10434 snd_hda_codec_write_cache(codec, 0x15, 0,
10435 AC_VERB_SET_PIN_WIDGET_CONTROL,
10436 val ? PIN_HP : 0);
10437 /* mono (speaker) depending on the HP jack sense */
10438 val = val && !spec->jack_present;
10439 snd_hda_codec_write_cache(codec, 0x16, 0,
10440 AC_VERB_SET_PIN_WIDGET_CONTROL,
10441 val ? PIN_OUT : 0);
10442}
10443
10444static void alc262_hp_bpc_automute(struct hda_codec *codec)
10445{
10446 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010447
10448 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010449 alc262_hp_master_update(codec);
10450}
10451
10452static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10453{
10454 if ((res >> 26) != ALC880_HP_EVENT)
10455 return;
10456 alc262_hp_bpc_automute(codec);
10457}
10458
10459static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10460{
10461 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010462
10463 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010464 alc262_hp_master_update(codec);
10465}
10466
10467static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10468 unsigned int res)
10469{
10470 if ((res >> 26) != ALC880_HP_EVENT)
10471 return;
10472 alc262_hp_wildwest_automute(codec);
10473}
10474
Takashi Iwaib72519b2009-05-08 14:31:55 +020010475#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010476
10477static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10478 struct snd_ctl_elem_value *ucontrol)
10479{
10480 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10481 struct alc_spec *spec = codec->spec;
10482 int val = !!*ucontrol->value.integer.value;
10483
10484 if (val == spec->master_sw)
10485 return 0;
10486 spec->master_sw = val;
10487 alc262_hp_master_update(codec);
10488 return 1;
10489}
10490
Takashi Iwaib72519b2009-05-08 14:31:55 +020010491#define ALC262_HP_MASTER_SWITCH \
10492 { \
10493 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10494 .name = "Master Playback Switch", \
10495 .info = snd_ctl_boolean_mono_info, \
10496 .get = alc262_hp_master_sw_get, \
10497 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010498 }, \
10499 { \
10500 .iface = NID_MAPPING, \
10501 .name = "Master Playback Switch", \
10502 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010503 }
10504
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010505
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010506static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010507 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010508 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10509 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10510 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010511 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10512 HDA_OUTPUT),
10513 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10514 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010515 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10516 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010517 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010518 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010520 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010521 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10522 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10523 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10524 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010525 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10526 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10527 { } /* end */
10528};
10529
Kailang Yangcd7509a2007-01-26 18:33:17 +010010530static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010531 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10533 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10534 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10535 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010536 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10537 HDA_OUTPUT),
10538 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10539 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010540 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10541 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010542 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10545 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10546 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010547 { } /* end */
10548};
10549
10550static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10551 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10552 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010553 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010554 { } /* end */
10555};
10556
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010557/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010558static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010559{
10560 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010561
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010562 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010563 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010564}
10565
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010566static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010567 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10568 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010569 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10570 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10573 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10574 { } /* end */
10575};
10576
10577static struct hda_verb alc262_hp_t5735_verbs[] = {
10578 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10579 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10580
10581 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10582 { }
10583};
10584
Kailang Yang8c427222008-01-10 13:03:59 +010010585static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010586 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010588 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10589 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010590 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10591 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10592 { } /* end */
10593};
10594
10595static struct hda_verb alc262_hp_rp5700_verbs[] = {
10596 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10597 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10598 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10599 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10600 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10601 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10603 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10605 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10606 {}
10607};
10608
10609static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10610 .num_items = 1,
10611 .items = {
10612 { "Line", 0x1 },
10613 },
10614};
10615
Takashi Iwai42171c12009-05-08 14:11:43 +020010616/* bind hp and internal speaker mute (with plug check) as master switch */
10617static void alc262_hippo_master_update(struct hda_codec *codec)
10618{
10619 struct alc_spec *spec = codec->spec;
10620 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10621 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10622 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10623 unsigned int mute;
10624
10625 /* HP */
10626 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10627 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10628 HDA_AMP_MUTE, mute);
10629 /* mute internal speaker per jack sense */
10630 if (spec->jack_present)
10631 mute = HDA_AMP_MUTE;
10632 if (line_nid)
10633 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10634 HDA_AMP_MUTE, mute);
10635 if (speaker_nid && speaker_nid != line_nid)
10636 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10637 HDA_AMP_MUTE, mute);
10638}
10639
10640#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10641
10642static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10643 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010644{
10645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010646 struct alc_spec *spec = codec->spec;
10647 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010648
Takashi Iwai42171c12009-05-08 14:11:43 +020010649 if (val == spec->master_sw)
10650 return 0;
10651 spec->master_sw = val;
10652 alc262_hippo_master_update(codec);
10653 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010654}
Takashi Iwai5b319542007-07-26 11:49:22 +020010655
Takashi Iwai42171c12009-05-08 14:11:43 +020010656#define ALC262_HIPPO_MASTER_SWITCH \
10657 { \
10658 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10659 .name = "Master Playback Switch", \
10660 .info = snd_ctl_boolean_mono_info, \
10661 .get = alc262_hippo_master_sw_get, \
10662 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010663 }, \
10664 { \
10665 .iface = NID_MAPPING, \
10666 .name = "Master Playback Switch", \
10667 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10668 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010669 }
10670
10671static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10672 ALC262_HIPPO_MASTER_SWITCH,
10673 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10674 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10675 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10676 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10677 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10678 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10679 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10680 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10681 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10682 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10683 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10684 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10685 { } /* end */
10686};
10687
10688static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10689 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10690 ALC262_HIPPO_MASTER_SWITCH,
10691 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10692 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10693 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10694 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10695 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10696 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10697 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10699 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10700 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10701 { } /* end */
10702};
10703
10704/* mute/unmute internal speaker according to the hp jack and mute state */
10705static void alc262_hippo_automute(struct hda_codec *codec)
10706{
10707 struct alc_spec *spec = codec->spec;
10708 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010709
Wu Fengguang864f92b2009-11-18 12:38:02 +080010710 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010711 alc262_hippo_master_update(codec);
10712}
10713
10714static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10715{
10716 if ((res >> 26) != ALC880_HP_EVENT)
10717 return;
10718 alc262_hippo_automute(codec);
10719}
10720
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010721static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010722{
10723 struct alc_spec *spec = codec->spec;
10724
10725 spec->autocfg.hp_pins[0] = 0x15;
10726 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010727}
10728
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010729static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010730{
10731 struct alc_spec *spec = codec->spec;
10732
10733 spec->autocfg.hp_pins[0] = 0x1b;
10734 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010735}
10736
10737
Kailang Yang272a5272007-05-14 11:00:38 +020010738static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010739 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010740 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010741 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10742 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10743 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10744 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10745 { } /* end */
10746};
10747
Kailang Yang83c34212007-07-05 11:43:05 +020010748static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010749 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10750 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10752 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10754 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10755 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10756 { } /* end */
10757};
Kailang Yang272a5272007-05-14 11:00:38 +020010758
Tony Vroonba340e82009-02-02 19:01:30 +000010759static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10760 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10761 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10762 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10763 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10764 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10765 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10766 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10767 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10768 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10769 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10770 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10771 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10772 { } /* end */
10773};
10774
10775static struct hda_verb alc262_tyan_verbs[] = {
10776 /* Headphone automute */
10777 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10778 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10780
10781 /* P11 AUX_IN, white 4-pin connector */
10782 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10783 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10784 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10785 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10786
10787 {}
10788};
10789
10790/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010791static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010792{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010793 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010794
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010795 spec->autocfg.hp_pins[0] = 0x1b;
10796 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010797}
10798
Tony Vroonba340e82009-02-02 19:01:30 +000010799
Kailang Yangdf694da2005-12-05 19:42:22 +010010800#define alc262_capture_mixer alc882_capture_mixer
10801#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10802
10803/*
10804 * generic initialization of ADC, input mixers and output mixers
10805 */
10806static struct hda_verb alc262_init_verbs[] = {
10807 /*
10808 * Unmute ADC0-2 and set the default input to mic-in
10809 */
10810 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10811 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10812 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10813 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10814 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10816
Takashi Iwaicb53c622007-08-10 17:21:45 +020010817 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010818 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010819 * Note: PASD motherboards uses the Line In 2 as the input for
10820 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010821 */
10822 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010823 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010828
10829 /*
10830 * Set up output mixers (0x0c - 0x0e)
10831 */
10832 /* set vol=0 to output mixers */
10833 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10836 /* set up input amps for analog loopback */
10837 /* Amp Indices: DAC = 0, mixer = 1 */
10838 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10840 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10842 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10844
10845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10846 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10847 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10848 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10849 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10851
10852 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10854 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10855 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10856 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010857
Kailang Yangdf694da2005-12-05 19:42:22 +010010858 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10859 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010860
Kailang Yangdf694da2005-12-05 19:42:22 +010010861 /* FIXME: use matrix-type input source selection */
10862 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10863 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10868 /* Input mixer2 */
10869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10873 /* Input mixer3 */
10874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010878
10879 { }
10880};
10881
Kailang Yang4e555fe2008-08-26 13:05:55 +020010882static struct hda_verb alc262_eapd_verbs[] = {
10883 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10884 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10885 { }
10886};
10887
Kailang Yangccc656c2006-10-17 12:32:26 +020010888static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10889 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10890 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10891 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10892
10893 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10895 {}
10896};
10897
Kailang Yang272a5272007-05-14 11:00:38 +020010898static struct hda_verb alc262_sony_unsol_verbs[] = {
10899 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10900 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10901 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10902
10903 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010905 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010906};
10907
Kailang Yang4e555fe2008-08-26 13:05:55 +020010908static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10909 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10910 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10911 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10912 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10913 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010914 { } /* end */
10915};
10916
10917static struct hda_verb alc262_toshiba_s06_verbs[] = {
10918 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10919 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10922 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10923 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10924 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10925 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10926 {}
10927};
10928
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010929static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010930{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010931 struct alc_spec *spec = codec->spec;
10932
10933 spec->autocfg.hp_pins[0] = 0x15;
10934 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010935 spec->ext_mic.pin = 0x18;
10936 spec->ext_mic.mux_idx = 0;
10937 spec->int_mic.pin = 0x12;
10938 spec->int_mic.mux_idx = 9;
10939 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010940}
10941
Takashi Iwai834be882006-03-01 14:16:17 +010010942/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010943 * nec model
10944 * 0x15 = headphone
10945 * 0x16 = internal speaker
10946 * 0x18 = external mic
10947 */
10948
10949static struct snd_kcontrol_new alc262_nec_mixer[] = {
10950 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10951 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10952
10953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10954 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10955 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10956
10957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10959 { } /* end */
10960};
10961
10962static struct hda_verb alc262_nec_verbs[] = {
10963 /* Unmute Speaker */
10964 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10965
10966 /* Headphone */
10967 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10968 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10969
10970 /* External mic to headphone */
10971 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10972 /* External mic to speaker */
10973 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10974 {}
10975};
10976
10977/*
Takashi Iwai834be882006-03-01 14:16:17 +010010978 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010979 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10980 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010981 */
10982
10983#define ALC_HP_EVENT 0x37
10984
10985static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10986 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010988 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010990 {}
10991};
10992
Jiang zhe0e31daf2008-03-20 12:12:39 +010010993static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10994 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10995 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10996 {}
10997};
10998
Daniel T Chene2595322009-12-19 18:19:02 -050010999static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11000 /* Front Mic pin: input vref at 50% */
11001 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11002 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11003 {}
11004};
11005
Takashi Iwai834be882006-03-01 14:16:17 +010011006static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011007 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011008 .items = {
11009 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011010 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011011 { "CD", 0x4 },
11012 },
11013};
11014
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011015static struct hda_input_mux alc262_HP_capture_source = {
11016 .num_items = 5,
11017 .items = {
11018 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011019 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011020 { "Line", 0x2 },
11021 { "CD", 0x4 },
11022 { "AUX IN", 0x6 },
11023 },
11024};
11025
zhejiangaccbe492007-08-31 12:36:05 +020011026static struct hda_input_mux alc262_HP_D7000_capture_source = {
11027 .num_items = 4,
11028 .items = {
11029 { "Mic", 0x0 },
11030 { "Front Mic", 0x2 },
11031 { "Line", 0x1 },
11032 { "CD", 0x4 },
11033 },
11034};
11035
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011036/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011037static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11038{
11039 struct alc_spec *spec = codec->spec;
11040 unsigned int mute;
11041
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011042 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011043 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11044 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011045 spec->sense_updated = 1;
11046 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011047 /* unmute internal speaker only if both HPs are unplugged and
11048 * master switch is on
11049 */
11050 if (spec->jack_present)
11051 mute = HDA_AMP_MUTE;
11052 else
Takashi Iwai834be882006-03-01 14:16:17 +010011053 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11055 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011056}
11057
11058/* unsolicited event for HP jack sensing */
11059static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11060 unsigned int res)
11061{
11062 if ((res >> 26) != ALC_HP_EVENT)
11063 return;
11064 alc262_fujitsu_automute(codec, 1);
11065}
11066
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011067static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11068{
11069 alc262_fujitsu_automute(codec, 1);
11070}
11071
Takashi Iwai834be882006-03-01 14:16:17 +010011072/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011073static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11074 .ops = &snd_hda_bind_vol,
11075 .values = {
11076 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11077 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11078 0
11079 },
11080};
Takashi Iwai834be882006-03-01 14:16:17 +010011081
Jiang zhe0e31daf2008-03-20 12:12:39 +010011082/* mute/unmute internal speaker according to the hp jack and mute state */
11083static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11084{
11085 struct alc_spec *spec = codec->spec;
11086 unsigned int mute;
11087
11088 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011089 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011090 spec->sense_updated = 1;
11091 }
11092 if (spec->jack_present) {
11093 /* mute internal speaker */
11094 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11095 HDA_AMP_MUTE, HDA_AMP_MUTE);
11096 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11097 HDA_AMP_MUTE, HDA_AMP_MUTE);
11098 } else {
11099 /* unmute internal speaker if necessary */
11100 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11101 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11102 HDA_AMP_MUTE, mute);
11103 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11104 HDA_AMP_MUTE, mute);
11105 }
11106}
11107
11108/* unsolicited event for HP jack sensing */
11109static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11110 unsigned int res)
11111{
11112 if ((res >> 26) != ALC_HP_EVENT)
11113 return;
11114 alc262_lenovo_3000_automute(codec, 1);
11115}
11116
Takashi Iwai8de56b72009-07-24 16:51:47 +020011117static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11118 int dir, int idx, long *valp)
11119{
11120 int i, change = 0;
11121
11122 for (i = 0; i < 2; i++, valp++)
11123 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11124 HDA_AMP_MUTE,
11125 *valp ? 0 : HDA_AMP_MUTE);
11126 return change;
11127}
11128
Takashi Iwai834be882006-03-01 14:16:17 +010011129/* bind hp and internal speaker mute (with plug check) */
11130static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11131 struct snd_ctl_elem_value *ucontrol)
11132{
11133 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11134 long *valp = ucontrol->value.integer.value;
11135 int change;
11136
Takashi Iwai8de56b72009-07-24 16:51:47 +020011137 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11138 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011139 if (change)
11140 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011141 return change;
11142}
11143
11144static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011145 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011146 {
11147 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11148 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011149 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011150 .info = snd_hda_mixer_amp_switch_info,
11151 .get = snd_hda_mixer_amp_switch_get,
11152 .put = alc262_fujitsu_master_sw_put,
11153 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11154 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011155 {
11156 .iface = NID_MAPPING,
11157 .name = "Master Playback Switch",
11158 .private_value = 0x1b,
11159 },
Takashi Iwai834be882006-03-01 14:16:17 +010011160 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11161 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11162 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011165 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11166 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11167 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011168 { } /* end */
11169};
11170
Jiang zhe0e31daf2008-03-20 12:12:39 +010011171/* bind hp and internal speaker mute (with plug check) */
11172static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11173 struct snd_ctl_elem_value *ucontrol)
11174{
11175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11176 long *valp = ucontrol->value.integer.value;
11177 int change;
11178
Takashi Iwai8de56b72009-07-24 16:51:47 +020011179 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011180 if (change)
11181 alc262_lenovo_3000_automute(codec, 0);
11182 return change;
11183}
11184
11185static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11186 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11187 {
11188 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11189 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011190 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011191 .info = snd_hda_mixer_amp_switch_info,
11192 .get = snd_hda_mixer_amp_switch_get,
11193 .put = alc262_lenovo_3000_master_sw_put,
11194 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11195 },
11196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11201 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11202 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11203 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11204 { } /* end */
11205};
11206
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011207static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11208 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011209 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011210 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11211 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11213 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11214 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11215 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11216 { } /* end */
11217};
11218
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011219/* additional init verbs for Benq laptops */
11220static struct hda_verb alc262_EAPD_verbs[] = {
11221 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11222 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11223 {}
11224};
11225
Kailang Yang83c34212007-07-05 11:43:05 +020011226static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11227 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11228 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11229
11230 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11231 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11232 {}
11233};
11234
Tobin Davisf651b502007-10-26 12:40:47 +020011235/* Samsung Q1 Ultra Vista model setup */
11236static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011237 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11238 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011239 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11240 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11241 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011242 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011243 { } /* end */
11244};
11245
11246static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011247 /* output mixer */
11248 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11251 /* speaker */
11252 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11253 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11254 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11255 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11256 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11261 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11262 /* internal mic */
11263 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11265 /* ADC, choose mic */
11266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011276 {}
11277};
11278
Tobin Davisf651b502007-10-26 12:40:47 +020011279/* mute/unmute internal speaker according to the hp jack and mute state */
11280static void alc262_ultra_automute(struct hda_codec *codec)
11281{
11282 struct alc_spec *spec = codec->spec;
11283 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011284
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011285 mute = 0;
11286 /* auto-mute only when HP is used as HP */
11287 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011288 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011289 if (spec->jack_present)
11290 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011291 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011292 /* mute/unmute internal speaker */
11293 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11294 HDA_AMP_MUTE, mute);
11295 /* mute/unmute HP */
11296 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11297 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011298}
11299
11300/* unsolicited event for HP jack sensing */
11301static void alc262_ultra_unsol_event(struct hda_codec *codec,
11302 unsigned int res)
11303{
11304 if ((res >> 26) != ALC880_HP_EVENT)
11305 return;
11306 alc262_ultra_automute(codec);
11307}
11308
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011309static struct hda_input_mux alc262_ultra_capture_source = {
11310 .num_items = 2,
11311 .items = {
11312 { "Mic", 0x1 },
11313 { "Headphone", 0x7 },
11314 },
11315};
11316
11317static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11318 struct snd_ctl_elem_value *ucontrol)
11319{
11320 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11321 struct alc_spec *spec = codec->spec;
11322 int ret;
11323
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011324 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011325 if (!ret)
11326 return 0;
11327 /* reprogram the HP pin as mic or HP according to the input source */
11328 snd_hda_codec_write_cache(codec, 0x15, 0,
11329 AC_VERB_SET_PIN_WIDGET_CONTROL,
11330 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11331 alc262_ultra_automute(codec); /* mute/unmute HP */
11332 return ret;
11333}
11334
11335static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11336 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11337 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11338 {
11339 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11340 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011341 .info = alc_mux_enum_info,
11342 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011343 .put = alc262_ultra_mux_enum_put,
11344 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011345 {
11346 .iface = NID_MAPPING,
11347 .name = "Capture Source",
11348 .private_value = 0x15,
11349 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011350 { } /* end */
11351};
11352
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011353/* We use two mixers depending on the output pin; 0x16 is a mono output
11354 * and thus it's bound with a different mixer.
11355 * This function returns which mixer amp should be used.
11356 */
11357static int alc262_check_volbit(hda_nid_t nid)
11358{
11359 if (!nid)
11360 return 0;
11361 else if (nid == 0x16)
11362 return 2;
11363 else
11364 return 1;
11365}
11366
11367static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11368 const char *pfx, int *vbits)
11369{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011370 unsigned long val;
11371 int vbit;
11372
11373 vbit = alc262_check_volbit(nid);
11374 if (!vbit)
11375 return 0;
11376 if (*vbits & vbit) /* a volume control for this mixer already there */
11377 return 0;
11378 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011379 if (vbit == 2)
11380 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11381 else
11382 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011383 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011384}
11385
11386static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11387 const char *pfx)
11388{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011389 unsigned long val;
11390
11391 if (!nid)
11392 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011393 if (nid == 0x16)
11394 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11395 else
11396 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011397 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011398}
11399
Kailang Yangdf694da2005-12-05 19:42:22 +010011400/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011401static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11402 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011403{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011404 const char *pfx;
11405 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011406 int err;
11407
11408 spec->multiout.num_dacs = 1; /* only use one dac */
11409 spec->multiout.dac_nids = spec->private_dac_nids;
11410 spec->multiout.dac_nids[0] = 2;
11411
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011412 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11413 pfx = "Master";
11414 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11415 pfx = "Speaker";
11416 else
11417 pfx = "Front";
11418 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11419 if (err < 0)
11420 return err;
11421 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11422 if (err < 0)
11423 return err;
11424 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11425 if (err < 0)
11426 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011427
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011428 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11429 alc262_check_volbit(cfg->speaker_pins[0]) |
11430 alc262_check_volbit(cfg->hp_pins[0]);
11431 if (vbits == 1 || vbits == 2)
11432 pfx = "Master"; /* only one mixer is used */
11433 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11434 pfx = "Speaker";
11435 else
11436 pfx = "Front";
11437 vbits = 0;
11438 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11439 if (err < 0)
11440 return err;
11441 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11442 &vbits);
11443 if (err < 0)
11444 return err;
11445 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11446 &vbits);
11447 if (err < 0)
11448 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011449 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011450}
11451
Takashi Iwai05f5f472009-08-25 13:10:18 +020011452#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011453 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011454
11455/*
11456 * generic initialization of ADC, input mixers and output mixers
11457 */
11458static struct hda_verb alc262_volume_init_verbs[] = {
11459 /*
11460 * Unmute ADC0-2 and set the default input to mic-in
11461 */
11462 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11464 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11465 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11466 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11467 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11468
Takashi Iwaicb53c622007-08-10 17:21:45 +020011469 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011470 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011471 * Note: PASD motherboards uses the Line In 2 as the input for
11472 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011473 */
11474 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011480
11481 /*
11482 * Set up output mixers (0x0c - 0x0f)
11483 */
11484 /* set vol=0 to output mixers */
11485 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011488
Kailang Yangdf694da2005-12-05 19:42:22 +010011489 /* set up input amps for analog loopback */
11490 /* Amp Indices: DAC = 0, mixer = 1 */
11491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11496 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11497
11498 /* FIXME: use matrix-type input source selection */
11499 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11500 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11505 /* Input mixer2 */
11506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11510 /* Input mixer3 */
11511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11515
11516 { }
11517};
11518
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011519static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11520 /*
11521 * Unmute ADC0-2 and set the default input to mic-in
11522 */
11523 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11525 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11526 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11527 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11528 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11529
Takashi Iwaicb53c622007-08-10 17:21:45 +020011530 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011531 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011532 * Note: PASD motherboards uses the Line In 2 as the input for
11533 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011534 */
11535 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011543
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011544 /*
11545 * Set up output mixers (0x0c - 0x0e)
11546 */
11547 /* set vol=0 to output mixers */
11548 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11551
11552 /* set up input amps for analog loopback */
11553 /* Amp Indices: DAC = 0, mixer = 1 */
11554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11560
Takashi Iwaice875f02008-01-28 18:17:43 +010011561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011562 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11563 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11564
11565 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11566 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11567
11568 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11569 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11570
11571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11572 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11574 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11575 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11576
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011577 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011578 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11579 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011580 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011581 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11582 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11583
11584
11585 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011586 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11587 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011597 /* Input mixer2 */
11598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011607 /* Input mixer3 */
11608 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011617
Takashi Iwaice875f02008-01-28 18:17:43 +010011618 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11619
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011620 { }
11621};
11622
Kailang Yangcd7509a2007-01-26 18:33:17 +010011623static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11624 /*
11625 * Unmute ADC0-2 and set the default input to mic-in
11626 */
11627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11633
Takashi Iwaicb53c622007-08-10 17:21:45 +020011634 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011635 * mixer widget
11636 * Note: PASD motherboards uses the Line In 2 as the input for front
11637 * panel mic (mic 2)
11638 */
11639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011648 /*
11649 * Set up output mixers (0x0c - 0x0e)
11650 */
11651 /* set vol=0 to output mixers */
11652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11655
11656 /* set up input amps for analog loopback */
11657 /* Amp Indices: DAC = 0, mixer = 1 */
11658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11664
11665
11666 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11667 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11668 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11669 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11670 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11672 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11673
11674 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11676
11677 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11678 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11679
11680 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11683 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11684 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11685 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11686
11687 /* FIXME: use matrix-type input source selection */
11688 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11689 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11690 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11695 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11696 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11697 /* Input mixer2 */
11698 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11701 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11703 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11704 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11705 /* Input mixer3 */
11706 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11711 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11712 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11713
Takashi Iwaice875f02008-01-28 18:17:43 +010011714 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11715
Kailang Yangcd7509a2007-01-26 18:33:17 +010011716 { }
11717};
11718
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011719static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11720
11721 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11722 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11723 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11724
11725 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11726 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11727 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11728 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11729
11730 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11731 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11732 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11733 {}
11734};
11735
11736
Takashi Iwaicb53c622007-08-10 17:21:45 +020011737#ifdef CONFIG_SND_HDA_POWER_SAVE
11738#define alc262_loopbacks alc880_loopbacks
11739#endif
11740
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011741/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011742#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11743#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11744#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11745#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11746
11747/*
11748 * BIOS auto configuration
11749 */
11750static int alc262_parse_auto_config(struct hda_codec *codec)
11751{
11752 struct alc_spec *spec = codec->spec;
11753 int err;
11754 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11755
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011756 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11757 alc262_ignore);
11758 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011759 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011760 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011761 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011762 spec->multiout.max_channels = 2;
11763 spec->no_analog = 1;
11764 goto dig_only;
11765 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011766 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011767 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011768 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11769 if (err < 0)
11770 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011771 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011772 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011773 return err;
11774
11775 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11776
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011777 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011778 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011779 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011780 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011781 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011782 if (spec->autocfg.dig_in_pin)
11783 spec->dig_in_nid = ALC262_DIGIN_NID;
11784
Takashi Iwai603c4012008-07-30 15:01:44 +020011785 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011786 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011787
Takashi Iwaid88897e2008-10-31 15:01:37 +010011788 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011789 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011790 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011791
Takashi Iwai776e1842007-08-29 15:07:11 +020011792 err = alc_auto_add_mic_boost(codec);
11793 if (err < 0)
11794 return err;
11795
Kailang Yang6227cdc2010-02-25 08:36:52 +010011796 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011797
Kailang Yangdf694da2005-12-05 19:42:22 +010011798 return 1;
11799}
11800
11801#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11802#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11803#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011804#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011805
11806
11807/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011808static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011809{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011810 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011811 alc262_auto_init_multi_out(codec);
11812 alc262_auto_init_hp_out(codec);
11813 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011814 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011815 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011816 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011817}
11818
11819/*
11820 * configuration and preset
11821 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011822static const char *alc262_models[ALC262_MODEL_LAST] = {
11823 [ALC262_BASIC] = "basic",
11824 [ALC262_HIPPO] = "hippo",
11825 [ALC262_HIPPO_1] = "hippo_1",
11826 [ALC262_FUJITSU] = "fujitsu",
11827 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011828 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011829 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011830 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011831 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011832 [ALC262_BENQ_T31] = "benq-t31",
11833 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011834 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011835 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011836 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011837 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011838 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011839 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011840 [ALC262_AUTO] = "auto",
11841};
11842
11843static struct snd_pci_quirk alc262_cfg_tbl[] = {
11844 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011845 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011846 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11847 ALC262_HP_BPC),
11848 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11849 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011850 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11851 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011852 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011853 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011854 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011855 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011856 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011857 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011858 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011859 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011860 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11861 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11862 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011863 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11864 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011865 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011866 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011867 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011868 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011869 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011870 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011871 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011872 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011873#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011874 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11875 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011876#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011877 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011878 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011879 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011880 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011881 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011882 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011883 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11884 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011885 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011886 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011887 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011888 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011889 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011890 {}
11891};
11892
11893static struct alc_config_preset alc262_presets[] = {
11894 [ALC262_BASIC] = {
11895 .mixers = { alc262_base_mixer },
11896 .init_verbs = { alc262_init_verbs },
11897 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11898 .dac_nids = alc262_dac_nids,
11899 .hp_nid = 0x03,
11900 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11901 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011902 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011903 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011904 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011905 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011906 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011907 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11908 .dac_nids = alc262_dac_nids,
11909 .hp_nid = 0x03,
11910 .dig_out_nid = ALC262_DIGOUT_NID,
11911 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11912 .channel_mode = alc262_modes,
11913 .input_mux = &alc262_capture_source,
11914 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011915 .setup = alc262_hippo_setup,
11916 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011917 },
11918 [ALC262_HIPPO_1] = {
11919 .mixers = { alc262_hippo1_mixer },
11920 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11921 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11922 .dac_nids = alc262_dac_nids,
11923 .hp_nid = 0x02,
11924 .dig_out_nid = ALC262_DIGOUT_NID,
11925 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11926 .channel_mode = alc262_modes,
11927 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011928 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011929 .setup = alc262_hippo1_setup,
11930 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011931 },
Takashi Iwai834be882006-03-01 14:16:17 +010011932 [ALC262_FUJITSU] = {
11933 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011934 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11935 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011936 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11937 .dac_nids = alc262_dac_nids,
11938 .hp_nid = 0x03,
11939 .dig_out_nid = ALC262_DIGOUT_NID,
11940 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11941 .channel_mode = alc262_modes,
11942 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011943 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011944 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011945 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011946 [ALC262_HP_BPC] = {
11947 .mixers = { alc262_HP_BPC_mixer },
11948 .init_verbs = { alc262_HP_BPC_init_verbs },
11949 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11950 .dac_nids = alc262_dac_nids,
11951 .hp_nid = 0x03,
11952 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11953 .channel_mode = alc262_modes,
11954 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011955 .unsol_event = alc262_hp_bpc_unsol_event,
11956 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011957 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011958 [ALC262_HP_BPC_D7000_WF] = {
11959 .mixers = { alc262_HP_BPC_WildWest_mixer },
11960 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11961 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11962 .dac_nids = alc262_dac_nids,
11963 .hp_nid = 0x03,
11964 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11965 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011966 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011967 .unsol_event = alc262_hp_wildwest_unsol_event,
11968 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011969 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011970 [ALC262_HP_BPC_D7000_WL] = {
11971 .mixers = { alc262_HP_BPC_WildWest_mixer,
11972 alc262_HP_BPC_WildWest_option_mixer },
11973 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11974 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11975 .dac_nids = alc262_dac_nids,
11976 .hp_nid = 0x03,
11977 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11978 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011979 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011980 .unsol_event = alc262_hp_wildwest_unsol_event,
11981 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011982 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011983 [ALC262_HP_TC_T5735] = {
11984 .mixers = { alc262_hp_t5735_mixer },
11985 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11986 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11987 .dac_nids = alc262_dac_nids,
11988 .hp_nid = 0x03,
11989 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11990 .channel_mode = alc262_modes,
11991 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011992 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011993 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011994 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010011995 },
11996 [ALC262_HP_RP5700] = {
11997 .mixers = { alc262_hp_rp5700_mixer },
11998 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
11999 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12000 .dac_nids = alc262_dac_nids,
12001 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12002 .channel_mode = alc262_modes,
12003 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012004 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012005 [ALC262_BENQ_ED8] = {
12006 .mixers = { alc262_base_mixer },
12007 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12008 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12009 .dac_nids = alc262_dac_nids,
12010 .hp_nid = 0x03,
12011 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12012 .channel_mode = alc262_modes,
12013 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012014 },
Kailang Yang272a5272007-05-14 11:00:38 +020012015 [ALC262_SONY_ASSAMD] = {
12016 .mixers = { alc262_sony_mixer },
12017 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12018 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12019 .dac_nids = alc262_dac_nids,
12020 .hp_nid = 0x02,
12021 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12022 .channel_mode = alc262_modes,
12023 .input_mux = &alc262_capture_source,
12024 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012025 .setup = alc262_hippo_setup,
12026 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012027 },
12028 [ALC262_BENQ_T31] = {
12029 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012030 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12031 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012032 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12033 .dac_nids = alc262_dac_nids,
12034 .hp_nid = 0x03,
12035 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12036 .channel_mode = alc262_modes,
12037 .input_mux = &alc262_capture_source,
12038 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012039 .setup = alc262_hippo_setup,
12040 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012041 },
Tobin Davisf651b502007-10-26 12:40:47 +020012042 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012043 .mixers = { alc262_ultra_mixer },
12044 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012045 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12047 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012048 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12049 .channel_mode = alc262_modes,
12050 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012051 .adc_nids = alc262_adc_nids, /* ADC0 */
12052 .capsrc_nids = alc262_capsrc_nids,
12053 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012054 .unsol_event = alc262_ultra_unsol_event,
12055 .init_hook = alc262_ultra_automute,
12056 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012057 [ALC262_LENOVO_3000] = {
12058 .mixers = { alc262_lenovo_3000_mixer },
12059 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012060 alc262_lenovo_3000_unsol_verbs,
12061 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012062 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12063 .dac_nids = alc262_dac_nids,
12064 .hp_nid = 0x03,
12065 .dig_out_nid = ALC262_DIGOUT_NID,
12066 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12067 .channel_mode = alc262_modes,
12068 .input_mux = &alc262_fujitsu_capture_source,
12069 .unsol_event = alc262_lenovo_3000_unsol_event,
12070 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012071 [ALC262_NEC] = {
12072 .mixers = { alc262_nec_mixer },
12073 .init_verbs = { alc262_nec_verbs },
12074 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12075 .dac_nids = alc262_dac_nids,
12076 .hp_nid = 0x03,
12077 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12078 .channel_mode = alc262_modes,
12079 .input_mux = &alc262_capture_source,
12080 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012081 [ALC262_TOSHIBA_S06] = {
12082 .mixers = { alc262_toshiba_s06_mixer },
12083 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12084 alc262_eapd_verbs },
12085 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12086 .capsrc_nids = alc262_dmic_capsrc_nids,
12087 .dac_nids = alc262_dac_nids,
12088 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012089 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012090 .dig_out_nid = ALC262_DIGOUT_NID,
12091 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12092 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012093 .unsol_event = alc_sku_unsol_event,
12094 .setup = alc262_toshiba_s06_setup,
12095 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012096 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012097 [ALC262_TOSHIBA_RX1] = {
12098 .mixers = { alc262_toshiba_rx1_mixer },
12099 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12100 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12101 .dac_nids = alc262_dac_nids,
12102 .hp_nid = 0x03,
12103 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12104 .channel_mode = alc262_modes,
12105 .input_mux = &alc262_capture_source,
12106 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012107 .setup = alc262_hippo_setup,
12108 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012109 },
Tony Vroonba340e82009-02-02 19:01:30 +000012110 [ALC262_TYAN] = {
12111 .mixers = { alc262_tyan_mixer },
12112 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12113 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12114 .dac_nids = alc262_dac_nids,
12115 .hp_nid = 0x02,
12116 .dig_out_nid = ALC262_DIGOUT_NID,
12117 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12118 .channel_mode = alc262_modes,
12119 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012120 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012121 .setup = alc262_tyan_setup,
12122 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012123 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012124};
12125
12126static int patch_alc262(struct hda_codec *codec)
12127{
12128 struct alc_spec *spec;
12129 int board_config;
12130 int err;
12131
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012132 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012133 if (spec == NULL)
12134 return -ENOMEM;
12135
12136 codec->spec = spec;
12137#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012138 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12139 * under-run
12140 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012141 {
12142 int tmp;
12143 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12144 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12145 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12146 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12147 }
12148#endif
12149
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012150 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12151
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012152 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12153 alc262_models,
12154 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012155
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012156 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012157 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12158 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012159 board_config = ALC262_AUTO;
12160 }
12161
12162 if (board_config == ALC262_AUTO) {
12163 /* automatic parse from the BIOS config */
12164 err = alc262_parse_auto_config(codec);
12165 if (err < 0) {
12166 alc_free(codec);
12167 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012168 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012169 printk(KERN_INFO
12170 "hda_codec: Cannot set up configuration "
12171 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012172 board_config = ALC262_BASIC;
12173 }
12174 }
12175
Takashi Iwai07eba612009-02-19 08:06:35 +010012176 if (!spec->no_analog) {
12177 err = snd_hda_attach_beep_device(codec, 0x1);
12178 if (err < 0) {
12179 alc_free(codec);
12180 return err;
12181 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012182 }
12183
Kailang Yangdf694da2005-12-05 19:42:22 +010012184 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012185 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012186
Kailang Yangdf694da2005-12-05 19:42:22 +010012187 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12188 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012189
Kailang Yangdf694da2005-12-05 19:42:22 +010012190 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12191 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12192
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012193 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012194 int i;
12195 /* check whether the digital-mic has to be supported */
12196 for (i = 0; i < spec->input_mux->num_items; i++) {
12197 if (spec->input_mux->items[i].index >= 9)
12198 break;
12199 }
12200 if (i < spec->input_mux->num_items) {
12201 /* use only ADC0 */
12202 spec->adc_nids = alc262_dmic_adc_nids;
12203 spec->num_adc_nids = 1;
12204 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012205 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012206 /* all analog inputs */
12207 /* check whether NID 0x07 is valid */
12208 unsigned int wcap = get_wcaps(codec, 0x07);
12209
12210 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012211 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012212 if (wcap != AC_WID_AUD_IN) {
12213 spec->adc_nids = alc262_adc_nids_alt;
12214 spec->num_adc_nids =
12215 ARRAY_SIZE(alc262_adc_nids_alt);
12216 spec->capsrc_nids = alc262_capsrc_nids_alt;
12217 } else {
12218 spec->adc_nids = alc262_adc_nids;
12219 spec->num_adc_nids =
12220 ARRAY_SIZE(alc262_adc_nids);
12221 spec->capsrc_nids = alc262_capsrc_nids;
12222 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012223 }
12224 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012225 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012226 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012227 if (!spec->no_analog)
12228 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012229
Takashi Iwai2134ea42008-01-10 16:53:55 +010012230 spec->vmaster_nid = 0x0c;
12231
Kailang Yangdf694da2005-12-05 19:42:22 +010012232 codec->patch_ops = alc_patch_ops;
12233 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012234 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012235#ifdef CONFIG_SND_HDA_POWER_SAVE
12236 if (!spec->loopback.amplist)
12237 spec->loopback.amplist = alc262_loopbacks;
12238#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012239
Kailang Yangdf694da2005-12-05 19:42:22 +010012240 return 0;
12241}
12242
Kailang Yangdf694da2005-12-05 19:42:22 +010012243/*
Kailang Yanga361d842007-06-05 12:30:55 +020012244 * ALC268 channel source setting (2 channel)
12245 */
12246#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12247#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012248
Kailang Yanga361d842007-06-05 12:30:55 +020012249static hda_nid_t alc268_dac_nids[2] = {
12250 /* front, hp */
12251 0x02, 0x03
12252};
12253
12254static hda_nid_t alc268_adc_nids[2] = {
12255 /* ADC0-1 */
12256 0x08, 0x07
12257};
12258
12259static hda_nid_t alc268_adc_nids_alt[1] = {
12260 /* ADC0 */
12261 0x08
12262};
12263
Takashi Iwaie1406342008-02-11 18:32:32 +010012264static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12265
Kailang Yanga361d842007-06-05 12:30:55 +020012266static struct snd_kcontrol_new alc268_base_mixer[] = {
12267 /* output mixer control */
12268 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12269 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12273 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012275 { }
12276};
12277
Takashi Iwai42171c12009-05-08 14:11:43 +020012278static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12279 /* output mixer control */
12280 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12281 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12282 ALC262_HIPPO_MASTER_SWITCH,
12283 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12284 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12285 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12286 { }
12287};
12288
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012289/* bind Beep switches of both NID 0x0f and 0x10 */
12290static struct hda_bind_ctls alc268_bind_beep_sw = {
12291 .ops = &snd_hda_bind_sw,
12292 .values = {
12293 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12294 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12295 0
12296 },
12297};
12298
12299static struct snd_kcontrol_new alc268_beep_mixer[] = {
12300 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12301 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12302 { }
12303};
12304
Kailang Yangd1a991a2007-08-15 16:21:59 +020012305static struct hda_verb alc268_eapd_verbs[] = {
12306 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12307 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12308 { }
12309};
12310
Takashi Iwaid2738092007-08-16 14:59:45 +020012311/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012312static struct hda_verb alc268_toshiba_verbs[] = {
12313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12314 { } /* end */
12315};
12316
12317/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012318/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012319static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12320 .ops = &snd_hda_bind_vol,
12321 .values = {
12322 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12323 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12324 0
12325 },
12326};
12327
Takashi Iwai889c4392007-08-23 18:56:52 +020012328/* mute/unmute internal speaker according to the hp jack and mute state */
12329static void alc268_acer_automute(struct hda_codec *codec, int force)
12330{
12331 struct alc_spec *spec = codec->spec;
12332 unsigned int mute;
12333
12334 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012335 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012336 spec->sense_updated = 1;
12337 }
12338 if (spec->jack_present)
12339 mute = HDA_AMP_MUTE; /* mute internal speaker */
12340 else /* unmute internal speaker if necessary */
12341 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12342 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12343 HDA_AMP_MUTE, mute);
12344}
12345
12346
12347/* bind hp and internal speaker mute (with plug check) */
12348static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12349 struct snd_ctl_elem_value *ucontrol)
12350{
12351 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12352 long *valp = ucontrol->value.integer.value;
12353 int change;
12354
Takashi Iwai8de56b72009-07-24 16:51:47 +020012355 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012356 if (change)
12357 alc268_acer_automute(codec, 0);
12358 return change;
12359}
Takashi Iwaid2738092007-08-16 14:59:45 +020012360
Kailang Yang8ef355d2008-08-26 13:10:22 +020012361static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12362 /* output mixer control */
12363 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12364 {
12365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12366 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012367 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012368 .info = snd_hda_mixer_amp_switch_info,
12369 .get = snd_hda_mixer_amp_switch_get,
12370 .put = alc268_acer_master_sw_put,
12371 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12372 },
12373 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12374 { }
12375};
12376
Takashi Iwaid2738092007-08-16 14:59:45 +020012377static struct snd_kcontrol_new alc268_acer_mixer[] = {
12378 /* output mixer control */
12379 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12380 {
12381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12382 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012383 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012384 .info = snd_hda_mixer_amp_switch_info,
12385 .get = snd_hda_mixer_amp_switch_get,
12386 .put = alc268_acer_master_sw_put,
12387 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12388 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012389 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12390 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12391 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012392 { }
12393};
12394
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012395static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12396 /* output mixer control */
12397 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12398 {
12399 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12400 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012401 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012402 .info = snd_hda_mixer_amp_switch_info,
12403 .get = snd_hda_mixer_amp_switch_get,
12404 .put = alc268_acer_master_sw_put,
12405 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12406 },
12407 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12408 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12409 { }
12410};
12411
Kailang Yang8ef355d2008-08-26 13:10:22 +020012412static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12413 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12415 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12416 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12417 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12419 { }
12420};
12421
Takashi Iwaid2738092007-08-16 14:59:45 +020012422static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012423 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12424 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12426 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012427 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012429 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12430 { }
12431};
12432
12433/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012434#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012435#define alc268_toshiba_setup alc262_hippo_setup
12436#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012437
12438static void alc268_acer_unsol_event(struct hda_codec *codec,
12439 unsigned int res)
12440{
Takashi Iwai889c4392007-08-23 18:56:52 +020012441 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012442 return;
12443 alc268_acer_automute(codec, 1);
12444}
12445
Takashi Iwai889c4392007-08-23 18:56:52 +020012446static void alc268_acer_init_hook(struct hda_codec *codec)
12447{
12448 alc268_acer_automute(codec, 1);
12449}
12450
Kailang Yang8ef355d2008-08-26 13:10:22 +020012451/* toggle speaker-output according to the hp-jack state */
12452static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12453{
12454 unsigned int present;
12455 unsigned char bits;
12456
Wu Fengguang864f92b2009-11-18 12:38:02 +080012457 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012458 bits = present ? AMP_IN_MUTE(0) : 0;
12459 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12460 AMP_IN_MUTE(0), bits);
12461 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12462 AMP_IN_MUTE(0), bits);
12463}
12464
Kailang Yang8ef355d2008-08-26 13:10:22 +020012465static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12466 unsigned int res)
12467{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012468 switch (res >> 26) {
12469 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012470 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012471 break;
12472 case ALC880_MIC_EVENT:
12473 alc_mic_automute(codec);
12474 break;
12475 }
12476}
12477
12478static void alc268_acer_lc_setup(struct hda_codec *codec)
12479{
12480 struct alc_spec *spec = codec->spec;
12481 spec->ext_mic.pin = 0x18;
12482 spec->ext_mic.mux_idx = 0;
12483 spec->int_mic.pin = 0x12;
12484 spec->int_mic.mux_idx = 6;
12485 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012486}
12487
12488static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12489{
12490 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012491 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012492}
12493
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012494static struct snd_kcontrol_new alc268_dell_mixer[] = {
12495 /* output mixer control */
12496 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12497 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12498 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12499 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12500 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12501 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12502 { }
12503};
12504
12505static struct hda_verb alc268_dell_verbs[] = {
12506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12507 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12508 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012509 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012510 { }
12511};
12512
12513/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012514static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012515{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012516 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012517
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012518 spec->autocfg.hp_pins[0] = 0x15;
12519 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012520 spec->ext_mic.pin = 0x18;
12521 spec->ext_mic.mux_idx = 0;
12522 spec->int_mic.pin = 0x19;
12523 spec->int_mic.mux_idx = 1;
12524 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012525}
12526
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012527static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12528 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12529 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12532 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12533 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12534 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12535 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12536 { }
12537};
12538
12539static struct hda_verb alc267_quanta_il1_verbs[] = {
12540 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12541 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12542 { }
12543};
12544
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012545static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012546{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012547 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012548 spec->autocfg.hp_pins[0] = 0x15;
12549 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012550 spec->ext_mic.pin = 0x18;
12551 spec->ext_mic.mux_idx = 0;
12552 spec->int_mic.pin = 0x19;
12553 spec->int_mic.mux_idx = 1;
12554 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012555}
12556
Kailang Yanga361d842007-06-05 12:30:55 +020012557/*
12558 * generic initialization of ADC, input mixers and output mixers
12559 */
12560static struct hda_verb alc268_base_init_verbs[] = {
12561 /* Unmute DAC0-1 and set vol = 0 */
12562 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012563 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012564
12565 /*
12566 * Set up output mixers (0x0c - 0x0e)
12567 */
12568 /* set vol=0 to output mixers */
12569 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012570 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12571
12572 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12573 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12574
12575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12577 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12578 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12579 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12580 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12581 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12582 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12583
12584 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12585 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12586 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012589
12590 /* set PCBEEP vol = 0, mute connections */
12591 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12592 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12593 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012594
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012595 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012596
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012597 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12599 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12600 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012601
Kailang Yanga361d842007-06-05 12:30:55 +020012602 { }
12603};
12604
12605/*
12606 * generic initialization of ADC, input mixers and output mixers
12607 */
12608static struct hda_verb alc268_volume_init_verbs[] = {
12609 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012610 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12611 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012612
12613 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12614 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12616 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12617 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12618
Kailang Yanga361d842007-06-05 12:30:55 +020012619 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012620 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12621 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12622
12623 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012624 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012625
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012626 /* set PCBEEP vol = 0, mute connections */
12627 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12628 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12629 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012630
12631 { }
12632};
12633
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012634static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12635 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12636 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12637 { } /* end */
12638};
12639
Kailang Yanga361d842007-06-05 12:30:55 +020012640static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12641 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12642 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012643 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012644 { } /* end */
12645};
12646
12647static struct snd_kcontrol_new alc268_capture_mixer[] = {
12648 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12649 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12650 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12651 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012652 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012653 { } /* end */
12654};
12655
12656static struct hda_input_mux alc268_capture_source = {
12657 .num_items = 4,
12658 .items = {
12659 { "Mic", 0x0 },
12660 { "Front Mic", 0x1 },
12661 { "Line", 0x2 },
12662 { "CD", 0x3 },
12663 },
12664};
12665
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012666static struct hda_input_mux alc268_acer_capture_source = {
12667 .num_items = 3,
12668 .items = {
12669 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012670 { "Internal Mic", 0x1 },
12671 { "Line", 0x2 },
12672 },
12673};
12674
12675static struct hda_input_mux alc268_acer_dmic_capture_source = {
12676 .num_items = 3,
12677 .items = {
12678 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012679 { "Internal Mic", 0x6 },
12680 { "Line", 0x2 },
12681 },
12682};
12683
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012684#ifdef CONFIG_SND_DEBUG
12685static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012686 /* Volume widgets */
12687 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12688 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12689 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12690 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12691 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12692 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12693 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12694 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12695 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12696 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12697 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12698 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12699 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012700 /* The below appears problematic on some hardwares */
12701 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012702 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12703 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12704 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12705 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12706
12707 /* Modes for retasking pin widgets */
12708 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12709 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12710 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12711 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12712
12713 /* Controls for GPIO pins, assuming they are configured as outputs */
12714 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12715 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12716 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12717 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12718
12719 /* Switches to allow the digital SPDIF output pin to be enabled.
12720 * The ALC268 does not have an SPDIF input.
12721 */
12722 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12723
12724 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12725 * this output to turn on an external amplifier.
12726 */
12727 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12728 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12729
12730 { } /* end */
12731};
12732#endif
12733
Kailang Yanga361d842007-06-05 12:30:55 +020012734/* create input playback/capture controls for the given pin */
12735static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12736 const char *ctlname, int idx)
12737{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012738 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012739 int err;
12740
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012741 switch (nid) {
12742 case 0x14:
12743 case 0x16:
12744 dac = 0x02;
12745 break;
12746 case 0x15:
12747 dac = 0x03;
12748 break;
12749 default:
12750 return 0;
12751 }
12752 if (spec->multiout.dac_nids[0] != dac &&
12753 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012754 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012755 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012756 HDA_OUTPUT));
12757 if (err < 0)
12758 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012759 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12760 }
12761
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012762 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012763 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012764 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012765 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012766 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012767 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012768 if (err < 0)
12769 return err;
12770 return 0;
12771}
12772
12773/* add playback controls from the parsed DAC table */
12774static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12775 const struct auto_pin_cfg *cfg)
12776{
12777 hda_nid_t nid;
12778 int err;
12779
Kailang Yanga361d842007-06-05 12:30:55 +020012780 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012781
12782 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012783 if (nid) {
12784 const char *name;
12785 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12786 name = "Speaker";
12787 else
12788 name = "Front";
12789 err = alc268_new_analog_output(spec, nid, name, 0);
12790 if (err < 0)
12791 return err;
12792 }
Kailang Yanga361d842007-06-05 12:30:55 +020012793
12794 nid = cfg->speaker_pins[0];
12795 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012796 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012797 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12798 if (err < 0)
12799 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012800 } else {
12801 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12802 if (err < 0)
12803 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012804 }
12805 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012806 if (nid) {
12807 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12808 if (err < 0)
12809 return err;
12810 }
Kailang Yanga361d842007-06-05 12:30:55 +020012811
12812 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12813 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012814 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012815 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012816 if (err < 0)
12817 return err;
12818 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012819 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012820}
12821
12822/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012823static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012824 const struct auto_pin_cfg *cfg)
12825{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012826 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012827}
12828
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012829static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12830 hda_nid_t nid, int pin_type)
12831{
12832 int idx;
12833
12834 alc_set_pin_output(codec, nid, pin_type);
12835 if (nid == 0x14 || nid == 0x16)
12836 idx = 0;
12837 else
12838 idx = 1;
12839 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12840}
12841
12842static void alc268_auto_init_multi_out(struct hda_codec *codec)
12843{
12844 struct alc_spec *spec = codec->spec;
12845 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12846 if (nid) {
12847 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12848 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12849 }
12850}
12851
12852static void alc268_auto_init_hp_out(struct hda_codec *codec)
12853{
12854 struct alc_spec *spec = codec->spec;
12855 hda_nid_t pin;
12856
12857 pin = spec->autocfg.hp_pins[0];
12858 if (pin)
12859 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12860 pin = spec->autocfg.speaker_pins[0];
12861 if (pin)
12862 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12863}
12864
Kailang Yanga361d842007-06-05 12:30:55 +020012865static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12866{
12867 struct alc_spec *spec = codec->spec;
12868 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12869 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12870 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12871 unsigned int dac_vol1, dac_vol2;
12872
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012873 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012874 snd_hda_codec_write(codec, speaker_nid, 0,
12875 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012876 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012877 snd_hda_codec_write(codec, 0x0f, 0,
12878 AC_VERB_SET_AMP_GAIN_MUTE,
12879 AMP_IN_UNMUTE(1));
12880 snd_hda_codec_write(codec, 0x10, 0,
12881 AC_VERB_SET_AMP_GAIN_MUTE,
12882 AMP_IN_UNMUTE(1));
12883 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012884 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012885 snd_hda_codec_write(codec, 0x0f, 0,
12886 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12887 snd_hda_codec_write(codec, 0x10, 0,
12888 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12889 }
12890
12891 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012892 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012893 dac_vol2 = AMP_OUT_ZERO;
12894 else if (line_nid == 0x15)
12895 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012896 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012897 dac_vol2 = AMP_OUT_ZERO;
12898 else if (hp_nid == 0x15)
12899 dac_vol1 = AMP_OUT_ZERO;
12900 if (line_nid != 0x16 || hp_nid != 0x16 ||
12901 spec->autocfg.line_out_pins[1] != 0x16 ||
12902 spec->autocfg.line_out_pins[2] != 0x16)
12903 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12904
12905 snd_hda_codec_write(codec, 0x02, 0,
12906 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12907 snd_hda_codec_write(codec, 0x03, 0,
12908 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12909}
12910
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012911/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012912#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12913#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012914#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012915#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12916
12917/*
12918 * BIOS auto configuration
12919 */
12920static int alc268_parse_auto_config(struct hda_codec *codec)
12921{
12922 struct alc_spec *spec = codec->spec;
12923 int err;
12924 static hda_nid_t alc268_ignore[] = { 0 };
12925
12926 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12927 alc268_ignore);
12928 if (err < 0)
12929 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012930 if (!spec->autocfg.line_outs) {
12931 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12932 spec->multiout.max_channels = 2;
12933 spec->no_analog = 1;
12934 goto dig_only;
12935 }
Kailang Yanga361d842007-06-05 12:30:55 +020012936 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012937 }
Kailang Yanga361d842007-06-05 12:30:55 +020012938 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12939 if (err < 0)
12940 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012941 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012942 if (err < 0)
12943 return err;
12944
12945 spec->multiout.max_channels = 2;
12946
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012947 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012948 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012949 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012950 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012951 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12952 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012953 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012954 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012955
Takashi Iwai892981f2009-03-02 08:04:35 +010012956 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012957 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012958
Takashi Iwaid88897e2008-10-31 15:01:37 +010012959 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012960 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012961 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012962
Takashi Iwai776e1842007-08-29 15:07:11 +020012963 err = alc_auto_add_mic_boost(codec);
12964 if (err < 0)
12965 return err;
12966
Kailang Yang6227cdc2010-02-25 08:36:52 +010012967 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012968
Kailang Yanga361d842007-06-05 12:30:55 +020012969 return 1;
12970}
12971
Kailang Yanga361d842007-06-05 12:30:55 +020012972#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12973
12974/* init callback for auto-configuration model -- overriding the default init */
12975static void alc268_auto_init(struct hda_codec *codec)
12976{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012977 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012978 alc268_auto_init_multi_out(codec);
12979 alc268_auto_init_hp_out(codec);
12980 alc268_auto_init_mono_speaker_out(codec);
12981 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012982 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012983 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012984}
12985
12986/*
12987 * configuration and preset
12988 */
12989static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012990 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012991 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012992 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012993 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012994 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012995 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012996 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012997 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012998#ifdef CONFIG_SND_DEBUG
12999 [ALC268_TEST] = "test",
13000#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013001 [ALC268_AUTO] = "auto",
13002};
13003
13004static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013005 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013006 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013007 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013008 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013009 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013010 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13011 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013012 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013013 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13014 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013015 /* almost compatible with toshiba but with optional digital outs;
13016 * auto-probing seems working fine
13017 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013018 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013019 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013020 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013021 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013022 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013023 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013024 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013025 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013026 {}
13027};
13028
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013029/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13030static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13031 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13032 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13033 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13034 ALC268_TOSHIBA),
13035 {}
13036};
13037
Kailang Yanga361d842007-06-05 12:30:55 +020013038static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013039 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013040 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13041 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013042 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13043 alc267_quanta_il1_verbs },
13044 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13045 .dac_nids = alc268_dac_nids,
13046 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13047 .adc_nids = alc268_adc_nids_alt,
13048 .hp_nid = 0x03,
13049 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13050 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013051 .unsol_event = alc_sku_unsol_event,
13052 .setup = alc267_quanta_il1_setup,
13053 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013054 },
Kailang Yanga361d842007-06-05 12:30:55 +020013055 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013056 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13057 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013058 .init_verbs = { alc268_base_init_verbs },
13059 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13060 .dac_nids = alc268_dac_nids,
13061 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13062 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013063 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013064 .hp_nid = 0x03,
13065 .dig_out_nid = ALC268_DIGOUT_NID,
13066 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13067 .channel_mode = alc268_modes,
13068 .input_mux = &alc268_capture_source,
13069 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013070 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013071 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013072 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013073 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13074 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013075 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13076 .dac_nids = alc268_dac_nids,
13077 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13078 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013079 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013080 .hp_nid = 0x03,
13081 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13082 .channel_mode = alc268_modes,
13083 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013084 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013085 .setup = alc268_toshiba_setup,
13086 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013087 },
13088 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013089 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013090 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013091 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13092 alc268_acer_verbs },
13093 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13094 .dac_nids = alc268_dac_nids,
13095 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13096 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013097 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013098 .hp_nid = 0x02,
13099 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13100 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013101 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013102 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013103 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013104 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013105 [ALC268_ACER_DMIC] = {
13106 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13107 alc268_beep_mixer },
13108 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13109 alc268_acer_verbs },
13110 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13111 .dac_nids = alc268_dac_nids,
13112 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13113 .adc_nids = alc268_adc_nids_alt,
13114 .capsrc_nids = alc268_capsrc_nids,
13115 .hp_nid = 0x02,
13116 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13117 .channel_mode = alc268_modes,
13118 .input_mux = &alc268_acer_dmic_capture_source,
13119 .unsol_event = alc268_acer_unsol_event,
13120 .init_hook = alc268_acer_init_hook,
13121 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013122 [ALC268_ACER_ASPIRE_ONE] = {
13123 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013124 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013125 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013126 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13127 alc268_acer_aspire_one_verbs },
13128 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13129 .dac_nids = alc268_dac_nids,
13130 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13131 .adc_nids = alc268_adc_nids_alt,
13132 .capsrc_nids = alc268_capsrc_nids,
13133 .hp_nid = 0x03,
13134 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13135 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013136 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013137 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013138 .init_hook = alc268_acer_lc_init_hook,
13139 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013140 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013141 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13142 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013143 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13144 alc268_dell_verbs },
13145 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13146 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013147 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13148 .adc_nids = alc268_adc_nids_alt,
13149 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013150 .hp_nid = 0x02,
13151 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13152 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013153 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013154 .setup = alc268_dell_setup,
13155 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013156 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013157 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013158 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13159 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013160 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13161 alc268_toshiba_verbs },
13162 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13163 .dac_nids = alc268_dac_nids,
13164 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13165 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013166 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013167 .hp_nid = 0x03,
13168 .dig_out_nid = ALC268_DIGOUT_NID,
13169 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13170 .channel_mode = alc268_modes,
13171 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013172 .setup = alc268_toshiba_setup,
13173 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013174 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013175#ifdef CONFIG_SND_DEBUG
13176 [ALC268_TEST] = {
13177 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13178 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13179 alc268_volume_init_verbs },
13180 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13181 .dac_nids = alc268_dac_nids,
13182 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13183 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013184 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013185 .hp_nid = 0x03,
13186 .dig_out_nid = ALC268_DIGOUT_NID,
13187 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13188 .channel_mode = alc268_modes,
13189 .input_mux = &alc268_capture_source,
13190 },
13191#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013192};
13193
13194static int patch_alc268(struct hda_codec *codec)
13195{
13196 struct alc_spec *spec;
13197 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013198 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013199
Julia Lawallef86f582009-12-19 08:18:03 +010013200 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013201 if (spec == NULL)
13202 return -ENOMEM;
13203
13204 codec->spec = spec;
13205
13206 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13207 alc268_models,
13208 alc268_cfg_tbl);
13209
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013210 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13211 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013212 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013213
Kailang Yanga361d842007-06-05 12:30:55 +020013214 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013215 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13216 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013217 board_config = ALC268_AUTO;
13218 }
13219
13220 if (board_config == ALC268_AUTO) {
13221 /* automatic parse from the BIOS config */
13222 err = alc268_parse_auto_config(codec);
13223 if (err < 0) {
13224 alc_free(codec);
13225 return err;
13226 } else if (!err) {
13227 printk(KERN_INFO
13228 "hda_codec: Cannot set up configuration "
13229 "from BIOS. Using base mode...\n");
13230 board_config = ALC268_3ST;
13231 }
13232 }
13233
13234 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013235 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013236
Kailang Yanga361d842007-06-05 12:30:55 +020013237 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13238 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013239 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013240
Kailang Yanga361d842007-06-05 12:30:55 +020013241 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13242
Takashi Iwai22971e32009-02-10 11:56:44 +010013243 has_beep = 0;
13244 for (i = 0; i < spec->num_mixers; i++) {
13245 if (spec->mixers[i] == alc268_beep_mixer) {
13246 has_beep = 1;
13247 break;
13248 }
13249 }
13250
13251 if (has_beep) {
13252 err = snd_hda_attach_beep_device(codec, 0x1);
13253 if (err < 0) {
13254 alc_free(codec);
13255 return err;
13256 }
13257 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13258 /* override the amp caps for beep generator */
13259 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013260 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13261 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13262 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13263 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013264 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013265
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013266 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013267 /* check whether NID 0x07 is valid */
13268 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013269 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013270
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013271 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013272 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013273 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013274 if (spec->auto_mic ||
13275 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013276 spec->adc_nids = alc268_adc_nids_alt;
13277 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013278 if (spec->auto_mic)
13279 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013280 if (spec->auto_mic || spec->input_mux->num_items == 1)
13281 add_mixer(spec, alc268_capture_nosrc_mixer);
13282 else
13283 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013284 } else {
13285 spec->adc_nids = alc268_adc_nids;
13286 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013287 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013288 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013289 /* set default input source */
13290 for (i = 0; i < spec->num_adc_nids; i++)
13291 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13292 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013293 i < spec->num_mux_defs ?
13294 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013295 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013296 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013297
13298 spec->vmaster_nid = 0x02;
13299
Kailang Yanga361d842007-06-05 12:30:55 +020013300 codec->patch_ops = alc_patch_ops;
13301 if (board_config == ALC268_AUTO)
13302 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013303
Kailang Yanga361d842007-06-05 12:30:55 +020013304 return 0;
13305}
13306
13307/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013308 * ALC269 channel source setting (2 channel)
13309 */
13310#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13311
13312#define alc269_dac_nids alc260_dac_nids
13313
13314static hda_nid_t alc269_adc_nids[1] = {
13315 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013316 0x08,
13317};
13318
Takashi Iwaie01bf502008-08-21 16:25:07 +020013319static hda_nid_t alc269_capsrc_nids[1] = {
13320 0x23,
13321};
13322
Kailang Yang84898e82010-02-04 14:16:14 +010013323static hda_nid_t alc269vb_adc_nids[1] = {
13324 /* ADC1 */
13325 0x09,
13326};
13327
13328static hda_nid_t alc269vb_capsrc_nids[1] = {
13329 0x22,
13330};
13331
Takashi Iwaie01bf502008-08-21 16:25:07 +020013332/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13333 * not a mux!
13334 */
13335
Kailang Yangf6a92242007-12-13 16:52:54 +010013336#define alc269_modes alc260_modes
13337#define alc269_capture_source alc880_lg_lw_capture_source
13338
13339static struct snd_kcontrol_new alc269_base_mixer[] = {
13340 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13341 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13342 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13343 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13346 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13349 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13350 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13351 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13352 { } /* end */
13353};
13354
Kailang Yang60db6b52008-08-26 13:13:00 +020013355static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13356 /* output mixer control */
13357 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13358 {
13359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13360 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013361 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013362 .info = snd_hda_mixer_amp_switch_info,
13363 .get = snd_hda_mixer_amp_switch_get,
13364 .put = alc268_acer_master_sw_put,
13365 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13366 },
13367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13370 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13371 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13372 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013373 { }
13374};
13375
Tony Vroon64154832008-11-06 15:08:49 +000013376static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13377 /* output mixer control */
13378 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13379 {
13380 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13381 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013382 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013383 .info = snd_hda_mixer_amp_switch_info,
13384 .get = snd_hda_mixer_amp_switch_get,
13385 .put = alc268_acer_master_sw_put,
13386 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13387 },
13388 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13390 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13391 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13392 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13393 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13394 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13395 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13396 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013397 { }
13398};
13399
Kailang Yang84898e82010-02-04 14:16:14 +010013400static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013401 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013402 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013404 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013405 { } /* end */
13406};
13407
Kailang Yang84898e82010-02-04 14:16:14 +010013408static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13409 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13410 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13411 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13412 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13413 { } /* end */
13414};
13415
Kailang Yangf6a92242007-12-13 16:52:54 +010013416/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013417static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13418 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13419 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13420 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13421 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13422 { } /* end */
13423};
13424
13425static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013426 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13427 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013428 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13429 { } /* end */
13430};
13431
Kailang Yang84898e82010-02-04 14:16:14 +010013432static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13433 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13434 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13435 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13436 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13437 { } /* end */
13438};
13439
13440static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13441 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13442 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13443 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13444 { } /* end */
13445};
13446
Takashi Iwai26f5df22008-11-03 17:39:46 +010013447/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013448#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013449
Kailang Yang60db6b52008-08-26 13:13:00 +020013450static struct hda_verb alc269_quanta_fl1_verbs[] = {
13451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13452 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13455 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13456 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13457 { }
13458};
13459
Tony Vroon64154832008-11-06 15:08:49 +000013460static struct hda_verb alc269_lifebook_verbs[] = {
13461 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13462 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13463 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13464 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13465 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13466 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13468 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13469 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13470 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13471 { }
13472};
13473
Kailang Yang60db6b52008-08-26 13:13:00 +020013474/* toggle speaker-output according to the hp-jack state */
13475static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13476{
13477 unsigned int present;
13478 unsigned char bits;
13479
Wu Fengguang864f92b2009-11-18 12:38:02 +080013480 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013481 bits = present ? AMP_IN_MUTE(0) : 0;
13482 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13483 AMP_IN_MUTE(0), bits);
13484 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13485 AMP_IN_MUTE(0), bits);
13486
13487 snd_hda_codec_write(codec, 0x20, 0,
13488 AC_VERB_SET_COEF_INDEX, 0x0c);
13489 snd_hda_codec_write(codec, 0x20, 0,
13490 AC_VERB_SET_PROC_COEF, 0x680);
13491
13492 snd_hda_codec_write(codec, 0x20, 0,
13493 AC_VERB_SET_COEF_INDEX, 0x0c);
13494 snd_hda_codec_write(codec, 0x20, 0,
13495 AC_VERB_SET_PROC_COEF, 0x480);
13496}
13497
Tony Vroon64154832008-11-06 15:08:49 +000013498/* toggle speaker-output according to the hp-jacks state */
13499static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13500{
13501 unsigned int present;
13502 unsigned char bits;
13503
13504 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013505 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013506
13507 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013508 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013509
13510 bits = present ? AMP_IN_MUTE(0) : 0;
13511 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13512 AMP_IN_MUTE(0), bits);
13513 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13514 AMP_IN_MUTE(0), bits);
13515
13516 snd_hda_codec_write(codec, 0x20, 0,
13517 AC_VERB_SET_COEF_INDEX, 0x0c);
13518 snd_hda_codec_write(codec, 0x20, 0,
13519 AC_VERB_SET_PROC_COEF, 0x680);
13520
13521 snd_hda_codec_write(codec, 0x20, 0,
13522 AC_VERB_SET_COEF_INDEX, 0x0c);
13523 snd_hda_codec_write(codec, 0x20, 0,
13524 AC_VERB_SET_PROC_COEF, 0x480);
13525}
13526
Tony Vroon64154832008-11-06 15:08:49 +000013527static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13528{
13529 unsigned int present_laptop;
13530 unsigned int present_dock;
13531
Wu Fengguang864f92b2009-11-18 12:38:02 +080013532 present_laptop = snd_hda_jack_detect(codec, 0x18);
13533 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013534
13535 /* Laptop mic port overrides dock mic port, design decision */
13536 if (present_dock)
13537 snd_hda_codec_write(codec, 0x23, 0,
13538 AC_VERB_SET_CONNECT_SEL, 0x3);
13539 if (present_laptop)
13540 snd_hda_codec_write(codec, 0x23, 0,
13541 AC_VERB_SET_CONNECT_SEL, 0x0);
13542 if (!present_dock && !present_laptop)
13543 snd_hda_codec_write(codec, 0x23, 0,
13544 AC_VERB_SET_CONNECT_SEL, 0x1);
13545}
13546
Kailang Yang60db6b52008-08-26 13:13:00 +020013547static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13548 unsigned int res)
13549{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013550 switch (res >> 26) {
13551 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013552 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013553 break;
13554 case ALC880_MIC_EVENT:
13555 alc_mic_automute(codec);
13556 break;
13557 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013558}
13559
Tony Vroon64154832008-11-06 15:08:49 +000013560static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13561 unsigned int res)
13562{
13563 if ((res >> 26) == ALC880_HP_EVENT)
13564 alc269_lifebook_speaker_automute(codec);
13565 if ((res >> 26) == ALC880_MIC_EVENT)
13566 alc269_lifebook_mic_autoswitch(codec);
13567}
13568
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013569static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13570{
13571 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013572 spec->autocfg.hp_pins[0] = 0x15;
13573 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013574 spec->ext_mic.pin = 0x18;
13575 spec->ext_mic.mux_idx = 0;
13576 spec->int_mic.pin = 0x19;
13577 spec->int_mic.mux_idx = 1;
13578 spec->auto_mic = 1;
13579}
13580
Kailang Yang60db6b52008-08-26 13:13:00 +020013581static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13582{
13583 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013584 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013585}
13586
Tony Vroon64154832008-11-06 15:08:49 +000013587static void alc269_lifebook_init_hook(struct hda_codec *codec)
13588{
13589 alc269_lifebook_speaker_automute(codec);
13590 alc269_lifebook_mic_autoswitch(codec);
13591}
13592
Kailang Yang84898e82010-02-04 14:16:14 +010013593static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013594 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13595 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13596 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13597 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13598 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13599 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13600 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13601 {}
13602};
13603
Kailang Yang84898e82010-02-04 14:16:14 +010013604static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13606 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13607 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13609 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13610 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13611 {}
13612};
13613
Kailang Yang84898e82010-02-04 14:16:14 +010013614static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13615 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13616 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13617 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13619 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13620 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13621 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13622 {}
13623};
13624
13625static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13626 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13627 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13628 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13629 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13630 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13631 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13632 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13633 {}
13634};
13635
Kailang Yang60db6b52008-08-26 13:13:00 +020013636/* toggle speaker-output according to the hp-jack state */
13637static void alc269_speaker_automute(struct hda_codec *codec)
13638{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013639 struct alc_spec *spec = codec->spec;
13640 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013641 unsigned int present;
13642 unsigned char bits;
13643
Kailang Yangebb83ee2009-12-17 12:23:00 +010013644 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013645 bits = present ? AMP_IN_MUTE(0) : 0;
13646 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13647 AMP_IN_MUTE(0), bits);
13648 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13649 AMP_IN_MUTE(0), bits);
13650}
13651
Kailang Yang60db6b52008-08-26 13:13:00 +020013652/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013653static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013654 unsigned int res)
13655{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013656 switch (res >> 26) {
13657 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013658 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013659 break;
13660 case ALC880_MIC_EVENT:
13661 alc_mic_automute(codec);
13662 break;
13663 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013664}
13665
Kailang Yang84898e82010-02-04 14:16:14 +010013666static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013667{
13668 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013669 spec->autocfg.hp_pins[0] = 0x15;
13670 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013671 spec->ext_mic.pin = 0x18;
13672 spec->ext_mic.mux_idx = 0;
13673 spec->int_mic.pin = 0x12;
13674 spec->int_mic.mux_idx = 5;
13675 spec->auto_mic = 1;
13676}
13677
Kailang Yang84898e82010-02-04 14:16:14 +010013678static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13679{
13680 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013681 spec->autocfg.hp_pins[0] = 0x15;
13682 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013683 spec->ext_mic.pin = 0x18;
13684 spec->ext_mic.mux_idx = 0;
13685 spec->int_mic.pin = 0x12;
13686 spec->int_mic.mux_idx = 6;
13687 spec->auto_mic = 1;
13688}
13689
13690static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013691{
13692 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013693 spec->autocfg.hp_pins[0] = 0x15;
13694 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013695 spec->ext_mic.pin = 0x18;
13696 spec->ext_mic.mux_idx = 0;
13697 spec->int_mic.pin = 0x19;
13698 spec->int_mic.mux_idx = 1;
13699 spec->auto_mic = 1;
13700}
13701
Kailang Yang84898e82010-02-04 14:16:14 +010013702static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013703{
13704 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013705 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013706}
13707
Kailang Yangf6a92242007-12-13 16:52:54 +010013708/*
13709 * generic initialization of ADC, input mixers and output mixers
13710 */
13711static struct hda_verb alc269_init_verbs[] = {
13712 /*
13713 * Unmute ADC0 and set the default input to mic-in
13714 */
Kailang Yang84898e82010-02-04 14:16:14 +010013715 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013716
13717 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013718 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013719 */
13720 /* set vol=0 to output mixers */
13721 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13722 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13723
13724 /* set up input amps for analog loopback */
13725 /* Amp Indices: DAC = 0, mixer = 1 */
13726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13728 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13730 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13732
13733 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13736 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13737 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13738 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13739 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13740
13741 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13742 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013743
Kailang Yang84898e82010-02-04 14:16:14 +010013744 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013745 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13746 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013747 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013748
13749 /* set EAPD */
13750 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013751 { }
13752};
13753
13754static struct hda_verb alc269vb_init_verbs[] = {
13755 /*
13756 * Unmute ADC0 and set the default input to mic-in
13757 */
13758 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13759
13760 /*
13761 * Set up output mixers (0x02 - 0x03)
13762 */
13763 /* set vol=0 to output mixers */
13764 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13765 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13766
13767 /* set up input amps for analog loopback */
13768 /* Amp Indices: DAC = 0, mixer = 1 */
13769 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13771 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13773 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13775
13776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13777 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13778 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13779 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13781 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13782 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13783
13784 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13785 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13786
13787 /* FIXME: use Mux-type input source selection */
13788 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13789 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13790 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13791
13792 /* set EAPD */
13793 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013794 { }
13795};
13796
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013797#define alc269_auto_create_multi_out_ctls \
13798 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013799#define alc269_auto_create_input_ctls \
13800 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013801
13802#ifdef CONFIG_SND_HDA_POWER_SAVE
13803#define alc269_loopbacks alc880_loopbacks
13804#endif
13805
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013806/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013807#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13808#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13809#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13810#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13811
Takashi Iwaif03d3112009-03-05 14:18:16 +010013812static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13813 .substreams = 1,
13814 .channels_min = 2,
13815 .channels_max = 8,
13816 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13817 /* NID is set in alc_build_pcms */
13818 .ops = {
13819 .open = alc880_playback_pcm_open,
13820 .prepare = alc880_playback_pcm_prepare,
13821 .cleanup = alc880_playback_pcm_cleanup
13822 },
13823};
13824
13825static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13826 .substreams = 1,
13827 .channels_min = 2,
13828 .channels_max = 2,
13829 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13830 /* NID is set in alc_build_pcms */
13831};
13832
Kailang Yangf6a92242007-12-13 16:52:54 +010013833/*
13834 * BIOS auto configuration
13835 */
13836static int alc269_parse_auto_config(struct hda_codec *codec)
13837{
13838 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013839 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013840 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yang84898e82010-02-04 14:16:14 +010013841 hda_nid_t real_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010013842
13843 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13844 alc269_ignore);
13845 if (err < 0)
13846 return err;
13847
13848 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13849 if (err < 0)
13850 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013851 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013852 if (err < 0)
13853 return err;
13854
13855 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13856
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013857 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013858 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13859
Takashi Iwai603c4012008-07-30 15:01:44 +020013860 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013861 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013862
Kailang Yang84898e82010-02-04 14:16:14 +010013863 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13864 add_verb(spec, alc269vb_init_verbs);
13865 real_capsrc_nids = alc269vb_capsrc_nids[0];
Kailang Yang6227cdc2010-02-25 08:36:52 +010013866 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010013867 } else {
13868 add_verb(spec, alc269_init_verbs);
13869 real_capsrc_nids = alc269_capsrc_nids[0];
Kailang Yang6227cdc2010-02-25 08:36:52 +010013870 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010013871 }
13872
Kailang Yangf6a92242007-12-13 16:52:54 +010013873 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013874 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013875 /* set default input source */
Kailang Yang84898e82010-02-04 14:16:14 +010013876 snd_hda_codec_write_cache(codec, real_capsrc_nids,
Takashi Iwaie01bf502008-08-21 16:25:07 +020013877 0, AC_VERB_SET_CONNECT_SEL,
13878 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013879
13880 err = alc_auto_add_mic_boost(codec);
13881 if (err < 0)
13882 return err;
13883
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013884 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013885 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013886
Kailang Yangf6a92242007-12-13 16:52:54 +010013887 return 1;
13888}
13889
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013890#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13891#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013892#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13893
13894
13895/* init callback for auto-configuration model -- overriding the default init */
13896static void alc269_auto_init(struct hda_codec *codec)
13897{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013898 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013899 alc269_auto_init_multi_out(codec);
13900 alc269_auto_init_hp_out(codec);
13901 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013902 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013903 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013904}
13905
13906/*
13907 * configuration and preset
13908 */
13909static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013910 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013911 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013912 [ALC269_AMIC] = "laptop-amic",
13913 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013914 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013915 [ALC269_LIFEBOOK] = "lifebook",
13916 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013917};
13918
13919static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013920 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013921 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013922 ALC269_AMIC),
13923 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13924 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13925 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13926 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13927 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13928 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13929 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13930 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13931 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
13932 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
13933 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
13934 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
13935 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
13936 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
13937 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
13938 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
13939 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
13940 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
13941 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
13942 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
13943 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
13944 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
13945 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
13946 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
13947 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
13948 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
13949 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
13950 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
13951 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
13952 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
13953 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
13954 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
13955 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
13956 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
13957 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
13958 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013959 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010013960 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013961 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010013962 ALC269_DMIC),
13963 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
13964 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010013965 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000013966 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010013967 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
13968 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
13969 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
13970 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
13971 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
13972 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010013973 {}
13974};
13975
13976static struct alc_config_preset alc269_presets[] = {
13977 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013978 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013979 .init_verbs = { alc269_init_verbs },
13980 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13981 .dac_nids = alc269_dac_nids,
13982 .hp_nid = 0x03,
13983 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13984 .channel_mode = alc269_modes,
13985 .input_mux = &alc269_capture_source,
13986 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013987 [ALC269_QUANTA_FL1] = {
13988 .mixers = { alc269_quanta_fl1_mixer },
13989 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13990 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13991 .dac_nids = alc269_dac_nids,
13992 .hp_nid = 0x03,
13993 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13994 .channel_mode = alc269_modes,
13995 .input_mux = &alc269_capture_source,
13996 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013997 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013998 .init_hook = alc269_quanta_fl1_init_hook,
13999 },
Kailang Yang84898e82010-02-04 14:16:14 +010014000 [ALC269_AMIC] = {
14001 .mixers = { alc269_laptop_mixer },
14002 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014003 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014004 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014005 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14006 .dac_nids = alc269_dac_nids,
14007 .hp_nid = 0x03,
14008 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14009 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014010 .unsol_event = alc269_laptop_unsol_event,
14011 .setup = alc269_laptop_amic_setup,
14012 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014013 },
Kailang Yang84898e82010-02-04 14:16:14 +010014014 [ALC269_DMIC] = {
14015 .mixers = { alc269_laptop_mixer },
14016 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014017 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014018 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014019 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14020 .dac_nids = alc269_dac_nids,
14021 .hp_nid = 0x03,
14022 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14023 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014024 .unsol_event = alc269_laptop_unsol_event,
14025 .setup = alc269_laptop_dmic_setup,
14026 .init_hook = alc269_laptop_inithook,
14027 },
14028 [ALC269VB_AMIC] = {
14029 .mixers = { alc269vb_laptop_mixer },
14030 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14031 .init_verbs = { alc269vb_init_verbs,
14032 alc269vb_laptop_amic_init_verbs },
14033 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14034 .dac_nids = alc269_dac_nids,
14035 .hp_nid = 0x03,
14036 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14037 .channel_mode = alc269_modes,
14038 .unsol_event = alc269_laptop_unsol_event,
14039 .setup = alc269_laptop_amic_setup,
14040 .init_hook = alc269_laptop_inithook,
14041 },
14042 [ALC269VB_DMIC] = {
14043 .mixers = { alc269vb_laptop_mixer },
14044 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14045 .init_verbs = { alc269vb_init_verbs,
14046 alc269vb_laptop_dmic_init_verbs },
14047 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14048 .dac_nids = alc269_dac_nids,
14049 .hp_nid = 0x03,
14050 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14051 .channel_mode = alc269_modes,
14052 .unsol_event = alc269_laptop_unsol_event,
14053 .setup = alc269vb_laptop_dmic_setup,
14054 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014055 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014056 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014057 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014058 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014059 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014060 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014061 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14062 .dac_nids = alc269_dac_nids,
14063 .hp_nid = 0x03,
14064 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14065 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014066 .unsol_event = alc269_laptop_unsol_event,
14067 .setup = alc269_laptop_dmic_setup,
14068 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014069 },
Tony Vroon64154832008-11-06 15:08:49 +000014070 [ALC269_LIFEBOOK] = {
14071 .mixers = { alc269_lifebook_mixer },
14072 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14073 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14074 .dac_nids = alc269_dac_nids,
14075 .hp_nid = 0x03,
14076 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14077 .channel_mode = alc269_modes,
14078 .input_mux = &alc269_capture_source,
14079 .unsol_event = alc269_lifebook_unsol_event,
14080 .init_hook = alc269_lifebook_init_hook,
14081 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014082};
14083
14084static int patch_alc269(struct hda_codec *codec)
14085{
14086 struct alc_spec *spec;
14087 int board_config;
14088 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014089 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014090
14091 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14092 if (spec == NULL)
14093 return -ENOMEM;
14094
14095 codec->spec = spec;
14096
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014097 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14098
Kailang Yang274693f2009-12-03 10:07:50 +010014099 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14100 kfree(codec->chip_name);
14101 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014102 if (!codec->chip_name) {
14103 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014104 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014105 }
Kailang Yang84898e82010-02-04 14:16:14 +010014106 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014107 }
14108
Kailang Yangf6a92242007-12-13 16:52:54 +010014109 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14110 alc269_models,
14111 alc269_cfg_tbl);
14112
14113 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014114 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14115 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014116 board_config = ALC269_AUTO;
14117 }
14118
14119 if (board_config == ALC269_AUTO) {
14120 /* automatic parse from the BIOS config */
14121 err = alc269_parse_auto_config(codec);
14122 if (err < 0) {
14123 alc_free(codec);
14124 return err;
14125 } else if (!err) {
14126 printk(KERN_INFO
14127 "hda_codec: Cannot set up configuration "
14128 "from BIOS. Using base mode...\n");
14129 board_config = ALC269_BASIC;
14130 }
14131 }
14132
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014133 err = snd_hda_attach_beep_device(codec, 0x1);
14134 if (err < 0) {
14135 alc_free(codec);
14136 return err;
14137 }
14138
Kailang Yangf6a92242007-12-13 16:52:54 +010014139 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014140 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014141
Kailang Yang84898e82010-02-04 14:16:14 +010014142 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014143 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14144 * fix the sample rate of analog I/O to 44.1kHz
14145 */
14146 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14147 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14148 } else {
14149 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14150 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14151 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014152 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14153 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14154
Kailang Yang84898e82010-02-04 14:16:14 +010014155 if (!is_alc269vb) {
14156 spec->adc_nids = alc269_adc_nids;
14157 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14158 spec->capsrc_nids = alc269_capsrc_nids;
14159 } else {
14160 spec->adc_nids = alc269vb_adc_nids;
14161 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14162 spec->capsrc_nids = alc269vb_capsrc_nids;
14163 }
14164
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014165 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014166 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014167 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014168
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014169 spec->vmaster_nid = 0x02;
14170
Kailang Yangf6a92242007-12-13 16:52:54 +010014171 codec->patch_ops = alc_patch_ops;
14172 if (board_config == ALC269_AUTO)
14173 spec->init_hook = alc269_auto_init;
14174#ifdef CONFIG_SND_HDA_POWER_SAVE
14175 if (!spec->loopback.amplist)
14176 spec->loopback.amplist = alc269_loopbacks;
14177#endif
14178
14179 return 0;
14180}
14181
14182/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014183 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14184 */
14185
14186/*
14187 * set the path ways for 2 channel output
14188 * need to set the codec line out and mic 1 pin widgets to inputs
14189 */
14190static struct hda_verb alc861_threestack_ch2_init[] = {
14191 /* set pin widget 1Ah (line in) for input */
14192 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014193 /* set pin widget 18h (mic1/2) for input, for mic also enable
14194 * the vref
14195 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014196 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14197
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014198 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14199#if 0
14200 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14201 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14202#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014203 { } /* end */
14204};
14205/*
14206 * 6ch mode
14207 * need to set the codec line out and mic 1 pin widgets to outputs
14208 */
14209static struct hda_verb alc861_threestack_ch6_init[] = {
14210 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14211 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14212 /* set pin widget 18h (mic1) for output (CLFE)*/
14213 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14214
14215 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014216 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014217
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014218 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14219#if 0
14220 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14221 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14222#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014223 { } /* end */
14224};
14225
14226static struct hda_channel_mode alc861_threestack_modes[2] = {
14227 { 2, alc861_threestack_ch2_init },
14228 { 6, alc861_threestack_ch6_init },
14229};
Takashi Iwai22309c32006-08-09 16:57:28 +020014230/* Set mic1 as input and unmute the mixer */
14231static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14232 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14233 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14234 { } /* end */
14235};
14236/* Set mic1 as output and mute mixer */
14237static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14238 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14239 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14240 { } /* end */
14241};
14242
14243static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14244 { 2, alc861_uniwill_m31_ch2_init },
14245 { 4, alc861_uniwill_m31_ch4_init },
14246};
Kailang Yangdf694da2005-12-05 19:42:22 +010014247
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014248/* Set mic1 and line-in as input and unmute the mixer */
14249static struct hda_verb alc861_asus_ch2_init[] = {
14250 /* set pin widget 1Ah (line in) for input */
14251 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014252 /* set pin widget 18h (mic1/2) for input, for mic also enable
14253 * the vref
14254 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014255 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14256
14257 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14258#if 0
14259 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14260 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14261#endif
14262 { } /* end */
14263};
14264/* Set mic1 nad line-in as output and mute mixer */
14265static struct hda_verb alc861_asus_ch6_init[] = {
14266 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14267 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14268 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14269 /* set pin widget 18h (mic1) for output (CLFE)*/
14270 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14271 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14272 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14273 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14274
14275 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14276#if 0
14277 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14278 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14279#endif
14280 { } /* end */
14281};
14282
14283static struct hda_channel_mode alc861_asus_modes[2] = {
14284 { 2, alc861_asus_ch2_init },
14285 { 6, alc861_asus_ch6_init },
14286};
14287
Kailang Yangdf694da2005-12-05 19:42:22 +010014288/* patch-ALC861 */
14289
14290static struct snd_kcontrol_new alc861_base_mixer[] = {
14291 /* output mixer control */
14292 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14293 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14294 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14295 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14296 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14297
14298 /*Input mixer control */
14299 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14300 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14301 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14302 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14303 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14304 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14306 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14307 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14308 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014309
Kailang Yangdf694da2005-12-05 19:42:22 +010014310 { } /* end */
14311};
14312
14313static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14314 /* output mixer control */
14315 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14316 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14317 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14318 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14319 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14320
14321 /* Input mixer control */
14322 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14323 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14324 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14325 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14326 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14327 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14329 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14330 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014332
Kailang Yangdf694da2005-12-05 19:42:22 +010014333 {
14334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14335 .name = "Channel Mode",
14336 .info = alc_ch_mode_info,
14337 .get = alc_ch_mode_get,
14338 .put = alc_ch_mode_put,
14339 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14340 },
14341 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014342};
14343
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014344static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014345 /* output mixer control */
14346 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14347 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14348 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014349
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014350 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014351};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014352
Takashi Iwai22309c32006-08-09 16:57:28 +020014353static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14354 /* output mixer control */
14355 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14356 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14357 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14358 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14359 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14360
14361 /* Input mixer control */
14362 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14363 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14364 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14365 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14366 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14367 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14369 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14371 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014372
Takashi Iwai22309c32006-08-09 16:57:28 +020014373 {
14374 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14375 .name = "Channel Mode",
14376 .info = alc_ch_mode_info,
14377 .get = alc_ch_mode_get,
14378 .put = alc_ch_mode_put,
14379 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14380 },
14381 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014382};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014383
14384static struct snd_kcontrol_new alc861_asus_mixer[] = {
14385 /* output mixer control */
14386 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14387 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14388 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14389 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14390 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14391
14392 /* Input mixer control */
14393 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14394 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14395 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14396 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14397 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14398 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14400 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14401 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014402 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14403
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014404 {
14405 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14406 .name = "Channel Mode",
14407 .info = alc_ch_mode_info,
14408 .get = alc_ch_mode_get,
14409 .put = alc_ch_mode_put,
14410 .private_value = ARRAY_SIZE(alc861_asus_modes),
14411 },
14412 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014413};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014414
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014415/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014416static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014417 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14418 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014419 { }
14420};
14421
Kailang Yangdf694da2005-12-05 19:42:22 +010014422/*
14423 * generic initialization of ADC, input mixers and output mixers
14424 */
14425static struct hda_verb alc861_base_init_verbs[] = {
14426 /*
14427 * Unmute ADC0 and set the default input to mic-in
14428 */
14429 /* port-A for surround (rear panel) */
14430 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14431 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14432 /* port-B for mic-in (rear panel) with vref */
14433 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14434 /* port-C for line-in (rear panel) */
14435 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14436 /* port-D for Front */
14437 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14438 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14439 /* port-E for HP out (front panel) */
14440 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14441 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014442 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014443 /* port-F for mic-in (front panel) with vref */
14444 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14445 /* port-G for CLFE (rear panel) */
14446 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14447 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14448 /* port-H for side (rear panel) */
14449 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14450 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14451 /* CD-in */
14452 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14453 /* route front mic to ADC1*/
14454 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014456
Kailang Yangdf694da2005-12-05 19:42:22 +010014457 /* Unmute DAC0~3 & spdif out*/
14458 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14459 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14460 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14461 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014463
Kailang Yangdf694da2005-12-05 19:42:22 +010014464 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14465 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14466 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14467 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14468 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014469
Kailang Yangdf694da2005-12-05 19:42:22 +010014470 /* Unmute Stereo Mixer 15 */
14471 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014475
14476 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14477 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14478 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14479 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14480 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14482 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014484 /* hp used DAC 3 (Front) */
14485 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14487
14488 { }
14489};
14490
14491static struct hda_verb alc861_threestack_init_verbs[] = {
14492 /*
14493 * Unmute ADC0 and set the default input to mic-in
14494 */
14495 /* port-A for surround (rear panel) */
14496 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14497 /* port-B for mic-in (rear panel) with vref */
14498 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14499 /* port-C for line-in (rear panel) */
14500 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14501 /* port-D for Front */
14502 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14503 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14504 /* port-E for HP out (front panel) */
14505 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14506 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014507 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014508 /* port-F for mic-in (front panel) with vref */
14509 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14510 /* port-G for CLFE (rear panel) */
14511 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14512 /* port-H for side (rear panel) */
14513 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14514 /* CD-in */
14515 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14516 /* route front mic to ADC1*/
14517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14519 /* Unmute DAC0~3 & spdif out*/
14520 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14521 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14522 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14523 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14524 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014525
Kailang Yangdf694da2005-12-05 19:42:22 +010014526 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14527 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14528 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14529 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14530 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014531
Kailang Yangdf694da2005-12-05 19:42:22 +010014532 /* Unmute Stereo Mixer 15 */
14533 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014537
14538 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14540 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14541 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14542 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14544 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014546 /* hp used DAC 3 (Front) */
14547 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14549 { }
14550};
Takashi Iwai22309c32006-08-09 16:57:28 +020014551
14552static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14553 /*
14554 * Unmute ADC0 and set the default input to mic-in
14555 */
14556 /* port-A for surround (rear panel) */
14557 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14558 /* port-B for mic-in (rear panel) with vref */
14559 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14560 /* port-C for line-in (rear panel) */
14561 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14562 /* port-D for Front */
14563 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14564 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14565 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014566 /* this has to be set to VREF80 */
14567 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014568 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014569 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014570 /* port-F for mic-in (front panel) with vref */
14571 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14572 /* port-G for CLFE (rear panel) */
14573 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14574 /* port-H for side (rear panel) */
14575 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14576 /* CD-in */
14577 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14578 /* route front mic to ADC1*/
14579 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14580 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14581 /* Unmute DAC0~3 & spdif out*/
14582 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14583 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14584 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14585 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014587
Takashi Iwai22309c32006-08-09 16:57:28 +020014588 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14589 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14590 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14591 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14592 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014593
Takashi Iwai22309c32006-08-09 16:57:28 +020014594 /* Unmute Stereo Mixer 15 */
14595 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014599
14600 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14601 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14602 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14603 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14604 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14605 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14606 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14607 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014608 /* hp used DAC 3 (Front) */
14609 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014610 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14611 { }
14612};
14613
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014614static struct hda_verb alc861_asus_init_verbs[] = {
14615 /*
14616 * Unmute ADC0 and set the default input to mic-in
14617 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014618 /* port-A for surround (rear panel)
14619 * according to codec#0 this is the HP jack
14620 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014621 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14622 /* route front PCM to HP */
14623 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14624 /* port-B for mic-in (rear panel) with vref */
14625 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14626 /* port-C for line-in (rear panel) */
14627 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14628 /* port-D for Front */
14629 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14630 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14631 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014632 /* this has to be set to VREF80 */
14633 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014634 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014635 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014636 /* port-F for mic-in (front panel) with vref */
14637 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14638 /* port-G for CLFE (rear panel) */
14639 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14640 /* port-H for side (rear panel) */
14641 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14642 /* CD-in */
14643 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14644 /* route front mic to ADC1*/
14645 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14647 /* Unmute DAC0~3 & spdif out*/
14648 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14649 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14650 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14651 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14653 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14654 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14655 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14656 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14657 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014658
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014659 /* Unmute Stereo Mixer 15 */
14660 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014664
14665 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14667 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14668 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14669 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14671 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014673 /* hp used DAC 3 (Front) */
14674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014675 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14676 { }
14677};
14678
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014679/* additional init verbs for ASUS laptops */
14680static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14681 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14682 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14683 { }
14684};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014685
Kailang Yangdf694da2005-12-05 19:42:22 +010014686/*
14687 * generic initialization of ADC, input mixers and output mixers
14688 */
14689static struct hda_verb alc861_auto_init_verbs[] = {
14690 /*
14691 * Unmute ADC0 and set the default input to mic-in
14692 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014693 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014694 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014695
Kailang Yangdf694da2005-12-05 19:42:22 +010014696 /* Unmute DAC0~3 & spdif out*/
14697 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14698 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14699 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14700 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14701 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014702
Kailang Yangdf694da2005-12-05 19:42:22 +010014703 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14704 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14705 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14706 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14707 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014708
Kailang Yangdf694da2005-12-05 19:42:22 +010014709 /* Unmute Stereo Mixer 15 */
14710 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14713 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14714
Takashi Iwai1c209302009-07-22 15:17:45 +020014715 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14717 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14719 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14720 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14721 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14722 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014723
14724 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014728 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14729 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14731 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014732
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014733 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014734
14735 { }
14736};
14737
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014738static struct hda_verb alc861_toshiba_init_verbs[] = {
14739 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014740
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014741 { }
14742};
14743
14744/* toggle speaker-output according to the hp-jack state */
14745static void alc861_toshiba_automute(struct hda_codec *codec)
14746{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014747 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014748
Takashi Iwai47fd8302007-08-10 17:11:07 +020014749 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14750 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14751 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14752 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014753}
14754
14755static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14756 unsigned int res)
14757{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014758 if ((res >> 26) == ALC880_HP_EVENT)
14759 alc861_toshiba_automute(codec);
14760}
14761
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014762/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014763#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14764#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14765#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14766#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14767
14768
14769#define ALC861_DIGOUT_NID 0x07
14770
14771static struct hda_channel_mode alc861_8ch_modes[1] = {
14772 { 8, NULL }
14773};
14774
14775static hda_nid_t alc861_dac_nids[4] = {
14776 /* front, surround, clfe, side */
14777 0x03, 0x06, 0x05, 0x04
14778};
14779
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014780static hda_nid_t alc660_dac_nids[3] = {
14781 /* front, clfe, surround */
14782 0x03, 0x05, 0x06
14783};
14784
Kailang Yangdf694da2005-12-05 19:42:22 +010014785static hda_nid_t alc861_adc_nids[1] = {
14786 /* ADC0-2 */
14787 0x08,
14788};
14789
14790static struct hda_input_mux alc861_capture_source = {
14791 .num_items = 5,
14792 .items = {
14793 { "Mic", 0x0 },
14794 { "Front Mic", 0x3 },
14795 { "Line", 0x1 },
14796 { "CD", 0x4 },
14797 { "Mixer", 0x5 },
14798 },
14799};
14800
Takashi Iwai1c209302009-07-22 15:17:45 +020014801static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14802{
14803 struct alc_spec *spec = codec->spec;
14804 hda_nid_t mix, srcs[5];
14805 int i, j, num;
14806
14807 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14808 return 0;
14809 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14810 if (num < 0)
14811 return 0;
14812 for (i = 0; i < num; i++) {
14813 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014814 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014815 if (type != AC_WID_AUD_OUT)
14816 continue;
14817 for (j = 0; j < spec->multiout.num_dacs; j++)
14818 if (spec->multiout.dac_nids[j] == srcs[i])
14819 break;
14820 if (j >= spec->multiout.num_dacs)
14821 return srcs[i];
14822 }
14823 return 0;
14824}
14825
Kailang Yangdf694da2005-12-05 19:42:22 +010014826/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014827static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014828 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014829{
Takashi Iwai1c209302009-07-22 15:17:45 +020014830 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014831 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014832 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014833
14834 spec->multiout.dac_nids = spec->private_dac_nids;
14835 for (i = 0; i < cfg->line_outs; i++) {
14836 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014837 dac = alc861_look_for_dac(codec, nid);
14838 if (!dac)
14839 continue;
14840 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014841 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014842 return 0;
14843}
14844
Takashi Iwai1c209302009-07-22 15:17:45 +020014845static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14846 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014847{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014848 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014849 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14850}
14851
14852/* add playback controls from the parsed DAC table */
14853static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14854 const struct auto_pin_cfg *cfg)
14855{
14856 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014857 static const char *chname[4] = {
14858 "Front", "Surround", NULL /*CLFE*/, "Side"
14859 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014860 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014861 int i, err;
14862
14863 if (cfg->line_outs == 1) {
14864 const char *pfx = NULL;
14865 if (!cfg->hp_outs)
14866 pfx = "Master";
14867 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14868 pfx = "Speaker";
14869 if (pfx) {
14870 nid = spec->multiout.dac_nids[0];
14871 return alc861_create_out_sw(codec, pfx, nid, 3);
14872 }
14873 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014874
14875 for (i = 0; i < cfg->line_outs; i++) {
14876 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014877 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014878 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014879 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014880 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014881 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014882 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014883 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014884 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014885 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014886 return err;
14887 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014888 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014889 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014890 return err;
14891 }
14892 }
14893 return 0;
14894}
14895
Takashi Iwai1c209302009-07-22 15:17:45 +020014896static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014897{
Takashi Iwai1c209302009-07-22 15:17:45 +020014898 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014899 int err;
14900 hda_nid_t nid;
14901
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014902 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014903 return 0;
14904
14905 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014906 nid = alc861_look_for_dac(codec, pin);
14907 if (nid) {
14908 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14909 if (err < 0)
14910 return err;
14911 spec->multiout.hp_nid = nid;
14912 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014913 }
14914 return 0;
14915}
14916
14917/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014918static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014919 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014920{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014921 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014922}
14923
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014924static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14925 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014926 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014927{
Takashi Iwai1c209302009-07-22 15:17:45 +020014928 hda_nid_t mix, srcs[5];
14929 int i, num;
14930
Jacek Luczak564c5be2008-05-03 18:41:23 +020014931 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14932 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014933 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014934 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014935 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14936 return;
14937 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14938 if (num < 0)
14939 return;
14940 for (i = 0; i < num; i++) {
14941 unsigned int mute;
14942 if (srcs[i] == dac || srcs[i] == 0x15)
14943 mute = AMP_IN_UNMUTE(i);
14944 else
14945 mute = AMP_IN_MUTE(i);
14946 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14947 mute);
14948 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014949}
14950
14951static void alc861_auto_init_multi_out(struct hda_codec *codec)
14952{
14953 struct alc_spec *spec = codec->spec;
14954 int i;
14955
14956 for (i = 0; i < spec->autocfg.line_outs; i++) {
14957 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014958 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014959 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014960 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014961 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014962 }
14963}
14964
14965static void alc861_auto_init_hp_out(struct hda_codec *codec)
14966{
14967 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014968
Takashi Iwai15870f02009-10-05 08:25:13 +020014969 if (spec->autocfg.hp_outs)
14970 alc861_auto_set_output_and_unmute(codec,
14971 spec->autocfg.hp_pins[0],
14972 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014973 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014974 if (spec->autocfg.speaker_outs)
14975 alc861_auto_set_output_and_unmute(codec,
14976 spec->autocfg.speaker_pins[0],
14977 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014978 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014979}
14980
14981static void alc861_auto_init_analog_input(struct hda_codec *codec)
14982{
14983 struct alc_spec *spec = codec->spec;
14984 int i;
14985
14986 for (i = 0; i < AUTO_PIN_LAST; i++) {
14987 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014988 if (nid >= 0x0c && nid <= 0x11)
14989 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014990 }
14991}
14992
14993/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014994/* return 1 if successful, 0 if the proper config is not found,
14995 * or a negative error code
14996 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014997static int alc861_parse_auto_config(struct hda_codec *codec)
14998{
14999 struct alc_spec *spec = codec->spec;
15000 int err;
15001 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15002
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015003 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15004 alc861_ignore);
15005 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015006 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015007 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015008 return 0; /* can't find valid BIOS pin config */
15009
Takashi Iwai1c209302009-07-22 15:17:45 +020015010 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015011 if (err < 0)
15012 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015013 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015014 if (err < 0)
15015 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015016 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015017 if (err < 0)
15018 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015019 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015020 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015021 return err;
15022
15023 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15024
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015025 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015026 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15027
Takashi Iwai603c4012008-07-30 15:01:44 +020015028 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015029 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015030
Takashi Iwaid88897e2008-10-31 15:01:37 +010015031 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015032
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015033 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015034 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015035
15036 spec->adc_nids = alc861_adc_nids;
15037 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015038 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015039
Kailang Yang6227cdc2010-02-25 08:36:52 +010015040 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015041
Kailang Yangdf694da2005-12-05 19:42:22 +010015042 return 1;
15043}
15044
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015045/* additional initialization for auto-configuration model */
15046static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015047{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015048 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015049 alc861_auto_init_multi_out(codec);
15050 alc861_auto_init_hp_out(codec);
15051 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015052 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015053 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015054}
15055
Takashi Iwaicb53c622007-08-10 17:21:45 +020015056#ifdef CONFIG_SND_HDA_POWER_SAVE
15057static struct hda_amp_list alc861_loopbacks[] = {
15058 { 0x15, HDA_INPUT, 0 },
15059 { 0x15, HDA_INPUT, 1 },
15060 { 0x15, HDA_INPUT, 2 },
15061 { 0x15, HDA_INPUT, 3 },
15062 { } /* end */
15063};
15064#endif
15065
Kailang Yangdf694da2005-12-05 19:42:22 +010015066
15067/*
15068 * configuration and preset
15069 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015070static const char *alc861_models[ALC861_MODEL_LAST] = {
15071 [ALC861_3ST] = "3stack",
15072 [ALC660_3ST] = "3stack-660",
15073 [ALC861_3ST_DIG] = "3stack-dig",
15074 [ALC861_6ST_DIG] = "6stack-dig",
15075 [ALC861_UNIWILL_M31] = "uniwill-m31",
15076 [ALC861_TOSHIBA] = "toshiba",
15077 [ALC861_ASUS] = "asus",
15078 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15079 [ALC861_AUTO] = "auto",
15080};
15081
15082static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015083 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015084 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15085 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15086 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015087 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015088 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015089 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015090 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15091 * Any other models that need this preset?
15092 */
15093 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015094 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15095 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015096 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15097 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15098 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15099 /* FIXME: the below seems conflict */
15100 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15101 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15102 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015103 {}
15104};
15105
15106static struct alc_config_preset alc861_presets[] = {
15107 [ALC861_3ST] = {
15108 .mixers = { alc861_3ST_mixer },
15109 .init_verbs = { alc861_threestack_init_verbs },
15110 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15111 .dac_nids = alc861_dac_nids,
15112 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15113 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015114 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015115 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15116 .adc_nids = alc861_adc_nids,
15117 .input_mux = &alc861_capture_source,
15118 },
15119 [ALC861_3ST_DIG] = {
15120 .mixers = { alc861_base_mixer },
15121 .init_verbs = { alc861_threestack_init_verbs },
15122 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15123 .dac_nids = alc861_dac_nids,
15124 .dig_out_nid = ALC861_DIGOUT_NID,
15125 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15126 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015127 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015128 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15129 .adc_nids = alc861_adc_nids,
15130 .input_mux = &alc861_capture_source,
15131 },
15132 [ALC861_6ST_DIG] = {
15133 .mixers = { alc861_base_mixer },
15134 .init_verbs = { alc861_base_init_verbs },
15135 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15136 .dac_nids = alc861_dac_nids,
15137 .dig_out_nid = ALC861_DIGOUT_NID,
15138 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15139 .channel_mode = alc861_8ch_modes,
15140 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15141 .adc_nids = alc861_adc_nids,
15142 .input_mux = &alc861_capture_source,
15143 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015144 [ALC660_3ST] = {
15145 .mixers = { alc861_3ST_mixer },
15146 .init_verbs = { alc861_threestack_init_verbs },
15147 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15148 .dac_nids = alc660_dac_nids,
15149 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15150 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015151 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015152 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15153 .adc_nids = alc861_adc_nids,
15154 .input_mux = &alc861_capture_source,
15155 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015156 [ALC861_UNIWILL_M31] = {
15157 .mixers = { alc861_uniwill_m31_mixer },
15158 .init_verbs = { alc861_uniwill_m31_init_verbs },
15159 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15160 .dac_nids = alc861_dac_nids,
15161 .dig_out_nid = ALC861_DIGOUT_NID,
15162 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15163 .channel_mode = alc861_uniwill_m31_modes,
15164 .need_dac_fix = 1,
15165 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15166 .adc_nids = alc861_adc_nids,
15167 .input_mux = &alc861_capture_source,
15168 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015169 [ALC861_TOSHIBA] = {
15170 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015171 .init_verbs = { alc861_base_init_verbs,
15172 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015173 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15174 .dac_nids = alc861_dac_nids,
15175 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15176 .channel_mode = alc883_3ST_2ch_modes,
15177 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15178 .adc_nids = alc861_adc_nids,
15179 .input_mux = &alc861_capture_source,
15180 .unsol_event = alc861_toshiba_unsol_event,
15181 .init_hook = alc861_toshiba_automute,
15182 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015183 [ALC861_ASUS] = {
15184 .mixers = { alc861_asus_mixer },
15185 .init_verbs = { alc861_asus_init_verbs },
15186 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15187 .dac_nids = alc861_dac_nids,
15188 .dig_out_nid = ALC861_DIGOUT_NID,
15189 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15190 .channel_mode = alc861_asus_modes,
15191 .need_dac_fix = 1,
15192 .hp_nid = 0x06,
15193 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15194 .adc_nids = alc861_adc_nids,
15195 .input_mux = &alc861_capture_source,
15196 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015197 [ALC861_ASUS_LAPTOP] = {
15198 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15199 .init_verbs = { alc861_asus_init_verbs,
15200 alc861_asus_laptop_init_verbs },
15201 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15202 .dac_nids = alc861_dac_nids,
15203 .dig_out_nid = ALC861_DIGOUT_NID,
15204 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15205 .channel_mode = alc883_3ST_2ch_modes,
15206 .need_dac_fix = 1,
15207 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15208 .adc_nids = alc861_adc_nids,
15209 .input_mux = &alc861_capture_source,
15210 },
15211};
Kailang Yangdf694da2005-12-05 19:42:22 +010015212
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015213/* Pin config fixes */
15214enum {
15215 PINFIX_FSC_AMILO_PI1505,
15216};
15217
15218static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15219 { 0x0b, 0x0221101f }, /* HP */
15220 { 0x0f, 0x90170310 }, /* speaker */
15221 { }
15222};
15223
15224static const struct alc_fixup alc861_fixups[] = {
15225 [PINFIX_FSC_AMILO_PI1505] = {
15226 .pins = alc861_fsc_amilo_pi1505_pinfix
15227 },
15228};
15229
15230static struct snd_pci_quirk alc861_fixup_tbl[] = {
15231 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15232 {}
15233};
Kailang Yangdf694da2005-12-05 19:42:22 +010015234
15235static int patch_alc861(struct hda_codec *codec)
15236{
15237 struct alc_spec *spec;
15238 int board_config;
15239 int err;
15240
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015241 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015242 if (spec == NULL)
15243 return -ENOMEM;
15244
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015245 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015246
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015247 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15248 alc861_models,
15249 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015250
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015251 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015252 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15253 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015254 board_config = ALC861_AUTO;
15255 }
15256
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015257 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15258
Kailang Yangdf694da2005-12-05 19:42:22 +010015259 if (board_config == ALC861_AUTO) {
15260 /* automatic parse from the BIOS config */
15261 err = alc861_parse_auto_config(codec);
15262 if (err < 0) {
15263 alc_free(codec);
15264 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015265 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015266 printk(KERN_INFO
15267 "hda_codec: Cannot set up configuration "
15268 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015269 board_config = ALC861_3ST_DIG;
15270 }
15271 }
15272
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015273 err = snd_hda_attach_beep_device(codec, 0x23);
15274 if (err < 0) {
15275 alc_free(codec);
15276 return err;
15277 }
15278
Kailang Yangdf694da2005-12-05 19:42:22 +010015279 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015280 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015281
Kailang Yangdf694da2005-12-05 19:42:22 +010015282 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15283 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15284
Kailang Yangdf694da2005-12-05 19:42:22 +010015285 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15286 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15287
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015288 if (!spec->cap_mixer)
15289 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015290 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15291
Takashi Iwai2134ea42008-01-10 16:53:55 +010015292 spec->vmaster_nid = 0x03;
15293
Kailang Yangdf694da2005-12-05 19:42:22 +010015294 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015295 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015296 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015297#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015298 spec->power_hook = alc_power_eapd;
15299#endif
15300 }
15301#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015302 if (!spec->loopback.amplist)
15303 spec->loopback.amplist = alc861_loopbacks;
15304#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015305
Kailang Yangdf694da2005-12-05 19:42:22 +010015306 return 0;
15307}
15308
15309/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015310 * ALC861-VD support
15311 *
15312 * Based on ALC882
15313 *
15314 * In addition, an independent DAC
15315 */
15316#define ALC861VD_DIGOUT_NID 0x06
15317
15318static hda_nid_t alc861vd_dac_nids[4] = {
15319 /* front, surr, clfe, side surr */
15320 0x02, 0x03, 0x04, 0x05
15321};
15322
15323/* dac_nids for ALC660vd are in a different order - according to
15324 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015325 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015326 * of ALC660vd codecs, but for now there is only 3stack mixer
15327 * - and it is the same as in 861vd.
15328 * adc_nids in ALC660vd are (is) the same as in 861vd
15329 */
15330static hda_nid_t alc660vd_dac_nids[3] = {
15331 /* front, rear, clfe, rear_surr */
15332 0x02, 0x04, 0x03
15333};
15334
15335static hda_nid_t alc861vd_adc_nids[1] = {
15336 /* ADC0 */
15337 0x09,
15338};
15339
Takashi Iwaie1406342008-02-11 18:32:32 +010015340static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15341
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015342/* input MUX */
15343/* FIXME: should be a matrix-type input source selection */
15344static struct hda_input_mux alc861vd_capture_source = {
15345 .num_items = 4,
15346 .items = {
15347 { "Mic", 0x0 },
15348 { "Front Mic", 0x1 },
15349 { "Line", 0x2 },
15350 { "CD", 0x4 },
15351 },
15352};
15353
Kailang Yang272a5272007-05-14 11:00:38 +020015354static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015355 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015356 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015357 { "Ext Mic", 0x0 },
15358 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015359 },
15360};
15361
Kailang Yangd1a991a2007-08-15 16:21:59 +020015362static struct hda_input_mux alc861vd_hp_capture_source = {
15363 .num_items = 2,
15364 .items = {
15365 { "Front Mic", 0x0 },
15366 { "ATAPI Mic", 0x1 },
15367 },
15368};
15369
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015370/*
15371 * 2ch mode
15372 */
15373static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15374 { 2, NULL }
15375};
15376
15377/*
15378 * 6ch mode
15379 */
15380static struct hda_verb alc861vd_6stack_ch6_init[] = {
15381 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15382 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15383 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15384 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15385 { } /* end */
15386};
15387
15388/*
15389 * 8ch mode
15390 */
15391static struct hda_verb alc861vd_6stack_ch8_init[] = {
15392 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15393 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15394 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15395 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15396 { } /* end */
15397};
15398
15399static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15400 { 6, alc861vd_6stack_ch6_init },
15401 { 8, alc861vd_6stack_ch8_init },
15402};
15403
15404static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15405 {
15406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15407 .name = "Channel Mode",
15408 .info = alc_ch_mode_info,
15409 .get = alc_ch_mode_get,
15410 .put = alc_ch_mode_put,
15411 },
15412 { } /* end */
15413};
15414
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015415/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15416 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15417 */
15418static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15419 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15420 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15421
15422 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15423 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15424
15425 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15426 HDA_OUTPUT),
15427 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15428 HDA_OUTPUT),
15429 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15430 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15431
15432 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15433 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15434
15435 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15436
15437 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15440
15441 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15442 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15443 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15444
15445 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15446 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15447
15448 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15449 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15450
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015451 { } /* end */
15452};
15453
15454static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15455 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15456 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15457
15458 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15459
15460 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15463
15464 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15465 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15466 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15467
15468 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15469 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15470
15471 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15472 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15473
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015474 { } /* end */
15475};
15476
Kailang Yangbdd148a2007-05-08 15:19:08 +020015477static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15478 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15479 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15480 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15481
15482 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15483
15484 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15487
15488 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15489 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15490 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15491
15492 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15493 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15494
15495 { } /* end */
15496};
15497
Tobin Davisb419f342008-03-07 11:57:51 +010015498/* Pin assignment: Speaker=0x14, HP = 0x15,
15499 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015500 */
15501static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015502 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15503 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015504 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15505 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015506 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15507 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15508 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15509 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15510 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15511 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015512 { } /* end */
15513};
15514
Kailang Yangd1a991a2007-08-15 16:21:59 +020015515/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15516 * Front Mic=0x18, ATAPI Mic = 0x19,
15517 */
15518static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15519 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15520 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15521 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15522 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15523 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15524 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15525 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15526 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015527
Kailang Yangd1a991a2007-08-15 16:21:59 +020015528 { } /* end */
15529};
15530
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015531/*
15532 * generic initialization of ADC, input mixers and output mixers
15533 */
15534static struct hda_verb alc861vd_volume_init_verbs[] = {
15535 /*
15536 * Unmute ADC0 and set the default input to mic-in
15537 */
15538 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15539 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15540
15541 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15542 * the analog-loopback mixer widget
15543 */
15544 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015550
15551 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015552 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015556
15557 /*
15558 * Set up output mixers (0x02 - 0x05)
15559 */
15560 /* set vol=0 to output mixers */
15561 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15562 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15563 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15564 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15565
15566 /* set up input amps for analog loopback */
15567 /* Amp Indices: DAC = 0, mixer = 1 */
15568 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15570 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15571 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15572 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15573 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15574 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15575 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15576
15577 { }
15578};
15579
15580/*
15581 * 3-stack pin configuration:
15582 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15583 */
15584static struct hda_verb alc861vd_3stack_init_verbs[] = {
15585 /*
15586 * Set pin mode and muting
15587 */
15588 /* set front pin widgets 0x14 for output */
15589 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15590 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15591 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15592
15593 /* Mic (rear) pin: input vref at 80% */
15594 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15595 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15596 /* Front Mic pin: input vref at 80% */
15597 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15598 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15599 /* Line In pin: input */
15600 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15602 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15603 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15604 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15605 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15606 /* CD pin widget for input */
15607 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15608
15609 { }
15610};
15611
15612/*
15613 * 6-stack pin configuration:
15614 */
15615static struct hda_verb alc861vd_6stack_init_verbs[] = {
15616 /*
15617 * Set pin mode and muting
15618 */
15619 /* set front pin widgets 0x14 for output */
15620 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15621 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15622 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15623
15624 /* Rear Pin: output 1 (0x0d) */
15625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15626 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15627 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15628 /* CLFE Pin: output 2 (0x0e) */
15629 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15630 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15631 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15632 /* Side Pin: output 3 (0x0f) */
15633 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15634 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15635 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15636
15637 /* Mic (rear) pin: input vref at 80% */
15638 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15639 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15640 /* Front Mic pin: input vref at 80% */
15641 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15642 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15643 /* Line In pin: input */
15644 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15645 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15646 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15648 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15649 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15650 /* CD pin widget for input */
15651 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15652
15653 { }
15654};
15655
Kailang Yangbdd148a2007-05-08 15:19:08 +020015656static struct hda_verb alc861vd_eapd_verbs[] = {
15657 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15658 { }
15659};
15660
Kailang Yangf9423e72008-05-27 12:32:25 +020015661static struct hda_verb alc660vd_eapd_verbs[] = {
15662 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15663 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15664 { }
15665};
15666
Kailang Yangbdd148a2007-05-08 15:19:08 +020015667static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15670 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15671 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015672 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015673 {}
15674};
15675
Kailang Yangbdd148a2007-05-08 15:19:08 +020015676static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15677{
15678 unsigned int present;
15679 unsigned char bits;
15680
Wu Fengguang864f92b2009-11-18 12:38:02 +080015681 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015682 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015683
Takashi Iwai47fd8302007-08-10 17:11:07 +020015684 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15685 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015686}
15687
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015688static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015689{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015690 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015691 spec->autocfg.hp_pins[0] = 0x1b;
15692 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015693}
15694
15695static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15696{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015697 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015698 alc861vd_lenovo_mic_automute(codec);
15699}
15700
15701static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15702 unsigned int res)
15703{
15704 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015705 case ALC880_MIC_EVENT:
15706 alc861vd_lenovo_mic_automute(codec);
15707 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015708 default:
15709 alc_automute_amp_unsol_event(codec, res);
15710 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015711 }
15712}
15713
Kailang Yang272a5272007-05-14 11:00:38 +020015714static struct hda_verb alc861vd_dallas_verbs[] = {
15715 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15716 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15717 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15718 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15719
15720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15726 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015728
Kailang Yang272a5272007-05-14 11:00:38 +020015729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15730 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15732 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15733 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15734 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15735 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15736 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15737
15738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15742 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15743 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15744 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15745 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15746
15747 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15751
15752 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015753 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015754 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15755
15756 { } /* end */
15757};
15758
15759/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015760static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015761{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015762 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015763
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015764 spec->autocfg.hp_pins[0] = 0x15;
15765 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015766}
15767
Takashi Iwaicb53c622007-08-10 17:21:45 +020015768#ifdef CONFIG_SND_HDA_POWER_SAVE
15769#define alc861vd_loopbacks alc880_loopbacks
15770#endif
15771
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015772/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015773#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15774#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15775#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15776#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15777
15778/*
15779 * configuration and preset
15780 */
15781static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15782 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015783 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015784 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015785 [ALC861VD_3ST] = "3stack",
15786 [ALC861VD_3ST_DIG] = "3stack-digout",
15787 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015788 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015789 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015790 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015791 [ALC861VD_AUTO] = "auto",
15792};
15793
15794static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015795 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15796 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015797 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015798 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015799 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015800 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015801 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015802 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015803 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015804 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015805 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015806 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015807 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015808 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015809 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015810 {}
15811};
15812
15813static struct alc_config_preset alc861vd_presets[] = {
15814 [ALC660VD_3ST] = {
15815 .mixers = { alc861vd_3st_mixer },
15816 .init_verbs = { alc861vd_volume_init_verbs,
15817 alc861vd_3stack_init_verbs },
15818 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15819 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015820 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15821 .channel_mode = alc861vd_3stack_2ch_modes,
15822 .input_mux = &alc861vd_capture_source,
15823 },
Mike Crash6963f842007-06-25 12:12:51 +020015824 [ALC660VD_3ST_DIG] = {
15825 .mixers = { alc861vd_3st_mixer },
15826 .init_verbs = { alc861vd_volume_init_verbs,
15827 alc861vd_3stack_init_verbs },
15828 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15829 .dac_nids = alc660vd_dac_nids,
15830 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015831 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15832 .channel_mode = alc861vd_3stack_2ch_modes,
15833 .input_mux = &alc861vd_capture_source,
15834 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015835 [ALC861VD_3ST] = {
15836 .mixers = { alc861vd_3st_mixer },
15837 .init_verbs = { alc861vd_volume_init_verbs,
15838 alc861vd_3stack_init_verbs },
15839 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15840 .dac_nids = alc861vd_dac_nids,
15841 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15842 .channel_mode = alc861vd_3stack_2ch_modes,
15843 .input_mux = &alc861vd_capture_source,
15844 },
15845 [ALC861VD_3ST_DIG] = {
15846 .mixers = { alc861vd_3st_mixer },
15847 .init_verbs = { alc861vd_volume_init_verbs,
15848 alc861vd_3stack_init_verbs },
15849 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15850 .dac_nids = alc861vd_dac_nids,
15851 .dig_out_nid = ALC861VD_DIGOUT_NID,
15852 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15853 .channel_mode = alc861vd_3stack_2ch_modes,
15854 .input_mux = &alc861vd_capture_source,
15855 },
15856 [ALC861VD_6ST_DIG] = {
15857 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15858 .init_verbs = { alc861vd_volume_init_verbs,
15859 alc861vd_6stack_init_verbs },
15860 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15861 .dac_nids = alc861vd_dac_nids,
15862 .dig_out_nid = ALC861VD_DIGOUT_NID,
15863 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15864 .channel_mode = alc861vd_6stack_modes,
15865 .input_mux = &alc861vd_capture_source,
15866 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015867 [ALC861VD_LENOVO] = {
15868 .mixers = { alc861vd_lenovo_mixer },
15869 .init_verbs = { alc861vd_volume_init_verbs,
15870 alc861vd_3stack_init_verbs,
15871 alc861vd_eapd_verbs,
15872 alc861vd_lenovo_unsol_verbs },
15873 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15874 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015875 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15876 .channel_mode = alc861vd_3stack_2ch_modes,
15877 .input_mux = &alc861vd_capture_source,
15878 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015879 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015880 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015881 },
Kailang Yang272a5272007-05-14 11:00:38 +020015882 [ALC861VD_DALLAS] = {
15883 .mixers = { alc861vd_dallas_mixer },
15884 .init_verbs = { alc861vd_dallas_verbs },
15885 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15886 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015887 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15888 .channel_mode = alc861vd_3stack_2ch_modes,
15889 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015890 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015891 .setup = alc861vd_dallas_setup,
15892 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015893 },
15894 [ALC861VD_HP] = {
15895 .mixers = { alc861vd_hp_mixer },
15896 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15897 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15898 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015899 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015900 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15901 .channel_mode = alc861vd_3stack_2ch_modes,
15902 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015903 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015904 .setup = alc861vd_dallas_setup,
15905 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015906 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015907 [ALC660VD_ASUS_V1S] = {
15908 .mixers = { alc861vd_lenovo_mixer },
15909 .init_verbs = { alc861vd_volume_init_verbs,
15910 alc861vd_3stack_init_verbs,
15911 alc861vd_eapd_verbs,
15912 alc861vd_lenovo_unsol_verbs },
15913 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15914 .dac_nids = alc660vd_dac_nids,
15915 .dig_out_nid = ALC861VD_DIGOUT_NID,
15916 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15917 .channel_mode = alc861vd_3stack_2ch_modes,
15918 .input_mux = &alc861vd_capture_source,
15919 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015920 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015921 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015922 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015923};
15924
15925/*
15926 * BIOS auto configuration
15927 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015928static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15929 const struct auto_pin_cfg *cfg)
15930{
Kailang Yang6227cdc2010-02-25 08:36:52 +010015931 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015932}
15933
15934
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015935static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15936 hda_nid_t nid, int pin_type, int dac_idx)
15937{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015938 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015939}
15940
15941static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15942{
15943 struct alc_spec *spec = codec->spec;
15944 int i;
15945
15946 for (i = 0; i <= HDA_SIDE; i++) {
15947 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015948 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015949 if (nid)
15950 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015951 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015952 }
15953}
15954
15955
15956static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15957{
15958 struct alc_spec *spec = codec->spec;
15959 hda_nid_t pin;
15960
15961 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015962 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015963 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015964 pin = spec->autocfg.speaker_pins[0];
15965 if (pin)
15966 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015967}
15968
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015969#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15970
15971static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15972{
15973 struct alc_spec *spec = codec->spec;
15974 int i;
15975
15976 for (i = 0; i < AUTO_PIN_LAST; i++) {
15977 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015978 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015979 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015980 if (nid != ALC861VD_PIN_CD_NID &&
15981 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015982 snd_hda_codec_write(codec, nid, 0,
15983 AC_VERB_SET_AMP_GAIN_MUTE,
15984 AMP_OUT_MUTE);
15985 }
15986 }
15987}
15988
Takashi Iwaif511b012008-08-15 16:46:42 +020015989#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15990
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015991#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15992#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15993
15994/* add playback controls from the parsed DAC table */
15995/* Based on ALC880 version. But ALC861VD has separate,
15996 * different NIDs for mute/unmute switch and volume control */
15997static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15998 const struct auto_pin_cfg *cfg)
15999{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016000 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16001 hda_nid_t nid_v, nid_s;
16002 int i, err;
16003
16004 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016005 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016006 continue;
16007 nid_v = alc861vd_idx_to_mixer_vol(
16008 alc880_dac_to_idx(
16009 spec->multiout.dac_nids[i]));
16010 nid_s = alc861vd_idx_to_mixer_switch(
16011 alc880_dac_to_idx(
16012 spec->multiout.dac_nids[i]));
16013
16014 if (i == 2) {
16015 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016016 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16017 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016018 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16019 HDA_OUTPUT));
16020 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016021 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016022 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16023 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016024 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16025 HDA_OUTPUT));
16026 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016027 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016028 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16029 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016030 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16031 HDA_INPUT));
16032 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016033 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016034 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16035 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016036 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16037 HDA_INPUT));
16038 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016039 return err;
16040 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016041 const char *pfx;
16042 if (cfg->line_outs == 1 &&
16043 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16044 if (!cfg->hp_pins)
16045 pfx = "Speaker";
16046 else
16047 pfx = "PCM";
16048 } else
16049 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016050 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016051 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16052 HDA_OUTPUT));
16053 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016054 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016055 if (cfg->line_outs == 1 &&
16056 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16057 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016058 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016059 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016060 HDA_INPUT));
16061 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016062 return err;
16063 }
16064 }
16065 return 0;
16066}
16067
16068/* add playback controls for speaker and HP outputs */
16069/* Based on ALC880 version. But ALC861VD has separate,
16070 * different NIDs for mute/unmute switch and volume control */
16071static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16072 hda_nid_t pin, const char *pfx)
16073{
16074 hda_nid_t nid_v, nid_s;
16075 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016076
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016077 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016078 return 0;
16079
16080 if (alc880_is_fixed_pin(pin)) {
16081 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16082 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016083 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016084 spec->multiout.hp_nid = nid_v;
16085 else
16086 spec->multiout.extra_out_nid[0] = nid_v;
16087 /* control HP volume/switch on the output mixer amp */
16088 nid_v = alc861vd_idx_to_mixer_vol(
16089 alc880_fixed_pin_idx(pin));
16090 nid_s = alc861vd_idx_to_mixer_switch(
16091 alc880_fixed_pin_idx(pin));
16092
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016093 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016094 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16095 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016096 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016097 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016098 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16099 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016100 return err;
16101 } else if (alc880_is_multi_pin(pin)) {
16102 /* set manual connection */
16103 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016104 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016105 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16106 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016107 return err;
16108 }
16109 return 0;
16110}
16111
16112/* parse the BIOS configuration and set up the alc_spec
16113 * return 1 if successful, 0 if the proper config is not found,
16114 * or a negative error code
16115 * Based on ALC880 version - had to change it to override
16116 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16117static int alc861vd_parse_auto_config(struct hda_codec *codec)
16118{
16119 struct alc_spec *spec = codec->spec;
16120 int err;
16121 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16122
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016123 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16124 alc861vd_ignore);
16125 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016126 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016127 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016128 return 0; /* can't find valid BIOS pin config */
16129
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016130 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16131 if (err < 0)
16132 return err;
16133 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16134 if (err < 0)
16135 return err;
16136 err = alc861vd_auto_create_extra_out(spec,
16137 spec->autocfg.speaker_pins[0],
16138 "Speaker");
16139 if (err < 0)
16140 return err;
16141 err = alc861vd_auto_create_extra_out(spec,
16142 spec->autocfg.hp_pins[0],
16143 "Headphone");
16144 if (err < 0)
16145 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016146 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016147 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016148 return err;
16149
16150 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16151
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016152 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016153 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16154
Takashi Iwai603c4012008-07-30 15:01:44 +020016155 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016156 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016157
Takashi Iwaid88897e2008-10-31 15:01:37 +010016158 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016159
16160 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016161 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016162
Takashi Iwai776e1842007-08-29 15:07:11 +020016163 err = alc_auto_add_mic_boost(codec);
16164 if (err < 0)
16165 return err;
16166
Kailang Yang6227cdc2010-02-25 08:36:52 +010016167 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016168
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016169 return 1;
16170}
16171
16172/* additional initialization for auto-configuration model */
16173static void alc861vd_auto_init(struct hda_codec *codec)
16174{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016175 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016176 alc861vd_auto_init_multi_out(codec);
16177 alc861vd_auto_init_hp_out(codec);
16178 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016179 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016180 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016181 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016182}
16183
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016184enum {
16185 ALC660VD_FIX_ASUS_GPIO1
16186};
16187
16188/* reset GPIO1 */
16189static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16190 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16191 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16192 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16193 { }
16194};
16195
16196static const struct alc_fixup alc861vd_fixups[] = {
16197 [ALC660VD_FIX_ASUS_GPIO1] = {
16198 .verbs = alc660vd_fix_asus_gpio1_verbs,
16199 },
16200};
16201
16202static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16203 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16204 {}
16205};
16206
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016207static int patch_alc861vd(struct hda_codec *codec)
16208{
16209 struct alc_spec *spec;
16210 int err, board_config;
16211
16212 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16213 if (spec == NULL)
16214 return -ENOMEM;
16215
16216 codec->spec = spec;
16217
16218 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16219 alc861vd_models,
16220 alc861vd_cfg_tbl);
16221
16222 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016223 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16224 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016225 board_config = ALC861VD_AUTO;
16226 }
16227
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016228 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16229
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016230 if (board_config == ALC861VD_AUTO) {
16231 /* automatic parse from the BIOS config */
16232 err = alc861vd_parse_auto_config(codec);
16233 if (err < 0) {
16234 alc_free(codec);
16235 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016236 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016237 printk(KERN_INFO
16238 "hda_codec: Cannot set up configuration "
16239 "from BIOS. Using base mode...\n");
16240 board_config = ALC861VD_3ST;
16241 }
16242 }
16243
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016244 err = snd_hda_attach_beep_device(codec, 0x23);
16245 if (err < 0) {
16246 alc_free(codec);
16247 return err;
16248 }
16249
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016250 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016251 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016252
Kailang Yang2f893282008-05-27 12:14:47 +020016253 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016254 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016255 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016256 }
16257
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016258 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16259 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16260
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016261 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16262 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16263
Takashi Iwaidd704692009-08-11 08:45:11 +020016264 if (!spec->adc_nids) {
16265 spec->adc_nids = alc861vd_adc_nids;
16266 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16267 }
16268 if (!spec->capsrc_nids)
16269 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016270
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016271 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016272 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016273
Takashi Iwai2134ea42008-01-10 16:53:55 +010016274 spec->vmaster_nid = 0x02;
16275
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016276 codec->patch_ops = alc_patch_ops;
16277
16278 if (board_config == ALC861VD_AUTO)
16279 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016280#ifdef CONFIG_SND_HDA_POWER_SAVE
16281 if (!spec->loopback.amplist)
16282 spec->loopback.amplist = alc861vd_loopbacks;
16283#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016284
16285 return 0;
16286}
16287
16288/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016289 * ALC662 support
16290 *
16291 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16292 * configuration. Each pin widget can choose any input DACs and a mixer.
16293 * Each ADC is connected from a mixer of all inputs. This makes possible
16294 * 6-channel independent captures.
16295 *
16296 * In addition, an independent DAC for the multi-playback (not used in this
16297 * driver yet).
16298 */
16299#define ALC662_DIGOUT_NID 0x06
16300#define ALC662_DIGIN_NID 0x0a
16301
16302static hda_nid_t alc662_dac_nids[4] = {
16303 /* front, rear, clfe, rear_surr */
16304 0x02, 0x03, 0x04
16305};
16306
Kailang Yang622e84c2009-04-21 07:39:04 +020016307static hda_nid_t alc272_dac_nids[2] = {
16308 0x02, 0x03
16309};
16310
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016311static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016312 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016313 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016314};
Takashi Iwaie1406342008-02-11 18:32:32 +010016315
Kailang Yang622e84c2009-04-21 07:39:04 +020016316static hda_nid_t alc272_adc_nids[1] = {
16317 /* ADC1-2 */
16318 0x08,
16319};
16320
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016321static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016322static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16323
Takashi Iwaie1406342008-02-11 18:32:32 +010016324
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016325/* input MUX */
16326/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016327static struct hda_input_mux alc662_capture_source = {
16328 .num_items = 4,
16329 .items = {
16330 { "Mic", 0x0 },
16331 { "Front Mic", 0x1 },
16332 { "Line", 0x2 },
16333 { "CD", 0x4 },
16334 },
16335};
16336
16337static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16338 .num_items = 2,
16339 .items = {
16340 { "Mic", 0x1 },
16341 { "Line", 0x2 },
16342 },
16343};
Kailang Yang291702f2007-10-16 14:28:03 +020016344
Kailang Yang6dda9f42008-05-27 12:05:31 +020016345static struct hda_input_mux alc663_capture_source = {
16346 .num_items = 3,
16347 .items = {
16348 { "Mic", 0x0 },
16349 { "Front Mic", 0x1 },
16350 { "Line", 0x2 },
16351 },
16352};
16353
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016354#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016355static struct hda_input_mux alc272_nc10_capture_source = {
16356 .num_items = 16,
16357 .items = {
16358 { "Autoselect Mic", 0x0 },
16359 { "Internal Mic", 0x1 },
16360 { "In-0x02", 0x2 },
16361 { "In-0x03", 0x3 },
16362 { "In-0x04", 0x4 },
16363 { "In-0x05", 0x5 },
16364 { "In-0x06", 0x6 },
16365 { "In-0x07", 0x7 },
16366 { "In-0x08", 0x8 },
16367 { "In-0x09", 0x9 },
16368 { "In-0x0a", 0x0a },
16369 { "In-0x0b", 0x0b },
16370 { "In-0x0c", 0x0c },
16371 { "In-0x0d", 0x0d },
16372 { "In-0x0e", 0x0e },
16373 { "In-0x0f", 0x0f },
16374 },
16375};
16376#endif
16377
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016378/*
16379 * 2ch mode
16380 */
16381static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16382 { 2, NULL }
16383};
16384
16385/*
16386 * 2ch mode
16387 */
16388static struct hda_verb alc662_3ST_ch2_init[] = {
16389 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16390 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16391 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16392 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16393 { } /* end */
16394};
16395
16396/*
16397 * 6ch mode
16398 */
16399static struct hda_verb alc662_3ST_ch6_init[] = {
16400 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16401 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16402 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16403 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16404 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16405 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16406 { } /* end */
16407};
16408
16409static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16410 { 2, alc662_3ST_ch2_init },
16411 { 6, alc662_3ST_ch6_init },
16412};
16413
16414/*
16415 * 2ch mode
16416 */
16417static struct hda_verb alc662_sixstack_ch6_init[] = {
16418 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16419 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16420 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16421 { } /* end */
16422};
16423
16424/*
16425 * 6ch mode
16426 */
16427static struct hda_verb alc662_sixstack_ch8_init[] = {
16428 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16429 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16430 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16431 { } /* end */
16432};
16433
16434static struct hda_channel_mode alc662_5stack_modes[2] = {
16435 { 2, alc662_sixstack_ch6_init },
16436 { 6, alc662_sixstack_ch8_init },
16437};
16438
16439/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16440 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16441 */
16442
16443static struct snd_kcontrol_new alc662_base_mixer[] = {
16444 /* output mixer control */
16445 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016446 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016448 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016451 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16452 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16454
16455 /*Input mixer control */
16456 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16457 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16458 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16459 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16460 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16461 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16462 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16463 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016464 { } /* end */
16465};
16466
16467static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16468 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016469 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16471 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16472 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16473 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16474 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16476 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16477 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16478 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016479 { } /* end */
16480};
16481
16482static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16483 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016484 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016485 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016486 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016487 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16488 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016489 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16490 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016491 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16492 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16493 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16494 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16495 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16498 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16499 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016500 { } /* end */
16501};
16502
16503static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16504 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16505 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016506 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16507 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016508 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16509 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16510 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016513 { } /* end */
16514};
16515
Kailang Yang291702f2007-10-16 14:28:03 +020016516static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016517 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16518 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016519
16520 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16521 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16522 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16523
16524 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16525 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16526 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16527 { } /* end */
16528};
16529
Kailang Yang8c427222008-01-10 13:03:59 +010016530static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016531 ALC262_HIPPO_MASTER_SWITCH,
16532 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016533 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016534 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16535 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016536 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16537 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16538 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16541 { } /* end */
16542};
16543
Kailang Yangf1d4e282008-08-26 14:03:29 +020016544static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16545 .ops = &snd_hda_bind_vol,
16546 .values = {
16547 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16548 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16549 0
16550 },
16551};
16552
16553static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16554 .ops = &snd_hda_bind_sw,
16555 .values = {
16556 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16557 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16558 0
16559 },
16560};
16561
Kailang Yang6dda9f42008-05-27 12:05:31 +020016562static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016563 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16564 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16565 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16566 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16567 { } /* end */
16568};
16569
16570static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16571 .ops = &snd_hda_bind_sw,
16572 .values = {
16573 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16574 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16575 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16576 0
16577 },
16578};
16579
16580static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16581 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16582 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16583 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16584 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16585 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16586 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16587
16588 { } /* end */
16589};
16590
16591static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16592 .ops = &snd_hda_bind_sw,
16593 .values = {
16594 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16595 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16596 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16597 0
16598 },
16599};
16600
16601static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16602 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16603 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16606 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16607 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16608 { } /* end */
16609};
16610
16611static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016612 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16613 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016614 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16617 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16618 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16619 { } /* end */
16620};
16621
16622static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16623 .ops = &snd_hda_bind_vol,
16624 .values = {
16625 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16626 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16627 0
16628 },
16629};
16630
16631static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16632 .ops = &snd_hda_bind_sw,
16633 .values = {
16634 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16635 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16636 0
16637 },
16638};
16639
16640static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16641 HDA_BIND_VOL("Master Playback Volume",
16642 &alc663_asus_two_bind_master_vol),
16643 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16644 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016645 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16647 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016648 { } /* end */
16649};
16650
16651static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16652 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16653 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16654 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16655 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16656 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16657 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016658 { } /* end */
16659};
16660
16661static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16662 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16663 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16664 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16665 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16666 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16667
16668 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16670 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16671 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16672 { } /* end */
16673};
16674
16675static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16676 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16677 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16679
16680 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16681 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16682 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16683 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16684 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16685 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16686 { } /* end */
16687};
16688
Kailang Yangebb83ee2009-12-17 12:23:00 +010016689static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16690 .ops = &snd_hda_bind_sw,
16691 .values = {
16692 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16693 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16694 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16695 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16696 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16697 0
16698 },
16699};
16700
16701static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16702 .ops = &snd_hda_bind_sw,
16703 .values = {
16704 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16705 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16706 0
16707 },
16708};
16709
16710static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16711 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16712 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16713 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16714 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16715 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16716 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16717 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16718 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16719 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16720 { } /* end */
16721};
16722
16723static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16724 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16725 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16726 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16727 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16728 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16729 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16731 { } /* end */
16732};
16733
16734
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016735static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16736 {
16737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16738 .name = "Channel Mode",
16739 .info = alc_ch_mode_info,
16740 .get = alc_ch_mode_get,
16741 .put = alc_ch_mode_put,
16742 },
16743 { } /* end */
16744};
16745
16746static struct hda_verb alc662_init_verbs[] = {
16747 /* ADC: mute amp left and right */
16748 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16749 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016750
Kailang Yangb60dd392007-09-20 12:50:29 +020016751 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16753 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16755 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016757
16758 /* Front Pin: output 0 (0x0c) */
16759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16760 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16761
16762 /* Rear Pin: output 1 (0x0d) */
16763 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16764 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16765
16766 /* CLFE Pin: output 2 (0x0e) */
16767 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16768 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16769
16770 /* Mic (rear) pin: input vref at 80% */
16771 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16772 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16773 /* Front Mic pin: input vref at 80% */
16774 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16775 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16776 /* Line In pin: input */
16777 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16778 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16779 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16782 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16783 /* CD pin widget for input */
16784 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16785
16786 /* FIXME: use matrix-type input source selection */
16787 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16788 /* Input mixer */
16789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016790 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016791
16792 /* always trun on EAPD */
16793 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16794 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16795
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016796 { }
16797};
16798
Kailang Yangcec27c82010-02-04 14:18:18 +010016799static struct hda_verb alc663_init_verbs[] = {
16800 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16801 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16802 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16803 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16805 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16806 { }
16807};
16808
16809static struct hda_verb alc272_init_verbs[] = {
16810 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16811 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16812 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16813 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16814 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16815 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16816 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16818 { }
16819};
16820
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016821static struct hda_verb alc662_sue_init_verbs[] = {
16822 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16823 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016824 {}
16825};
16826
16827static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16828 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16829 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16830 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016831};
16832
Kailang Yang8c427222008-01-10 13:03:59 +010016833/* Set Unsolicited Event*/
16834static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16835 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16836 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16837 {}
16838};
16839
Kailang Yang6dda9f42008-05-27 12:05:31 +020016840static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016841 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16842 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016843 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16844 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016845 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16846 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016848 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16849 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16850 {}
16851};
16852
Kailang Yangf1d4e282008-08-26 14:03:29 +020016853static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16854 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16855 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16856 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16859 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16860 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16861 {}
16862};
16863
16864static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16866 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16867 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16868 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16871 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16872 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16873 {}
16874};
16875
16876static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16878 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16880 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16882 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16883 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16884 {}
16885};
16886
16887static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16888 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16889 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16890 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16891 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16893 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16894 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16895 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16897 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16898 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16899 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16900 {}
16901};
16902
16903static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16904 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16905 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16906 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16907 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16908 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16909 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16910 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16911 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16913 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16914 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16915 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16916 {}
16917};
16918
Kailang Yang6dda9f42008-05-27 12:05:31 +020016919static struct hda_verb alc663_g71v_init_verbs[] = {
16920 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16921 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16922 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16923
16924 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16925 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16926 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16927
16928 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16929 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16930 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16931 {}
16932};
16933
16934static struct hda_verb alc663_g50v_init_verbs[] = {
16935 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16936 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16937 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16938
16939 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16940 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16941 {}
16942};
16943
Kailang Yangf1d4e282008-08-26 14:03:29 +020016944static struct hda_verb alc662_ecs_init_verbs[] = {
16945 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16947 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16948 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16949 {}
16950};
16951
Kailang Yang622e84c2009-04-21 07:39:04 +020016952static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16954 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16955 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16956 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16957 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16958 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16959 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16960 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16962 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16963 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16964 {}
16965};
16966
16967static struct hda_verb alc272_dell_init_verbs[] = {
16968 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16969 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16971 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16972 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16973 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16974 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16975 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16977 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16978 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16979 {}
16980};
16981
Kailang Yangebb83ee2009-12-17 12:23:00 +010016982static struct hda_verb alc663_mode7_init_verbs[] = {
16983 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16984 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16985 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16986 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16988 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16989 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16990 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16991 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16992 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16993 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16995 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16996 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16997 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16998 {}
16999};
17000
17001static struct hda_verb alc663_mode8_init_verbs[] = {
17002 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17006 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17007 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17008 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17009 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17010 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17011 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17012 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17013 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17015 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17016 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17017 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17018 {}
17019};
17020
Kailang Yangf1d4e282008-08-26 14:03:29 +020017021static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17022 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17023 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17024 { } /* end */
17025};
17026
Kailang Yang622e84c2009-04-21 07:39:04 +020017027static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17028 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17029 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17030 { } /* end */
17031};
17032
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017033static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17034{
17035 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017036 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017037
Wu Fengguang864f92b2009-11-18 12:38:02 +080017038 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017039 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017040
Takashi Iwai47fd8302007-08-10 17:11:07 +020017041 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17042 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017043}
17044
17045static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17046{
17047 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017048 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017049
Wu Fengguang864f92b2009-11-18 12:38:02 +080017050 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017051 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017052
Takashi Iwai47fd8302007-08-10 17:11:07 +020017053 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17054 HDA_AMP_MUTE, bits);
17055 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17056 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017057}
17058
17059static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17060 unsigned int res)
17061{
17062 if ((res >> 26) == ALC880_HP_EVENT)
17063 alc662_lenovo_101e_all_automute(codec);
17064 if ((res >> 26) == ALC880_FRONT_EVENT)
17065 alc662_lenovo_101e_ispeaker_automute(codec);
17066}
17067
Kailang Yang291702f2007-10-16 14:28:03 +020017068/* unsolicited event for HP jack sensing */
17069static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17070 unsigned int res)
17071{
Kailang Yang291702f2007-10-16 14:28:03 +020017072 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017073 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017074 else
17075 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017076}
17077
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017078static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017079{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017080 struct alc_spec *spec = codec->spec;
17081
17082 alc262_hippo1_setup(codec);
17083 spec->ext_mic.pin = 0x18;
17084 spec->ext_mic.mux_idx = 0;
17085 spec->int_mic.pin = 0x19;
17086 spec->int_mic.mux_idx = 1;
17087 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017088}
17089
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017090static void alc662_eeepc_inithook(struct hda_codec *codec)
17091{
17092 alc262_hippo_automute(codec);
17093 alc_mic_automute(codec);
17094}
17095
17096static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017097{
Takashi Iwai42171c12009-05-08 14:11:43 +020017098 struct alc_spec *spec = codec->spec;
17099
17100 spec->autocfg.hp_pins[0] = 0x14;
17101 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017102}
17103
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017104#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17105
Kailang Yang6dda9f42008-05-27 12:05:31 +020017106static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17107{
17108 unsigned int present;
17109 unsigned char bits;
17110
Wu Fengguang864f92b2009-11-18 12:38:02 +080017111 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017112 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017113 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17114 AMP_IN_MUTE(0), bits);
17115 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17116 AMP_IN_MUTE(0), bits);
17117}
17118
17119static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17120{
17121 unsigned int present;
17122 unsigned char bits;
17123
Wu Fengguang864f92b2009-11-18 12:38:02 +080017124 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017125 bits = present ? HDA_AMP_MUTE : 0;
17126 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17127 AMP_IN_MUTE(0), bits);
17128 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17129 AMP_IN_MUTE(0), bits);
17130 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17131 AMP_IN_MUTE(0), bits);
17132 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17133 AMP_IN_MUTE(0), bits);
17134}
17135
17136static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17137{
17138 unsigned int present;
17139 unsigned char bits;
17140
Wu Fengguang864f92b2009-11-18 12:38:02 +080017141 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017142 bits = present ? HDA_AMP_MUTE : 0;
17143 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17144 AMP_IN_MUTE(0), bits);
17145 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17146 AMP_IN_MUTE(0), bits);
17147 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17148 AMP_IN_MUTE(0), bits);
17149 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17150 AMP_IN_MUTE(0), bits);
17151}
17152
17153static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17154{
17155 unsigned int present;
17156 unsigned char bits;
17157
Wu Fengguang864f92b2009-11-18 12:38:02 +080017158 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017159 bits = present ? 0 : PIN_OUT;
17160 snd_hda_codec_write(codec, 0x14, 0,
17161 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17162}
17163
17164static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17165{
17166 unsigned int present1, present2;
17167
Wu Fengguang864f92b2009-11-18 12:38:02 +080017168 present1 = snd_hda_jack_detect(codec, 0x21);
17169 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017170
17171 if (present1 || present2) {
17172 snd_hda_codec_write_cache(codec, 0x14, 0,
17173 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17174 } else {
17175 snd_hda_codec_write_cache(codec, 0x14, 0,
17176 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17177 }
17178}
17179
17180static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17181{
17182 unsigned int present1, present2;
17183
Wu Fengguang864f92b2009-11-18 12:38:02 +080017184 present1 = snd_hda_jack_detect(codec, 0x1b);
17185 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017186
17187 if (present1 || present2) {
17188 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17189 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17190 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17191 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17192 } else {
17193 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17194 AMP_IN_MUTE(0), 0);
17195 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17196 AMP_IN_MUTE(0), 0);
17197 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017198}
17199
Kailang Yangebb83ee2009-12-17 12:23:00 +010017200static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17201{
17202 unsigned int present1, present2;
17203
17204 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17205 AC_VERB_GET_PIN_SENSE, 0)
17206 & AC_PINSENSE_PRESENCE;
17207 present2 = snd_hda_codec_read(codec, 0x21, 0,
17208 AC_VERB_GET_PIN_SENSE, 0)
17209 & AC_PINSENSE_PRESENCE;
17210
17211 if (present1 || present2) {
17212 snd_hda_codec_write_cache(codec, 0x14, 0,
17213 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17214 snd_hda_codec_write_cache(codec, 0x17, 0,
17215 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17216 } else {
17217 snd_hda_codec_write_cache(codec, 0x14, 0,
17218 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17219 snd_hda_codec_write_cache(codec, 0x17, 0,
17220 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17221 }
17222}
17223
17224static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17225{
17226 unsigned int present1, present2;
17227
17228 present1 = snd_hda_codec_read(codec, 0x21, 0,
17229 AC_VERB_GET_PIN_SENSE, 0)
17230 & AC_PINSENSE_PRESENCE;
17231 present2 = snd_hda_codec_read(codec, 0x15, 0,
17232 AC_VERB_GET_PIN_SENSE, 0)
17233 & AC_PINSENSE_PRESENCE;
17234
17235 if (present1 || present2) {
17236 snd_hda_codec_write_cache(codec, 0x14, 0,
17237 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17238 snd_hda_codec_write_cache(codec, 0x17, 0,
17239 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17240 } else {
17241 snd_hda_codec_write_cache(codec, 0x14, 0,
17242 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17243 snd_hda_codec_write_cache(codec, 0x17, 0,
17244 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17245 }
17246}
17247
Kailang Yang6dda9f42008-05-27 12:05:31 +020017248static void alc663_m51va_unsol_event(struct hda_codec *codec,
17249 unsigned int res)
17250{
17251 switch (res >> 26) {
17252 case ALC880_HP_EVENT:
17253 alc663_m51va_speaker_automute(codec);
17254 break;
17255 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017256 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017257 break;
17258 }
17259}
17260
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017261static void alc663_m51va_setup(struct hda_codec *codec)
17262{
17263 struct alc_spec *spec = codec->spec;
17264 spec->ext_mic.pin = 0x18;
17265 spec->ext_mic.mux_idx = 0;
17266 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017267 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017268 spec->auto_mic = 1;
17269}
17270
Kailang Yang6dda9f42008-05-27 12:05:31 +020017271static void alc663_m51va_inithook(struct hda_codec *codec)
17272{
17273 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017274 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017275}
17276
Kailang Yangf1d4e282008-08-26 14:03:29 +020017277/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017278#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017279
17280static void alc663_mode1_setup(struct hda_codec *codec)
17281{
17282 struct alc_spec *spec = codec->spec;
17283 spec->ext_mic.pin = 0x18;
17284 spec->ext_mic.mux_idx = 0;
17285 spec->int_mic.pin = 0x19;
17286 spec->int_mic.mux_idx = 1;
17287 spec->auto_mic = 1;
17288}
17289
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017290#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017291
Kailang Yangf1d4e282008-08-26 14:03:29 +020017292/* ***************** Mode2 ******************************/
17293static void alc662_mode2_unsol_event(struct hda_codec *codec,
17294 unsigned int res)
17295{
17296 switch (res >> 26) {
17297 case ALC880_HP_EVENT:
17298 alc662_f5z_speaker_automute(codec);
17299 break;
17300 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017301 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017302 break;
17303 }
17304}
17305
Kailang Yangebb83ee2009-12-17 12:23:00 +010017306#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017307
Kailang Yangf1d4e282008-08-26 14:03:29 +020017308static void alc662_mode2_inithook(struct hda_codec *codec)
17309{
17310 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017311 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017312}
17313/* ***************** Mode3 ******************************/
17314static void alc663_mode3_unsol_event(struct hda_codec *codec,
17315 unsigned int res)
17316{
17317 switch (res >> 26) {
17318 case ALC880_HP_EVENT:
17319 alc663_two_hp_m1_speaker_automute(codec);
17320 break;
17321 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017322 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017323 break;
17324 }
17325}
17326
Kailang Yangebb83ee2009-12-17 12:23:00 +010017327#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017328
Kailang Yangf1d4e282008-08-26 14:03:29 +020017329static void alc663_mode3_inithook(struct hda_codec *codec)
17330{
17331 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017332 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017333}
17334/* ***************** Mode4 ******************************/
17335static void alc663_mode4_unsol_event(struct hda_codec *codec,
17336 unsigned int res)
17337{
17338 switch (res >> 26) {
17339 case ALC880_HP_EVENT:
17340 alc663_21jd_two_speaker_automute(codec);
17341 break;
17342 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017343 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017344 break;
17345 }
17346}
17347
Kailang Yangebb83ee2009-12-17 12:23:00 +010017348#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017349
Kailang Yangf1d4e282008-08-26 14:03:29 +020017350static void alc663_mode4_inithook(struct hda_codec *codec)
17351{
17352 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017353 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017354}
17355/* ***************** Mode5 ******************************/
17356static void alc663_mode5_unsol_event(struct hda_codec *codec,
17357 unsigned int res)
17358{
17359 switch (res >> 26) {
17360 case ALC880_HP_EVENT:
17361 alc663_15jd_two_speaker_automute(codec);
17362 break;
17363 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017364 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017365 break;
17366 }
17367}
17368
Kailang Yangebb83ee2009-12-17 12:23:00 +010017369#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017370
Kailang Yangf1d4e282008-08-26 14:03:29 +020017371static void alc663_mode5_inithook(struct hda_codec *codec)
17372{
17373 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017374 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017375}
17376/* ***************** Mode6 ******************************/
17377static void alc663_mode6_unsol_event(struct hda_codec *codec,
17378 unsigned int res)
17379{
17380 switch (res >> 26) {
17381 case ALC880_HP_EVENT:
17382 alc663_two_hp_m2_speaker_automute(codec);
17383 break;
17384 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017385 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017386 break;
17387 }
17388}
17389
Kailang Yangebb83ee2009-12-17 12:23:00 +010017390#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017391
Kailang Yangf1d4e282008-08-26 14:03:29 +020017392static void alc663_mode6_inithook(struct hda_codec *codec)
17393{
17394 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017395 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017396}
17397
Kailang Yangebb83ee2009-12-17 12:23:00 +010017398/* ***************** Mode7 ******************************/
17399static void alc663_mode7_unsol_event(struct hda_codec *codec,
17400 unsigned int res)
17401{
17402 switch (res >> 26) {
17403 case ALC880_HP_EVENT:
17404 alc663_two_hp_m7_speaker_automute(codec);
17405 break;
17406 case ALC880_MIC_EVENT:
17407 alc_mic_automute(codec);
17408 break;
17409 }
17410}
17411
17412#define alc663_mode7_setup alc663_mode1_setup
17413
17414static void alc663_mode7_inithook(struct hda_codec *codec)
17415{
17416 alc663_two_hp_m7_speaker_automute(codec);
17417 alc_mic_automute(codec);
17418}
17419
17420/* ***************** Mode8 ******************************/
17421static void alc663_mode8_unsol_event(struct hda_codec *codec,
17422 unsigned int res)
17423{
17424 switch (res >> 26) {
17425 case ALC880_HP_EVENT:
17426 alc663_two_hp_m8_speaker_automute(codec);
17427 break;
17428 case ALC880_MIC_EVENT:
17429 alc_mic_automute(codec);
17430 break;
17431 }
17432}
17433
17434#define alc663_mode8_setup alc663_m51va_setup
17435
17436static void alc663_mode8_inithook(struct hda_codec *codec)
17437{
17438 alc663_two_hp_m8_speaker_automute(codec);
17439 alc_mic_automute(codec);
17440}
17441
Kailang Yang6dda9f42008-05-27 12:05:31 +020017442static void alc663_g71v_hp_automute(struct hda_codec *codec)
17443{
17444 unsigned int present;
17445 unsigned char bits;
17446
Wu Fengguang864f92b2009-11-18 12:38:02 +080017447 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017448 bits = present ? HDA_AMP_MUTE : 0;
17449 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17450 HDA_AMP_MUTE, bits);
17451 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17452 HDA_AMP_MUTE, bits);
17453}
17454
17455static void alc663_g71v_front_automute(struct hda_codec *codec)
17456{
17457 unsigned int present;
17458 unsigned char bits;
17459
Wu Fengguang864f92b2009-11-18 12:38:02 +080017460 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017461 bits = present ? HDA_AMP_MUTE : 0;
17462 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17463 HDA_AMP_MUTE, bits);
17464}
17465
17466static void alc663_g71v_unsol_event(struct hda_codec *codec,
17467 unsigned int res)
17468{
17469 switch (res >> 26) {
17470 case ALC880_HP_EVENT:
17471 alc663_g71v_hp_automute(codec);
17472 break;
17473 case ALC880_FRONT_EVENT:
17474 alc663_g71v_front_automute(codec);
17475 break;
17476 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017477 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017478 break;
17479 }
17480}
17481
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017482#define alc663_g71v_setup alc663_m51va_setup
17483
Kailang Yang6dda9f42008-05-27 12:05:31 +020017484static void alc663_g71v_inithook(struct hda_codec *codec)
17485{
17486 alc663_g71v_front_automute(codec);
17487 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017488 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017489}
17490
17491static void alc663_g50v_unsol_event(struct hda_codec *codec,
17492 unsigned int res)
17493{
17494 switch (res >> 26) {
17495 case ALC880_HP_EVENT:
17496 alc663_m51va_speaker_automute(codec);
17497 break;
17498 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017499 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017500 break;
17501 }
17502}
17503
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017504#define alc663_g50v_setup alc663_m51va_setup
17505
Kailang Yang6dda9f42008-05-27 12:05:31 +020017506static void alc663_g50v_inithook(struct hda_codec *codec)
17507{
17508 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017509 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017510}
17511
Kailang Yangf1d4e282008-08-26 14:03:29 +020017512static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17513 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017514 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017515
17516 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17517 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17518 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17519
17520 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17521 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17522 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17523 { } /* end */
17524};
17525
Chris Pockelé9541ba12009-05-12 08:08:53 +020017526static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17527 /* Master Playback automatically created from Speaker and Headphone */
17528 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17529 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17530 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17531 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17532
17533 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17534 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17535 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17536
17537 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17538 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17539 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17540 { } /* end */
17541};
17542
Takashi Iwaicb53c622007-08-10 17:21:45 +020017543#ifdef CONFIG_SND_HDA_POWER_SAVE
17544#define alc662_loopbacks alc880_loopbacks
17545#endif
17546
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017547
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017548/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017549#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17550#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17551#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17552#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17553
17554/*
17555 * configuration and preset
17556 */
17557static const char *alc662_models[ALC662_MODEL_LAST] = {
17558 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17559 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17560 [ALC662_3ST_6ch] = "3stack-6ch",
17561 [ALC662_5ST_DIG] = "6stack-dig",
17562 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017563 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017564 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017565 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017566 [ALC663_ASUS_M51VA] = "m51va",
17567 [ALC663_ASUS_G71V] = "g71v",
17568 [ALC663_ASUS_H13] = "h13",
17569 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017570 [ALC663_ASUS_MODE1] = "asus-mode1",
17571 [ALC662_ASUS_MODE2] = "asus-mode2",
17572 [ALC663_ASUS_MODE3] = "asus-mode3",
17573 [ALC663_ASUS_MODE4] = "asus-mode4",
17574 [ALC663_ASUS_MODE5] = "asus-mode5",
17575 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017576 [ALC663_ASUS_MODE7] = "asus-mode7",
17577 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017578 [ALC272_DELL] = "dell",
17579 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017580 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017581 [ALC662_AUTO] = "auto",
17582};
17583
17584static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017585 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017586 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17587 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017588 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17589 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017590 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017591 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17592 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17593 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17594 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017595 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17596 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017597 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017598 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17599 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17600 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17601 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17602 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017603 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017604 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17605 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017606 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17607 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17608 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17609 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017610 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017611 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17612 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17613 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017614 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17615 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17616 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17617 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017618 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017619 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17620 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017621 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017622 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17623 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17624 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017625 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017626 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017627 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17628 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017629 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17630 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17631 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017632 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017633 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17634 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017635 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017636 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017637 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017638 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17639 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17640 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017641 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017642 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17643 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017644 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017645 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017646 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017647 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017648 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17649 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017650 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017651 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017652 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17653 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017654 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017655 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017656 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017657 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017658 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017659 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017660 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17661 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017662 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017663 {}
17664};
17665
17666static struct alc_config_preset alc662_presets[] = {
17667 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017668 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017669 .init_verbs = { alc662_init_verbs },
17670 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17671 .dac_nids = alc662_dac_nids,
17672 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017673 .dig_in_nid = ALC662_DIGIN_NID,
17674 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17675 .channel_mode = alc662_3ST_2ch_modes,
17676 .input_mux = &alc662_capture_source,
17677 },
17678 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017679 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017680 .init_verbs = { alc662_init_verbs },
17681 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17682 .dac_nids = alc662_dac_nids,
17683 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017684 .dig_in_nid = ALC662_DIGIN_NID,
17685 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17686 .channel_mode = alc662_3ST_6ch_modes,
17687 .need_dac_fix = 1,
17688 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017689 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017690 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017691 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017692 .init_verbs = { alc662_init_verbs },
17693 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17694 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017695 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17696 .channel_mode = alc662_3ST_6ch_modes,
17697 .need_dac_fix = 1,
17698 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017699 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017700 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017701 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017702 .init_verbs = { alc662_init_verbs },
17703 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17704 .dac_nids = alc662_dac_nids,
17705 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017706 .dig_in_nid = ALC662_DIGIN_NID,
17707 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17708 .channel_mode = alc662_5stack_modes,
17709 .input_mux = &alc662_capture_source,
17710 },
17711 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017712 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017713 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17714 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17715 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017716 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17717 .channel_mode = alc662_3ST_2ch_modes,
17718 .input_mux = &alc662_lenovo_101e_capture_source,
17719 .unsol_event = alc662_lenovo_101e_unsol_event,
17720 .init_hook = alc662_lenovo_101e_all_automute,
17721 },
Kailang Yang291702f2007-10-16 14:28:03 +020017722 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017723 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017724 .init_verbs = { alc662_init_verbs,
17725 alc662_eeepc_sue_init_verbs },
17726 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17727 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017728 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17729 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017730 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017731 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017732 .init_hook = alc662_eeepc_inithook,
17733 },
Kailang Yang8c427222008-01-10 13:03:59 +010017734 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017735 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017736 alc662_chmode_mixer },
17737 .init_verbs = { alc662_init_verbs,
17738 alc662_eeepc_ep20_sue_init_verbs },
17739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17740 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017741 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17742 .channel_mode = alc662_3ST_6ch_modes,
17743 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017744 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017745 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017746 .init_hook = alc662_eeepc_ep20_inithook,
17747 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017748 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017749 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017750 .init_verbs = { alc662_init_verbs,
17751 alc662_ecs_init_verbs },
17752 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17753 .dac_nids = alc662_dac_nids,
17754 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17755 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017756 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017757 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017758 .init_hook = alc662_eeepc_inithook,
17759 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017760 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017761 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017762 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17763 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17764 .dac_nids = alc662_dac_nids,
17765 .dig_out_nid = ALC662_DIGOUT_NID,
17766 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17767 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017768 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017769 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017770 .init_hook = alc663_m51va_inithook,
17771 },
17772 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017773 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017774 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17776 .dac_nids = alc662_dac_nids,
17777 .dig_out_nid = ALC662_DIGOUT_NID,
17778 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17779 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017780 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017781 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017782 .init_hook = alc663_g71v_inithook,
17783 },
17784 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017785 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017786 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17787 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17788 .dac_nids = alc662_dac_nids,
17789 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17790 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017791 .unsol_event = alc663_m51va_unsol_event,
17792 .init_hook = alc663_m51va_inithook,
17793 },
17794 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017795 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017796 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17797 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17798 .dac_nids = alc662_dac_nids,
17799 .dig_out_nid = ALC662_DIGOUT_NID,
17800 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17801 .channel_mode = alc662_3ST_6ch_modes,
17802 .input_mux = &alc663_capture_source,
17803 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017804 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017805 .init_hook = alc663_g50v_inithook,
17806 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017807 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017808 .mixers = { alc663_m51va_mixer },
17809 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017810 .init_verbs = { alc662_init_verbs,
17811 alc663_21jd_amic_init_verbs },
17812 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17813 .hp_nid = 0x03,
17814 .dac_nids = alc662_dac_nids,
17815 .dig_out_nid = ALC662_DIGOUT_NID,
17816 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17817 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017818 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017819 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017820 .init_hook = alc663_mode1_inithook,
17821 },
17822 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017823 .mixers = { alc662_1bjd_mixer },
17824 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017825 .init_verbs = { alc662_init_verbs,
17826 alc662_1bjd_amic_init_verbs },
17827 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17828 .dac_nids = alc662_dac_nids,
17829 .dig_out_nid = ALC662_DIGOUT_NID,
17830 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17831 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017832 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017833 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017834 .init_hook = alc662_mode2_inithook,
17835 },
17836 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017837 .mixers = { alc663_two_hp_m1_mixer },
17838 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017839 .init_verbs = { alc662_init_verbs,
17840 alc663_two_hp_amic_m1_init_verbs },
17841 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17842 .hp_nid = 0x03,
17843 .dac_nids = alc662_dac_nids,
17844 .dig_out_nid = ALC662_DIGOUT_NID,
17845 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17846 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017847 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017848 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017849 .init_hook = alc663_mode3_inithook,
17850 },
17851 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017852 .mixers = { alc663_asus_21jd_clfe_mixer },
17853 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017854 .init_verbs = { alc662_init_verbs,
17855 alc663_21jd_amic_init_verbs},
17856 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17857 .hp_nid = 0x03,
17858 .dac_nids = alc662_dac_nids,
17859 .dig_out_nid = ALC662_DIGOUT_NID,
17860 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17861 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017862 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017863 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017864 .init_hook = alc663_mode4_inithook,
17865 },
17866 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017867 .mixers = { alc663_asus_15jd_clfe_mixer },
17868 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017869 .init_verbs = { alc662_init_verbs,
17870 alc663_15jd_amic_init_verbs },
17871 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17872 .hp_nid = 0x03,
17873 .dac_nids = alc662_dac_nids,
17874 .dig_out_nid = ALC662_DIGOUT_NID,
17875 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17876 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017877 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017878 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017879 .init_hook = alc663_mode5_inithook,
17880 },
17881 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017882 .mixers = { alc663_two_hp_m2_mixer },
17883 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017884 .init_verbs = { alc662_init_verbs,
17885 alc663_two_hp_amic_m2_init_verbs },
17886 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17887 .hp_nid = 0x03,
17888 .dac_nids = alc662_dac_nids,
17889 .dig_out_nid = ALC662_DIGOUT_NID,
17890 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17891 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017892 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017893 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017894 .init_hook = alc663_mode6_inithook,
17895 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017896 [ALC663_ASUS_MODE7] = {
17897 .mixers = { alc663_mode7_mixer },
17898 .cap_mixer = alc662_auto_capture_mixer,
17899 .init_verbs = { alc662_init_verbs,
17900 alc663_mode7_init_verbs },
17901 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17902 .hp_nid = 0x03,
17903 .dac_nids = alc662_dac_nids,
17904 .dig_out_nid = ALC662_DIGOUT_NID,
17905 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17906 .channel_mode = alc662_3ST_2ch_modes,
17907 .unsol_event = alc663_mode7_unsol_event,
17908 .setup = alc663_mode7_setup,
17909 .init_hook = alc663_mode7_inithook,
17910 },
17911 [ALC663_ASUS_MODE8] = {
17912 .mixers = { alc663_mode8_mixer },
17913 .cap_mixer = alc662_auto_capture_mixer,
17914 .init_verbs = { alc662_init_verbs,
17915 alc663_mode8_init_verbs },
17916 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17917 .hp_nid = 0x03,
17918 .dac_nids = alc662_dac_nids,
17919 .dig_out_nid = ALC662_DIGOUT_NID,
17920 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17921 .channel_mode = alc662_3ST_2ch_modes,
17922 .unsol_event = alc663_mode8_unsol_event,
17923 .setup = alc663_mode8_setup,
17924 .init_hook = alc663_mode8_inithook,
17925 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017926 [ALC272_DELL] = {
17927 .mixers = { alc663_m51va_mixer },
17928 .cap_mixer = alc272_auto_capture_mixer,
17929 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17930 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17931 .dac_nids = alc662_dac_nids,
17932 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17933 .adc_nids = alc272_adc_nids,
17934 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17935 .capsrc_nids = alc272_capsrc_nids,
17936 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017937 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017938 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017939 .init_hook = alc663_m51va_inithook,
17940 },
17941 [ALC272_DELL_ZM1] = {
17942 .mixers = { alc663_m51va_mixer },
17943 .cap_mixer = alc662_auto_capture_mixer,
17944 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17945 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17946 .dac_nids = alc662_dac_nids,
17947 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17948 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017949 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017950 .capsrc_nids = alc662_capsrc_nids,
17951 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017952 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017953 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017954 .init_hook = alc663_m51va_inithook,
17955 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017956 [ALC272_SAMSUNG_NC10] = {
17957 .mixers = { alc272_nc10_mixer },
17958 .init_verbs = { alc662_init_verbs,
17959 alc663_21jd_amic_init_verbs },
17960 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17961 .dac_nids = alc272_dac_nids,
17962 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17963 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017964 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017965 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017966 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017967 .init_hook = alc663_mode4_inithook,
17968 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017969};
17970
17971
17972/*
17973 * BIOS auto configuration
17974 */
17975
Takashi Iwai7085ec12009-10-02 09:03:58 +020017976/* convert from MIX nid to DAC */
17977static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17978{
17979 if (nid == 0x0f)
17980 return 0x02;
17981 else if (nid >= 0x0c && nid <= 0x0e)
17982 return nid - 0x0c + 0x02;
17983 else
17984 return 0;
17985}
17986
17987/* get MIX nid connected to the given pin targeted to DAC */
17988static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17989 hda_nid_t dac)
17990{
17991 hda_nid_t mix[4];
17992 int i, num;
17993
17994 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17995 for (i = 0; i < num; i++) {
17996 if (alc662_mix_to_dac(mix[i]) == dac)
17997 return mix[i];
17998 }
17999 return 0;
18000}
18001
18002/* look for an empty DAC slot */
18003static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18004{
18005 struct alc_spec *spec = codec->spec;
18006 hda_nid_t srcs[5];
18007 int i, j, num;
18008
18009 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18010 if (num < 0)
18011 return 0;
18012 for (i = 0; i < num; i++) {
18013 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18014 if (!nid)
18015 continue;
18016 for (j = 0; j < spec->multiout.num_dacs; j++)
18017 if (spec->multiout.dac_nids[j] == nid)
18018 break;
18019 if (j >= spec->multiout.num_dacs)
18020 return nid;
18021 }
18022 return 0;
18023}
18024
18025/* fill in the dac_nids table from the parsed pin configuration */
18026static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18027 const struct auto_pin_cfg *cfg)
18028{
18029 struct alc_spec *spec = codec->spec;
18030 int i;
18031 hda_nid_t dac;
18032
18033 spec->multiout.dac_nids = spec->private_dac_nids;
18034 for (i = 0; i < cfg->line_outs; i++) {
18035 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18036 if (!dac)
18037 continue;
18038 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18039 }
18040 return 0;
18041}
18042
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018043static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018044 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018045{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018046 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018047 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18048}
18049
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018050static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018051 hda_nid_t nid, unsigned int chs)
18052{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018053 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018054 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18055}
18056
18057#define alc662_add_stereo_vol(spec, pfx, nid) \
18058 alc662_add_vol_ctl(spec, pfx, nid, 3)
18059#define alc662_add_stereo_sw(spec, pfx, nid) \
18060 alc662_add_sw_ctl(spec, pfx, nid, 3)
18061
18062/* add playback controls from the parsed DAC table */
18063static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18064 const struct auto_pin_cfg *cfg)
18065{
18066 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018067 static const char *chname[4] = {
18068 "Front", "Surround", NULL /*CLFE*/, "Side"
18069 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018070 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018071 int i, err;
18072
18073 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018074 nid = spec->multiout.dac_nids[i];
18075 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018076 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018077 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18078 if (!mix)
18079 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018080 if (i == 2) {
18081 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018082 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018083 if (err < 0)
18084 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018085 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018086 if (err < 0)
18087 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018088 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018089 if (err < 0)
18090 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018091 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018092 if (err < 0)
18093 return err;
18094 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018095 const char *pfx;
18096 if (cfg->line_outs == 1 &&
18097 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018098 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018099 pfx = "Speaker";
18100 else
18101 pfx = "PCM";
18102 } else
18103 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018104 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018105 if (err < 0)
18106 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018107 if (cfg->line_outs == 1 &&
18108 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18109 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018110 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018111 if (err < 0)
18112 return err;
18113 }
18114 }
18115 return 0;
18116}
18117
18118/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018119/* return DAC nid if any new DAC is assigned */
18120static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018121 const char *pfx)
18122{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018123 struct alc_spec *spec = codec->spec;
18124 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018125 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018126
18127 if (!pin)
18128 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018129 nid = alc662_look_for_dac(codec, pin);
18130 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018131 /* the corresponding DAC is already occupied */
18132 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18133 return 0; /* no way */
18134 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018135 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018136 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18137 }
18138
18139 mix = alc662_dac_to_mix(codec, pin, nid);
18140 if (!mix)
18141 return 0;
18142 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18143 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018144 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018145 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18146 if (err < 0)
18147 return err;
18148 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018149}
18150
18151/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018152#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018153 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018154
18155static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18156 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018157 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018158{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018159 int i, num;
18160 hda_nid_t srcs[4];
18161
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018162 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018163 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018164 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18165 if (num <= 1)
18166 return;
18167 for (i = 0; i < num; i++) {
18168 if (alc662_mix_to_dac(srcs[i]) != dac)
18169 continue;
18170 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18171 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018172 }
18173}
18174
18175static void alc662_auto_init_multi_out(struct hda_codec *codec)
18176{
18177 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018178 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018179 int i;
18180
18181 for (i = 0; i <= HDA_SIDE; i++) {
18182 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18183 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018184 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018185 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018186 }
18187}
18188
18189static void alc662_auto_init_hp_out(struct hda_codec *codec)
18190{
18191 struct alc_spec *spec = codec->spec;
18192 hda_nid_t pin;
18193
18194 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018195 if (pin)
18196 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18197 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018198 pin = spec->autocfg.speaker_pins[0];
18199 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018200 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18201 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018202}
18203
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018204#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18205
18206static void alc662_auto_init_analog_input(struct hda_codec *codec)
18207{
18208 struct alc_spec *spec = codec->spec;
18209 int i;
18210
18211 for (i = 0; i < AUTO_PIN_LAST; i++) {
18212 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018213 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018214 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018215 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018216 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018217 snd_hda_codec_write(codec, nid, 0,
18218 AC_VERB_SET_AMP_GAIN_MUTE,
18219 AMP_OUT_MUTE);
18220 }
18221 }
18222}
18223
Takashi Iwaif511b012008-08-15 16:46:42 +020018224#define alc662_auto_init_input_src alc882_auto_init_input_src
18225
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018226static int alc662_parse_auto_config(struct hda_codec *codec)
18227{
18228 struct alc_spec *spec = codec->spec;
18229 int err;
18230 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18231
18232 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18233 alc662_ignore);
18234 if (err < 0)
18235 return err;
18236 if (!spec->autocfg.line_outs)
18237 return 0; /* can't find valid BIOS pin config */
18238
Takashi Iwai7085ec12009-10-02 09:03:58 +020018239 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018240 if (err < 0)
18241 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018242 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018243 if (err < 0)
18244 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018245 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018246 spec->autocfg.speaker_pins[0],
18247 "Speaker");
18248 if (err < 0)
18249 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018250 if (err)
18251 spec->multiout.extra_out_nid[0] = err;
18252 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018253 "Headphone");
18254 if (err < 0)
18255 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018256 if (err)
18257 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018258 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018259 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018260 return err;
18261
18262 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18263
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018264 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018265 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18266
Takashi Iwai603c4012008-07-30 15:01:44 +020018267 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018268 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018269
18270 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018271 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018272
Kailang Yangcec27c82010-02-04 14:18:18 +010018273 add_verb(spec, alc662_init_verbs);
18274 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18275 codec->vendor_id == 0x10ec0665)
18276 add_verb(spec, alc663_init_verbs);
18277
18278 if (codec->vendor_id == 0x10ec0272)
18279 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018280
18281 err = alc_auto_add_mic_boost(codec);
18282 if (err < 0)
18283 return err;
18284
Kailang Yang6227cdc2010-02-25 08:36:52 +010018285 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18286 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18287 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18288 else
18289 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018290
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018291 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018292}
18293
18294/* additional initialization for auto-configuration model */
18295static void alc662_auto_init(struct hda_codec *codec)
18296{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018297 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018298 alc662_auto_init_multi_out(codec);
18299 alc662_auto_init_hp_out(codec);
18300 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018301 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018302 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018303 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018304}
18305
18306static int patch_alc662(struct hda_codec *codec)
18307{
18308 struct alc_spec *spec;
18309 int err, board_config;
18310
18311 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18312 if (!spec)
18313 return -ENOMEM;
18314
18315 codec->spec = spec;
18316
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018317 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18318
Kailang Yang274693f2009-12-03 10:07:50 +010018319 if (alc_read_coef_idx(codec, 0)==0x8020){
18320 kfree(codec->chip_name);
18321 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018322 if (!codec->chip_name) {
18323 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018324 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018325 }
Kailang Yang274693f2009-12-03 10:07:50 +010018326 }
18327
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018328 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18329 alc662_models,
18330 alc662_cfg_tbl);
18331 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018332 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18333 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018334 board_config = ALC662_AUTO;
18335 }
18336
18337 if (board_config == ALC662_AUTO) {
18338 /* automatic parse from the BIOS config */
18339 err = alc662_parse_auto_config(codec);
18340 if (err < 0) {
18341 alc_free(codec);
18342 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018343 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018344 printk(KERN_INFO
18345 "hda_codec: Cannot set up configuration "
18346 "from BIOS. Using base mode...\n");
18347 board_config = ALC662_3ST_2ch_DIG;
18348 }
18349 }
18350
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018351 err = snd_hda_attach_beep_device(codec, 0x1);
18352 if (err < 0) {
18353 alc_free(codec);
18354 return err;
18355 }
18356
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018357 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018358 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018359
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018360 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18361 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18362
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018363 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18364 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18365
Takashi Iwaidd704692009-08-11 08:45:11 +020018366 if (!spec->adc_nids) {
18367 spec->adc_nids = alc662_adc_nids;
18368 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18369 }
18370 if (!spec->capsrc_nids)
18371 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018372
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018373 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018374 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018375
Kailang Yangcec27c82010-02-04 14:18:18 +010018376 switch (codec->vendor_id) {
18377 case 0x10ec0662:
18378 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18379 break;
18380 case 0x10ec0272:
18381 case 0x10ec0663:
18382 case 0x10ec0665:
18383 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18384 break;
18385 case 0x10ec0273:
18386 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18387 break;
18388 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018389 spec->vmaster_nid = 0x02;
18390
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018391 codec->patch_ops = alc_patch_ops;
18392 if (board_config == ALC662_AUTO)
18393 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018394#ifdef CONFIG_SND_HDA_POWER_SAVE
18395 if (!spec->loopback.amplist)
18396 spec->loopback.amplist = alc662_loopbacks;
18397#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018398
18399 return 0;
18400}
18401
Kailang Yang274693f2009-12-03 10:07:50 +010018402static int patch_alc888(struct hda_codec *codec)
18403{
18404 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18405 kfree(codec->chip_name);
18406 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018407 if (!codec->chip_name) {
18408 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018409 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018410 }
18411 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018412 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018413 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018414}
18415
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018416/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018417 * patch entries
18418 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018419static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018420 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018421 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018422 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018423 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018424 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018425 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018426 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018427 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018428 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018429 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018430 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18431 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18432 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018433 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018434 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018435 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18436 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018437 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018438 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018439 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018440 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018441 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018442 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018443 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018444 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018445 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018446 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018447 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018448 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018449 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018450 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018451 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018452 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018453 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018454 {} /* terminator */
18455};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018456
18457MODULE_ALIAS("snd-hda-codec-id:10ec*");
18458
18459MODULE_LICENSE("GPL");
18460MODULE_DESCRIPTION("Realtek HD-audio codec");
18461
18462static struct hda_codec_preset_list realtek_list = {
18463 .preset = snd_hda_preset_realtek,
18464 .owner = THIS_MODULE,
18465};
18466
18467static int __init patch_realtek_init(void)
18468{
18469 return snd_hda_add_codec_preset(&realtek_list);
18470}
18471
18472static void __exit patch_realtek_exit(void)
18473{
18474 snd_hda_delete_codec_preset(&realtek_list);
18475}
18476
18477module_init(patch_realtek_init)
18478module_exit(patch_realtek_exit)