blob: 053d53d8c8b2d39f9e489c7d47b4a4b73f57a2cf [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ünther3e1647c2009-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
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002535 /* assign Capture Source enums to NID */
2536 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2537 if (!kctl)
2538 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2539 for (i = 0; kctl && i < kctl->count; i++) {
Takashi Iwaid1409ae2009-12-17 15:01:31 +01002540 hda_nid_t *nids = spec->capsrc_nids;
2541 if (!nids)
2542 nids = spec->adc_nids;
Takashi Iwai21949f02009-12-23 08:31:59 +01002543 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002544 if (err < 0)
2545 return err;
2546 }
2547 if (spec->cap_mixer) {
2548 const char *kname = kctl ? kctl->id.name : NULL;
2549 for (knew = spec->cap_mixer; knew->name; knew++) {
2550 if (kname && strcmp(knew->name, kname) == 0)
2551 continue;
2552 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2553 for (i = 0; kctl && i < kctl->count; i++) {
2554 err = snd_hda_add_nid(codec, kctl, i,
2555 spec->adc_nids[i]);
2556 if (err < 0)
2557 return err;
2558 }
2559 }
2560 }
2561
2562 /* other nid->control mapping */
2563 for (i = 0; i < spec->num_mixers; i++) {
2564 for (knew = spec->mixers[i]; knew->name; knew++) {
2565 if (knew->iface != NID_MAPPING)
2566 continue;
2567 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2568 if (kctl == NULL)
2569 continue;
2570 u = knew->subdevice;
2571 for (j = 0; j < 4; j++, u >>= 8) {
2572 nid = u & 0x3f;
2573 if (nid == 0)
2574 continue;
2575 switch (u & 0xc0) {
2576 case SUBDEV_SPEAKER_:
2577 nid = spec->autocfg.speaker_pins[nid];
2578 break;
2579 case SUBDEV_LINE_:
2580 nid = spec->autocfg.line_out_pins[nid];
2581 break;
2582 case SUBDEV_HP_:
2583 nid = spec->autocfg.hp_pins[nid];
2584 break;
2585 default:
2586 continue;
2587 }
2588 err = snd_hda_add_nid(codec, kctl, 0, nid);
2589 if (err < 0)
2590 return err;
2591 }
2592 u = knew->private_value;
2593 for (j = 0; j < 4; j++, u >>= 8) {
2594 nid = u & 0xff;
2595 if (nid == 0)
2596 continue;
2597 err = snd_hda_add_nid(codec, kctl, 0, nid);
2598 if (err < 0)
2599 return err;
2600 }
2601 }
2602 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002603
2604 alc_free_kctls(codec); /* no longer needed */
2605
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 return 0;
2607}
2608
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002609
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610/*
2611 * initialize the codec volumes, etc
2612 */
2613
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002614/*
2615 * generic initialization of ADC, input mixers and output mixers
2616 */
2617static struct hda_verb alc880_volume_init_verbs[] = {
2618 /*
2619 * Unmute ADC0-2 and set the default input to mic-in
2620 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002621 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002622 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002623 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002625 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002626 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002628 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2629 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002630 * Note: PASD motherboards uses the Line In 2 as the input for front
2631 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002633 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002634 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2635 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2636 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2637 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002642 /*
2643 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002645 /* set vol=0 to output mixers */
2646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2647 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2648 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2649 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2650 /* set up input amps for analog loopback */
2651 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002652 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2655 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002658 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2659 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660
2661 { }
2662};
2663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002664/*
2665 * 3-stack pin configuration:
2666 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2667 */
2668static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2669 /*
2670 * preset connection lists of input pins
2671 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2672 */
2673 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2674 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2675 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2676
2677 /*
2678 * Set pin mode and muting
2679 */
2680 /* set front pin widgets 0x14 for output */
2681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2682 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2683 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2684 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2685 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2686 /* Mic2 (as headphone out) for HP output */
2687 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2688 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2689 /* Line In pin widget for input */
2690 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2691 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2692 /* Line2 (as front mic) pin widget for input and vref at 80% */
2693 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2694 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2695 /* CD pin widget for input */
2696 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2697
2698 { }
2699};
2700
2701/*
2702 * 5-stack pin configuration:
2703 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
2704 * line-in/side = 0x1a, f-mic = 0x1b
2705 */
2706static struct hda_verb alc880_pin_5stack_init_verbs[] = {
2707 /*
2708 * preset connection lists of input pins
2709 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2710 */
2711 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2712 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2713
2714 /*
2715 * Set pin mode and muting
2716 */
2717 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002718 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2719 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2720 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2721 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002722 /* unmute pins for output (no gain on this amp) */
2723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2725 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2726 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2727
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002730 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2731 /* Mic2 (as headphone out) for HP output */
2732 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002734 /* Line In pin widget for input */
2735 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2737 /* Line2 (as front mic) pin widget for input and vref at 80% */
2738 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2739 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2740 /* CD pin widget for input */
2741 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742
2743 { }
2744};
2745
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002746/*
2747 * W810 pin configuration:
2748 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2749 */
2750static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 /* hphone/speaker input selector: front DAC */
2752 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2753
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002754 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2755 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2756 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2757 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2759 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2760
2761 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002762 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764 { }
2765};
2766
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002767/*
2768 * Z71V pin configuration:
2769 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2770 */
2771static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002772 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002773 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002774 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002776
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002781
2782 { }
2783};
2784
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002785/*
2786 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002787 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2788 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002789 */
2790static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2791 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2792
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002796 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002797 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002798 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002799 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002800 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2801
Takashi Iwai16ded522005-06-10 19:58:24 +02002802 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002803 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002804 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002805 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002806 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002807 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002808 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002809 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002810 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002811
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002812 { }
2813};
Takashi Iwai16ded522005-06-10 19:58:24 +02002814
Kailang Yangccc656c2006-10-17 12:32:26 +02002815/*
2816 * Uniwill pin configuration:
2817 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2818 * line = 0x1a
2819 */
2820static struct hda_verb alc880_uniwill_init_verbs[] = {
2821 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2822
2823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2827 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2828 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2829 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2831 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2832 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2833 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2834 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2835 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2837
2838 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2839 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2840 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2841 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2842 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2844 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2845 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2846 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2847
2848 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2849 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2850
2851 { }
2852};
2853
2854/*
2855* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002856* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002857 */
2858static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2859 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2860
2861 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2862 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2863 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2864 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2865 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2866 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2867 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2868 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2869 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2870 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2871 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2872 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2873
2874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2875 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2876 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2877 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2879 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2880
2881 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2882 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2883
2884 { }
2885};
2886
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002887static struct hda_verb alc880_beep_init_verbs[] = {
2888 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2889 { }
2890};
2891
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002892/* auto-toggle front mic */
2893static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2894{
2895 unsigned int present;
2896 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002897
Wu Fengguang864f92b2009-11-18 12:38:02 +08002898 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002899 bits = present ? HDA_AMP_MUTE : 0;
2900 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002901}
2902
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002903static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002904{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002905 struct alc_spec *spec = codec->spec;
2906
2907 spec->autocfg.hp_pins[0] = 0x14;
2908 spec->autocfg.speaker_pins[0] = 0x15;
2909 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002910}
2911
2912static void alc880_uniwill_init_hook(struct hda_codec *codec)
2913{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002914 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002915 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002916}
2917
2918static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2919 unsigned int res)
2920{
2921 /* Looks like the unsol event is incompatible with the standard
2922 * definition. 4bit tag is placed at 28 bit!
2923 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002924 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002925 case ALC880_MIC_EVENT:
2926 alc880_uniwill_mic_automute(codec);
2927 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002928 default:
2929 alc_automute_amp_unsol_event(codec, res);
2930 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002931 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002932}
2933
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002934static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002935{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002936 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02002937
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002938 spec->autocfg.hp_pins[0] = 0x14;
2939 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02002940}
2941
2942static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2943{
2944 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002945
Kailang Yangccc656c2006-10-17 12:32:26 +02002946 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002947 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2948 present &= HDA_AMP_VOLMASK;
2949 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2950 HDA_AMP_VOLMASK, present);
2951 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2952 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002953}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002954
Kailang Yangccc656c2006-10-17 12:32:26 +02002955static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2956 unsigned int res)
2957{
2958 /* Looks like the unsol event is incompatible with the standard
2959 * definition. 4bit tag is placed at 28 bit!
2960 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002961 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002962 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002963 else
2964 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02002965}
2966
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002967/*
2968 * F1734 pin configuration:
2969 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2970 */
2971static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002972 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002973 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2974 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2975 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2976 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2977
2978 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2981 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2982
2983 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2984 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002986 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2987 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2988 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2989 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2990 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2991 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002992
Takashi Iwai937b4162008-02-11 14:52:36 +01002993 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2994 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2995
Takashi Iwai16ded522005-06-10 19:58:24 +02002996 { }
2997};
2998
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999/*
3000 * ASUS pin configuration:
3001 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3002 */
3003static struct hda_verb alc880_pin_asus_init_verbs[] = {
3004 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3005 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3006 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3007 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3008
3009 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3010 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3011 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3014 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3015 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3017
3018 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3019 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3020 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3021 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3022 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3025 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3026 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003027
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 { }
3029};
3030
3031/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003032#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3033#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003034#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003035
Kailang Yangdf694da2005-12-05 19:42:22 +01003036/* Clevo m520g init */
3037static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3038 /* headphone output */
3039 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3040 /* line-out */
3041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3043 /* Line-in */
3044 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3045 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3046 /* CD */
3047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3048 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3049 /* Mic1 (rear panel) */
3050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3052 /* Mic2 (front panel) */
3053 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3054 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 /* headphone */
3056 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3057 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3058 /* change to EAPD mode */
3059 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3060 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3061
3062 { }
3063};
3064
3065static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003066 /* change to EAPD mode */
3067 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3068 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3069
Kailang Yangdf694da2005-12-05 19:42:22 +01003070 /* Headphone output */
3071 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3072 /* Front output*/
3073 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3074 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3075
3076 /* Line In pin widget for input */
3077 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3078 /* CD pin widget for input */
3079 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3080 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3082
3083 /* change to EAPD mode */
3084 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3085 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3086
3087 { }
3088};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089
3090/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003091 * LG m1 express dual
3092 *
3093 * Pin assignment:
3094 * Rear Line-In/Out (blue): 0x14
3095 * Build-in Mic-In: 0x15
3096 * Speaker-out: 0x17
3097 * HP-Out (green): 0x1b
3098 * Mic-In/Out (red): 0x19
3099 * SPDIF-Out: 0x1e
3100 */
3101
3102/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3103static hda_nid_t alc880_lg_dac_nids[3] = {
3104 0x05, 0x02, 0x03
3105};
3106
3107/* seems analog CD is not working */
3108static struct hda_input_mux alc880_lg_capture_source = {
3109 .num_items = 3,
3110 .items = {
3111 { "Mic", 0x1 },
3112 { "Line", 0x5 },
3113 { "Internal Mic", 0x6 },
3114 },
3115};
3116
3117/* 2,4,6 channel modes */
3118static struct hda_verb alc880_lg_ch2_init[] = {
3119 /* set line-in and mic-in to input */
3120 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3121 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3122 { }
3123};
3124
3125static struct hda_verb alc880_lg_ch4_init[] = {
3126 /* set line-in to out and mic-in to input */
3127 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3128 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3129 { }
3130};
3131
3132static struct hda_verb alc880_lg_ch6_init[] = {
3133 /* set line-in and mic-in to output */
3134 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3135 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3136 { }
3137};
3138
3139static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3140 { 2, alc880_lg_ch2_init },
3141 { 4, alc880_lg_ch4_init },
3142 { 6, alc880_lg_ch6_init },
3143};
3144
3145static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003146 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3147 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003148 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3149 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3155 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3156 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3157 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3158 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3159 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3160 {
3161 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3162 .name = "Channel Mode",
3163 .info = alc_ch_mode_info,
3164 .get = alc_ch_mode_get,
3165 .put = alc_ch_mode_put,
3166 },
3167 { } /* end */
3168};
3169
3170static struct hda_verb alc880_lg_init_verbs[] = {
3171 /* set capture source to mic-in */
3172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3173 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3174 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3175 /* mute all amp mixer inputs */
3176 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003177 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3178 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003179 /* line-in to input */
3180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3181 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3182 /* built-in mic */
3183 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3184 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3185 /* speaker-out */
3186 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3187 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 /* mic-in to input */
3189 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3190 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3191 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3192 /* HP-out */
3193 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3194 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3195 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3196 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003197 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003198 { }
3199};
3200
3201/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003202static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003203{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003204 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003205
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003206 spec->autocfg.hp_pins[0] = 0x1b;
3207 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003208}
3209
3210/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003211 * LG LW20
3212 *
3213 * Pin assignment:
3214 * Speaker-out: 0x14
3215 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003216 * Built-in Mic-In: 0x19
3217 * Line-In: 0x1b
3218 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003219 * SPDIF-Out: 0x1e
3220 */
3221
Takashi Iwaid6815182006-03-23 16:06:23 +01003222static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003223 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003224 .items = {
3225 { "Mic", 0x0 },
3226 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003227 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003228 },
3229};
3230
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003231#define alc880_lg_lw_modes alc880_threestack_modes
3232
Takashi Iwaid6815182006-03-23 16:06:23 +01003233static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003234 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3235 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3236 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3237 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3238 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3239 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3240 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3241 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3242 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3243 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003244 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3245 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3246 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3247 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003248 {
3249 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3250 .name = "Channel Mode",
3251 .info = alc_ch_mode_info,
3252 .get = alc_ch_mode_get,
3253 .put = alc_ch_mode_put,
3254 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003255 { } /* end */
3256};
3257
3258static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003259 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3260 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3261 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3262
Takashi Iwaid6815182006-03-23 16:06:23 +01003263 /* set capture source to mic-in */
3264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3265 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3266 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003268 /* speaker-out */
3269 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3270 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3271 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003272 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3273 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3274 /* mic-in to input */
3275 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3276 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3277 /* built-in mic */
3278 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3279 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3280 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003282 { }
3283};
3284
3285/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003286static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003287{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003288 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003289
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003290 spec->autocfg.hp_pins[0] = 0x1b;
3291 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003292}
3293
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003294static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3295 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3296 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3297 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3298 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3299 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3300 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3301 { } /* end */
3302};
3303
3304static struct hda_input_mux alc880_medion_rim_capture_source = {
3305 .num_items = 2,
3306 .items = {
3307 { "Mic", 0x0 },
3308 { "Internal Mic", 0x1 },
3309 },
3310};
3311
3312static struct hda_verb alc880_medion_rim_init_verbs[] = {
3313 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3314
3315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3316 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3317
3318 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3321 /* Mic2 (as headphone out) for HP output */
3322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3324 /* Internal Speaker */
3325 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3326 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3327
3328 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3329 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3330
3331 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3332 { }
3333};
3334
3335/* toggle speaker-output according to the hp-jack state */
3336static void alc880_medion_rim_automute(struct hda_codec *codec)
3337{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003338 struct alc_spec *spec = codec->spec;
3339 alc_automute_amp(codec);
3340 /* toggle EAPD */
3341 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003342 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3343 else
3344 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3345}
3346
3347static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3348 unsigned int res)
3349{
3350 /* Looks like the unsol event is incompatible with the standard
3351 * definition. 4bit tag is placed at 28 bit!
3352 */
3353 if ((res >> 28) == ALC880_HP_EVENT)
3354 alc880_medion_rim_automute(codec);
3355}
3356
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003357static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003358{
3359 struct alc_spec *spec = codec->spec;
3360
3361 spec->autocfg.hp_pins[0] = 0x14;
3362 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003363}
3364
Takashi Iwaicb53c622007-08-10 17:21:45 +02003365#ifdef CONFIG_SND_HDA_POWER_SAVE
3366static struct hda_amp_list alc880_loopbacks[] = {
3367 { 0x0b, HDA_INPUT, 0 },
3368 { 0x0b, HDA_INPUT, 1 },
3369 { 0x0b, HDA_INPUT, 2 },
3370 { 0x0b, HDA_INPUT, 3 },
3371 { 0x0b, HDA_INPUT, 4 },
3372 { } /* end */
3373};
3374
3375static struct hda_amp_list alc880_lg_loopbacks[] = {
3376 { 0x0b, HDA_INPUT, 1 },
3377 { 0x0b, HDA_INPUT, 6 },
3378 { 0x0b, HDA_INPUT, 7 },
3379 { } /* end */
3380};
3381#endif
3382
Takashi Iwaid6815182006-03-23 16:06:23 +01003383/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003384 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003385 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003386
Linus Torvalds1da177e2005-04-16 15:20:36 -07003387static int alc_init(struct hda_codec *codec)
3388{
3389 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003390 unsigned int i;
3391
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003392 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003393 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003394
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395 for (i = 0; i < spec->num_init_verbs; i++)
3396 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003397
3398 if (spec->init_hook)
3399 spec->init_hook(codec);
3400
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401 return 0;
3402}
3403
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003404static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3405{
3406 struct alc_spec *spec = codec->spec;
3407
3408 if (spec->unsol_event)
3409 spec->unsol_event(codec, res);
3410}
3411
Takashi Iwaicb53c622007-08-10 17:21:45 +02003412#ifdef CONFIG_SND_HDA_POWER_SAVE
3413static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3414{
3415 struct alc_spec *spec = codec->spec;
3416 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3417}
3418#endif
3419
Linus Torvalds1da177e2005-04-16 15:20:36 -07003420/*
3421 * Analog playback callbacks
3422 */
3423static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3424 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003425 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003426{
3427 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003428 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3429 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003430}
3431
3432static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3433 struct hda_codec *codec,
3434 unsigned int stream_tag,
3435 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003436 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003437{
3438 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003439 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3440 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003441}
3442
3443static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3444 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003445 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003446{
3447 struct alc_spec *spec = codec->spec;
3448 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3449}
3450
3451/*
3452 * Digital out
3453 */
3454static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3455 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003456 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003457{
3458 struct alc_spec *spec = codec->spec;
3459 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3460}
3461
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003462static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3463 struct hda_codec *codec,
3464 unsigned int stream_tag,
3465 unsigned int format,
3466 struct snd_pcm_substream *substream)
3467{
3468 struct alc_spec *spec = codec->spec;
3469 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3470 stream_tag, format, substream);
3471}
3472
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003473static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3474 struct hda_codec *codec,
3475 struct snd_pcm_substream *substream)
3476{
3477 struct alc_spec *spec = codec->spec;
3478 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3479}
3480
Linus Torvalds1da177e2005-04-16 15:20:36 -07003481static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3482 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003483 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003484{
3485 struct alc_spec *spec = codec->spec;
3486 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3487}
3488
3489/*
3490 * Analog capture
3491 */
Takashi Iwai63300792008-01-24 15:31:36 +01003492static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003493 struct hda_codec *codec,
3494 unsigned int stream_tag,
3495 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003496 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003497{
3498 struct alc_spec *spec = codec->spec;
3499
Takashi Iwai63300792008-01-24 15:31:36 +01003500 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003501 stream_tag, 0, format);
3502 return 0;
3503}
3504
Takashi Iwai63300792008-01-24 15:31:36 +01003505static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003506 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003507 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003508{
3509 struct alc_spec *spec = codec->spec;
3510
Takashi Iwai888afa12008-03-18 09:57:50 +01003511 snd_hda_codec_cleanup_stream(codec,
3512 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003513 return 0;
3514}
3515
3516
3517/*
3518 */
3519static struct hda_pcm_stream alc880_pcm_analog_playback = {
3520 .substreams = 1,
3521 .channels_min = 2,
3522 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003523 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003524 .ops = {
3525 .open = alc880_playback_pcm_open,
3526 .prepare = alc880_playback_pcm_prepare,
3527 .cleanup = alc880_playback_pcm_cleanup
3528 },
3529};
3530
3531static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003532 .substreams = 1,
3533 .channels_min = 2,
3534 .channels_max = 2,
3535 /* NID is set in alc_build_pcms */
3536};
3537
3538static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3539 .substreams = 1,
3540 .channels_min = 2,
3541 .channels_max = 2,
3542 /* NID is set in alc_build_pcms */
3543};
3544
3545static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3546 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003547 .channels_min = 2,
3548 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003549 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003550 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003551 .prepare = alc880_alt_capture_pcm_prepare,
3552 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003553 },
3554};
3555
3556static struct hda_pcm_stream alc880_pcm_digital_playback = {
3557 .substreams = 1,
3558 .channels_min = 2,
3559 .channels_max = 2,
3560 /* NID is set in alc_build_pcms */
3561 .ops = {
3562 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003563 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003564 .prepare = alc880_dig_playback_pcm_prepare,
3565 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566 },
3567};
3568
3569static struct hda_pcm_stream alc880_pcm_digital_capture = {
3570 .substreams = 1,
3571 .channels_min = 2,
3572 .channels_max = 2,
3573 /* NID is set in alc_build_pcms */
3574};
3575
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003576/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003577static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003578 .substreams = 0,
3579 .channels_min = 0,
3580 .channels_max = 0,
3581};
3582
Linus Torvalds1da177e2005-04-16 15:20:36 -07003583static int alc_build_pcms(struct hda_codec *codec)
3584{
3585 struct alc_spec *spec = codec->spec;
3586 struct hda_pcm *info = spec->pcm_rec;
3587 int i;
3588
3589 codec->num_pcms = 1;
3590 codec->pcm_info = info;
3591
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003592 if (spec->no_analog)
3593 goto skip_analog;
3594
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003595 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3596 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003597 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003598
Takashi Iwai4a471b72005-12-07 13:56:29 +01003599 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003600 if (snd_BUG_ON(!spec->multiout.dac_nids))
3601 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003602 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3603 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3604 }
3605 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003606 if (snd_BUG_ON(!spec->adc_nids))
3607 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003608 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3609 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3610 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003611
Takashi Iwai4a471b72005-12-07 13:56:29 +01003612 if (spec->channel_mode) {
3613 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3614 for (i = 0; i < spec->num_channel_mode; i++) {
3615 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3616 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3617 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003618 }
3619 }
3620
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003621 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003622 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003623 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003624 snprintf(spec->stream_name_digital,
3625 sizeof(spec->stream_name_digital),
3626 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003627 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003628 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003629 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003630 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003631 if (spec->dig_out_type)
3632 info->pcm_type = spec->dig_out_type;
3633 else
3634 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003635 if (spec->multiout.dig_out_nid &&
3636 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003637 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3638 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3639 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003640 if (spec->dig_in_nid &&
3641 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003642 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3643 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3644 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003645 /* FIXME: do we need this for all Realtek codec models? */
3646 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003647 }
3648
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003649 if (spec->no_analog)
3650 return 0;
3651
Takashi Iwaie08a0072006-09-07 17:52:14 +02003652 /* If the use of more than one ADC is requested for the current
3653 * model, configure a second analog capture-only PCM.
3654 */
3655 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01003656 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
3657 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02003658 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003659 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003660 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01003661 if (spec->alt_dac_nid) {
3662 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3663 *spec->stream_analog_alt_playback;
3664 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
3665 spec->alt_dac_nid;
3666 } else {
3667 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
3668 alc_pcm_null_stream;
3669 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
3670 }
3671 if (spec->num_adc_nids > 1) {
3672 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3673 *spec->stream_analog_alt_capture;
3674 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
3675 spec->adc_nids[1];
3676 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
3677 spec->num_adc_nids - 1;
3678 } else {
3679 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
3680 alc_pcm_null_stream;
3681 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02003682 }
3683 }
3684
Linus Torvalds1da177e2005-04-16 15:20:36 -07003685 return 0;
3686}
3687
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003688static inline void alc_shutup(struct hda_codec *codec)
3689{
3690 snd_hda_shutup_pins(codec);
3691}
3692
Takashi Iwai603c4012008-07-30 15:01:44 +02003693static void alc_free_kctls(struct hda_codec *codec)
3694{
3695 struct alc_spec *spec = codec->spec;
3696
3697 if (spec->kctls.list) {
3698 struct snd_kcontrol_new *kctl = spec->kctls.list;
3699 int i;
3700 for (i = 0; i < spec->kctls.used; i++)
3701 kfree(kctl[i].name);
3702 }
3703 snd_array_free(&spec->kctls);
3704}
3705
Linus Torvalds1da177e2005-04-16 15:20:36 -07003706static void alc_free(struct hda_codec *codec)
3707{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003708 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003709
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003710 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003711 return;
3712
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003713 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02003714 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003715 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09003716 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717}
3718
Hector Martinf5de24b2009-12-20 22:51:31 +01003719#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05003720static void alc_power_eapd(struct hda_codec *codec)
3721{
3722 /* We currently only handle front, HP */
3723 switch (codec->vendor_id) {
3724 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003725 set_eapd(codec, 0x0f, 0);
3726 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003727 break;
3728 case 0x10ec0262:
3729 case 0x10ec0267:
3730 case 0x10ec0268:
3731 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003732 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05003733 case 0x10ec0272:
3734 case 0x10ec0660:
3735 case 0x10ec0662:
3736 case 0x10ec0663:
3737 case 0x10ec0862:
3738 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01003739 set_eapd(codec, 0x14, 0);
3740 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05003741 break;
3742 }
3743}
3744
Hector Martinf5de24b2009-12-20 22:51:31 +01003745static int alc_suspend(struct hda_codec *codec, pm_message_t state)
3746{
3747 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01003748 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003749 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05003750 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01003751 return 0;
3752}
3753#endif
3754
Takashi Iwaie044c392008-10-27 16:56:24 +01003755#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01003756static int alc_resume(struct hda_codec *codec)
3757{
Takashi Iwaie044c392008-10-27 16:56:24 +01003758 codec->patch_ops.init(codec);
3759 snd_hda_codec_resume_amp(codec);
3760 snd_hda_codec_resume_cache(codec);
3761 return 0;
3762}
Takashi Iwaie044c392008-10-27 16:56:24 +01003763#endif
3764
Linus Torvalds1da177e2005-04-16 15:20:36 -07003765/*
3766 */
3767static struct hda_codec_ops alc_patch_ops = {
3768 .build_controls = alc_build_controls,
3769 .build_pcms = alc_build_pcms,
3770 .init = alc_init,
3771 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003772 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003773#ifdef SND_HDA_NEEDS_RESUME
3774 .resume = alc_resume,
3775#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003776#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01003777 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003778 .check_power_status = alc_check_power_status,
3779#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05003780 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003781};
3782
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003783
3784/*
3785 * Test configuration for debugging
3786 *
3787 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3788 * enum controls.
3789 */
3790#ifdef CONFIG_SND_DEBUG
3791static hda_nid_t alc880_test_dac_nids[4] = {
3792 0x02, 0x03, 0x04, 0x05
3793};
3794
3795static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003796 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003797 .items = {
3798 { "In-1", 0x0 },
3799 { "In-2", 0x1 },
3800 { "In-3", 0x2 },
3801 { "In-4", 0x3 },
3802 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003803 { "Front", 0x5 },
3804 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003805 },
3806};
3807
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003808static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003809 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003810 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003811 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003812 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003813};
3814
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003815static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3816 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003817{
3818 static char *texts[] = {
3819 "N/A", "Line Out", "HP Out",
3820 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3821 };
3822 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3823 uinfo->count = 1;
3824 uinfo->value.enumerated.items = 8;
3825 if (uinfo->value.enumerated.item >= 8)
3826 uinfo->value.enumerated.item = 7;
3827 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3828 return 0;
3829}
3830
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003831static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3832 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003833{
3834 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3835 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3836 unsigned int pin_ctl, item = 0;
3837
3838 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3839 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3840 if (pin_ctl & AC_PINCTL_OUT_EN) {
3841 if (pin_ctl & AC_PINCTL_HP_EN)
3842 item = 2;
3843 else
3844 item = 1;
3845 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3846 switch (pin_ctl & AC_PINCTL_VREFEN) {
3847 case AC_PINCTL_VREF_HIZ: item = 3; break;
3848 case AC_PINCTL_VREF_50: item = 4; break;
3849 case AC_PINCTL_VREF_GRD: item = 5; break;
3850 case AC_PINCTL_VREF_80: item = 6; break;
3851 case AC_PINCTL_VREF_100: item = 7; break;
3852 }
3853 }
3854 ucontrol->value.enumerated.item[0] = item;
3855 return 0;
3856}
3857
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003858static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3859 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003860{
3861 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3862 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3863 static unsigned int ctls[] = {
3864 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3865 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3866 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3867 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3868 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3869 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3870 };
3871 unsigned int old_ctl, new_ctl;
3872
3873 old_ctl = snd_hda_codec_read(codec, nid, 0,
3874 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3875 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3876 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003877 int val;
3878 snd_hda_codec_write_cache(codec, nid, 0,
3879 AC_VERB_SET_PIN_WIDGET_CONTROL,
3880 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003881 val = ucontrol->value.enumerated.item[0] >= 3 ?
3882 HDA_AMP_MUTE : 0;
3883 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3884 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003885 return 1;
3886 }
3887 return 0;
3888}
3889
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003890static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3891 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003892{
3893 static char *texts[] = {
3894 "Front", "Surround", "CLFE", "Side"
3895 };
3896 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3897 uinfo->count = 1;
3898 uinfo->value.enumerated.items = 4;
3899 if (uinfo->value.enumerated.item >= 4)
3900 uinfo->value.enumerated.item = 3;
3901 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3902 return 0;
3903}
3904
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003905static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3906 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003907{
3908 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3909 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3910 unsigned int sel;
3911
3912 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3913 ucontrol->value.enumerated.item[0] = sel & 3;
3914 return 0;
3915}
3916
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003917static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3918 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003919{
3920 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3921 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3922 unsigned int sel;
3923
3924 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3925 if (ucontrol->value.enumerated.item[0] != sel) {
3926 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003927 snd_hda_codec_write_cache(codec, nid, 0,
3928 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003929 return 1;
3930 }
3931 return 0;
3932}
3933
3934#define PIN_CTL_TEST(xname,nid) { \
3935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3936 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003937 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003938 .info = alc_test_pin_ctl_info, \
3939 .get = alc_test_pin_ctl_get, \
3940 .put = alc_test_pin_ctl_put, \
3941 .private_value = nid \
3942 }
3943
3944#define PIN_SRC_TEST(xname,nid) { \
3945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3946 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003947 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003948 .info = alc_test_pin_src_info, \
3949 .get = alc_test_pin_src_get, \
3950 .put = alc_test_pin_src_put, \
3951 .private_value = nid \
3952 }
3953
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003954static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003955 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3956 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3957 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3958 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003959 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3960 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3961 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3962 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003963 PIN_CTL_TEST("Front Pin Mode", 0x14),
3964 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3965 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3966 PIN_CTL_TEST("Side Pin Mode", 0x17),
3967 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3968 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3969 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3970 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3971 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3972 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3973 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3974 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3975 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3976 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3977 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3978 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3979 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3980 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3981 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3982 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3983 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3984 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003985 {
3986 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3987 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003988 .info = alc_ch_mode_info,
3989 .get = alc_ch_mode_get,
3990 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003991 },
3992 { } /* end */
3993};
3994
3995static struct hda_verb alc880_test_init_verbs[] = {
3996 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003997 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3998 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4001 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4003 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4004 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004005 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004006 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4007 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4008 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4009 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004010 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4013 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4014 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004015 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004016 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4017 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4018 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4019 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004020 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004021 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4022 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4024 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4025 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004026 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4028 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4029 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4030 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004031 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004033 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004034 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004035 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004036 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004037 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004038 /* Analog input/passthru */
4039 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4040 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4041 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4042 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4043 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004044 { }
4045};
4046#endif
4047
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048/*
4049 */
4050
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004051static const char *alc880_models[ALC880_MODEL_LAST] = {
4052 [ALC880_3ST] = "3stack",
4053 [ALC880_TCL_S700] = "tcl",
4054 [ALC880_3ST_DIG] = "3stack-digout",
4055 [ALC880_CLEVO] = "clevo",
4056 [ALC880_5ST] = "5stack",
4057 [ALC880_5ST_DIG] = "5stack-digout",
4058 [ALC880_W810] = "w810",
4059 [ALC880_Z71V] = "z71v",
4060 [ALC880_6ST] = "6stack",
4061 [ALC880_6ST_DIG] = "6stack-digout",
4062 [ALC880_ASUS] = "asus",
4063 [ALC880_ASUS_W1V] = "asus-w1v",
4064 [ALC880_ASUS_DIG] = "asus-dig",
4065 [ALC880_ASUS_DIG2] = "asus-dig2",
4066 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004067 [ALC880_UNIWILL_P53] = "uniwill-p53",
4068 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004069 [ALC880_F1734] = "F1734",
4070 [ALC880_LG] = "lg",
4071 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004072 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004073#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004074 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004075#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004076 [ALC880_AUTO] = "auto",
4077};
4078
4079static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004080 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004081 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4082 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4083 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4084 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4085 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4086 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4087 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4088 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004089 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4090 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004091 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4092 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4093 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4094 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4095 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4096 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4097 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4098 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4099 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4100 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004101 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004102 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4103 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4104 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004105 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004106 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004107 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4108 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004109 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4110 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004111 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4112 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4113 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4114 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004115 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4116 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004117 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004118 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004119 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004120 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004121 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4122 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004123 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004124 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004125 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004126 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004127 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004128 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004129 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004130 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004131 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004132 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4133 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004134 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004135 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4136 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4137 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4138 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004139 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4140 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004141 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004142 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004143 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4144 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004145 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4146 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4147 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004148 /* default Intel */
4149 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004150 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4151 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004152 {}
4153};
4154
Takashi Iwai16ded522005-06-10 19:58:24 +02004155/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004156 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004157 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004158static struct alc_config_preset alc880_presets[] = {
4159 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004161 .init_verbs = { alc880_volume_init_verbs,
4162 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004163 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004164 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004165 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4166 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004167 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004168 .input_mux = &alc880_capture_source,
4169 },
4170 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004171 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004172 .init_verbs = { alc880_volume_init_verbs,
4173 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004174 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004175 .dac_nids = alc880_dac_nids,
4176 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004177 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4178 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004179 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004180 .input_mux = &alc880_capture_source,
4181 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004182 [ALC880_TCL_S700] = {
4183 .mixers = { alc880_tcl_s700_mixer },
4184 .init_verbs = { alc880_volume_init_verbs,
4185 alc880_pin_tcl_S700_init_verbs,
4186 alc880_gpio2_init_verbs },
4187 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4188 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004189 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4190 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004191 .hp_nid = 0x03,
4192 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4193 .channel_mode = alc880_2_jack_modes,
4194 .input_mux = &alc880_capture_source,
4195 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004196 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004197 .mixers = { alc880_three_stack_mixer,
4198 alc880_five_stack_mixer},
4199 .init_verbs = { alc880_volume_init_verbs,
4200 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004201 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4202 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004203 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4204 .channel_mode = alc880_fivestack_modes,
4205 .input_mux = &alc880_capture_source,
4206 },
4207 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004208 .mixers = { alc880_three_stack_mixer,
4209 alc880_five_stack_mixer },
4210 .init_verbs = { alc880_volume_init_verbs,
4211 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004212 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4213 .dac_nids = alc880_dac_nids,
4214 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004215 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4216 .channel_mode = alc880_fivestack_modes,
4217 .input_mux = &alc880_capture_source,
4218 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004219 [ALC880_6ST] = {
4220 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004221 .init_verbs = { alc880_volume_init_verbs,
4222 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004223 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4224 .dac_nids = alc880_6st_dac_nids,
4225 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4226 .channel_mode = alc880_sixstack_modes,
4227 .input_mux = &alc880_6stack_capture_source,
4228 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004229 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004231 .init_verbs = { alc880_volume_init_verbs,
4232 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004233 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4234 .dac_nids = alc880_6st_dac_nids,
4235 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004236 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4237 .channel_mode = alc880_sixstack_modes,
4238 .input_mux = &alc880_6stack_capture_source,
4239 },
4240 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004241 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004242 .init_verbs = { alc880_volume_init_verbs,
4243 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004244 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004245 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4246 .dac_nids = alc880_w810_dac_nids,
4247 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004248 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4249 .channel_mode = alc880_w810_modes,
4250 .input_mux = &alc880_capture_source,
4251 },
4252 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004253 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004254 .init_verbs = { alc880_volume_init_verbs,
4255 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004256 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4257 .dac_nids = alc880_z71v_dac_nids,
4258 .dig_out_nid = ALC880_DIGOUT_NID,
4259 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004260 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4261 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004262 .input_mux = &alc880_capture_source,
4263 },
4264 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004265 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004266 .init_verbs = { alc880_volume_init_verbs,
4267 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004268 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4269 .dac_nids = alc880_f1734_dac_nids,
4270 .hp_nid = 0x02,
4271 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4272 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004273 .input_mux = &alc880_f1734_capture_source,
4274 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004275 .setup = alc880_uniwill_p53_setup,
4276 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004277 },
4278 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004279 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004280 .init_verbs = { alc880_volume_init_verbs,
4281 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004282 alc880_gpio1_init_verbs },
4283 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4284 .dac_nids = alc880_asus_dac_nids,
4285 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4286 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004287 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004288 .input_mux = &alc880_capture_source,
4289 },
4290 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004291 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004292 .init_verbs = { alc880_volume_init_verbs,
4293 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004294 alc880_gpio1_init_verbs },
4295 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4296 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004297 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004298 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4299 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004300 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004301 .input_mux = &alc880_capture_source,
4302 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004303 [ALC880_ASUS_DIG2] = {
4304 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004305 .init_verbs = { alc880_volume_init_verbs,
4306 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004307 alc880_gpio2_init_verbs }, /* use GPIO2 */
4308 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4309 .dac_nids = alc880_asus_dac_nids,
4310 .dig_out_nid = ALC880_DIGOUT_NID,
4311 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4312 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004313 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004314 .input_mux = &alc880_capture_source,
4315 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004316 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004317 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004318 .init_verbs = { alc880_volume_init_verbs,
4319 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004320 alc880_gpio1_init_verbs },
4321 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4322 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004323 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004324 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4325 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004326 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004327 .input_mux = &alc880_capture_source,
4328 },
4329 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004330 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004331 .init_verbs = { alc880_volume_init_verbs,
4332 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004333 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4334 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004335 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004336 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4337 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004338 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004339 .input_mux = &alc880_capture_source,
4340 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004341 [ALC880_UNIWILL] = {
4342 .mixers = { alc880_uniwill_mixer },
4343 .init_verbs = { alc880_volume_init_verbs,
4344 alc880_uniwill_init_verbs },
4345 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4346 .dac_nids = alc880_asus_dac_nids,
4347 .dig_out_nid = ALC880_DIGOUT_NID,
4348 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4349 .channel_mode = alc880_threestack_modes,
4350 .need_dac_fix = 1,
4351 .input_mux = &alc880_capture_source,
4352 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004353 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004354 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004355 },
4356 [ALC880_UNIWILL_P53] = {
4357 .mixers = { alc880_uniwill_p53_mixer },
4358 .init_verbs = { alc880_volume_init_verbs,
4359 alc880_uniwill_p53_init_verbs },
4360 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4361 .dac_nids = alc880_asus_dac_nids,
4362 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004363 .channel_mode = alc880_threestack_modes,
4364 .input_mux = &alc880_capture_source,
4365 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004366 .setup = alc880_uniwill_p53_setup,
4367 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004368 },
4369 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004370 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004371 .init_verbs = { alc880_volume_init_verbs,
4372 alc880_uniwill_p53_init_verbs,
4373 alc880_beep_init_verbs },
4374 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4375 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004376 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004377 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4378 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004379 .input_mux = &alc880_capture_source,
4380 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004381 .setup = alc880_uniwill_p53_setup,
4382 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004383 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004384 [ALC880_CLEVO] = {
4385 .mixers = { alc880_three_stack_mixer },
4386 .init_verbs = { alc880_volume_init_verbs,
4387 alc880_pin_clevo_init_verbs },
4388 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4389 .dac_nids = alc880_dac_nids,
4390 .hp_nid = 0x03,
4391 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4392 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004393 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004394 .input_mux = &alc880_capture_source,
4395 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004396 [ALC880_LG] = {
4397 .mixers = { alc880_lg_mixer },
4398 .init_verbs = { alc880_volume_init_verbs,
4399 alc880_lg_init_verbs },
4400 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4401 .dac_nids = alc880_lg_dac_nids,
4402 .dig_out_nid = ALC880_DIGOUT_NID,
4403 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4404 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004405 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004406 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004407 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004408 .setup = alc880_lg_setup,
4409 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004410#ifdef CONFIG_SND_HDA_POWER_SAVE
4411 .loopbacks = alc880_lg_loopbacks,
4412#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004413 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004414 [ALC880_LG_LW] = {
4415 .mixers = { alc880_lg_lw_mixer },
4416 .init_verbs = { alc880_volume_init_verbs,
4417 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004418 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004419 .dac_nids = alc880_dac_nids,
4420 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004421 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4422 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004423 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004424 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004425 .setup = alc880_lg_lw_setup,
4426 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004427 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004428 [ALC880_MEDION_RIM] = {
4429 .mixers = { alc880_medion_rim_mixer },
4430 .init_verbs = { alc880_volume_init_verbs,
4431 alc880_medion_rim_init_verbs,
4432 alc_gpio2_init_verbs },
4433 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4434 .dac_nids = alc880_dac_nids,
4435 .dig_out_nid = ALC880_DIGOUT_NID,
4436 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4437 .channel_mode = alc880_2_jack_modes,
4438 .input_mux = &alc880_medion_rim_capture_source,
4439 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004440 .setup = alc880_medion_rim_setup,
4441 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004442 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004443#ifdef CONFIG_SND_DEBUG
4444 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004445 .mixers = { alc880_test_mixer },
4446 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004447 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4448 .dac_nids = alc880_test_dac_nids,
4449 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004450 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4451 .channel_mode = alc880_test_modes,
4452 .input_mux = &alc880_test_capture_source,
4453 },
4454#endif
4455};
4456
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004457/*
4458 * Automatic parse of I/O pins from the BIOS configuration
4459 */
4460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004461enum {
4462 ALC_CTL_WIDGET_VOL,
4463 ALC_CTL_WIDGET_MUTE,
4464 ALC_CTL_BIND_MUTE,
4465};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004466static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004467 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4468 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004469 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004470};
4471
4472/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004473static int add_control(struct alc_spec *spec, int type, const char *name,
4474 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004475{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004476 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004477
Takashi Iwai603c4012008-07-30 15:01:44 +02004478 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4479 knew = snd_array_new(&spec->kctls);
4480 if (!knew)
4481 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004482 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004483 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004484 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004485 return -ENOMEM;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004486 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004487 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004488 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004489 return 0;
4490}
4491
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004492static int add_control_with_pfx(struct alc_spec *spec, int type,
4493 const char *pfx, const char *dir,
4494 const char *sfx, unsigned long val)
4495{
4496 char name[32];
4497 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
4498 return add_control(spec, type, name, val);
4499}
4500
4501#define add_pb_vol_ctrl(spec, type, pfx, val) \
4502 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", val)
4503#define add_pb_sw_ctrl(spec, type, pfx, val) \
4504 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", val)
4505
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004506#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4507#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4508#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4509#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004510#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4511#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4512#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4513#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4514#define ALC880_PIN_CD_NID 0x1c
4515
4516/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004517static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4518 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004519{
4520 hda_nid_t nid;
4521 int assigned[4];
4522 int i, j;
4523
4524 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004525 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004526
4527 /* check the pins hardwired to audio widget */
4528 for (i = 0; i < cfg->line_outs; i++) {
4529 nid = cfg->line_out_pins[i];
4530 if (alc880_is_fixed_pin(nid)) {
4531 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004532 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004533 assigned[idx] = 1;
4534 }
4535 }
4536 /* left pins can be connect to any audio widget */
4537 for (i = 0; i < cfg->line_outs; i++) {
4538 nid = cfg->line_out_pins[i];
4539 if (alc880_is_fixed_pin(nid))
4540 continue;
4541 /* search for an empty channel */
4542 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004543 if (!assigned[j]) {
4544 spec->multiout.dac_nids[i] =
4545 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004546 assigned[j] = 1;
4547 break;
4548 }
4549 }
4550 }
4551 spec->multiout.num_dacs = cfg->line_outs;
4552 return 0;
4553}
4554
4555/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004556static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4557 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004558{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004559 static const char *chname[4] = {
4560 "Front", "Surround", NULL /*CLFE*/, "Side"
4561 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004562 hda_nid_t nid;
4563 int i, err;
4564
4565 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004566 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004567 continue;
4568 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4569 if (i == 2) {
4570 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004571 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4572 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004573 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4574 HDA_OUTPUT));
4575 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004576 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004577 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4578 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004579 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4580 HDA_OUTPUT));
4581 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004582 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004583 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4584 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004585 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4586 HDA_INPUT));
4587 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004588 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004589 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4590 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004591 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4592 HDA_INPUT));
4593 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004594 return err;
4595 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004596 const char *pfx;
4597 if (cfg->line_outs == 1 &&
4598 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4599 pfx = "Speaker";
4600 else
4601 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004602 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004603 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4604 HDA_OUTPUT));
4605 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004606 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004607 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004608 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4609 HDA_INPUT));
4610 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004611 return err;
4612 }
4613 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 return 0;
4615}
4616
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004617/* add playback controls for speaker and HP outputs */
4618static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4619 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004620{
4621 hda_nid_t nid;
4622 int err;
4623
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004624 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 return 0;
4626
4627 if (alc880_is_fixed_pin(pin)) {
4628 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004629 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004630 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004631 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004632 else
4633 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004634 /* control HP volume/switch on the output mixer amp */
4635 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004636 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004637 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
4638 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004640 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004641 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
4642 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004643 return err;
4644 } else if (alc880_is_multi_pin(pin)) {
4645 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004646 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004647 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004648 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
4649 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004650 return err;
4651 }
4652 return 0;
4653}
4654
4655/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004656static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
4657 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01004658 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004659{
Kailang Yangdf694da2005-12-05 19:42:22 +01004660 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004661
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004662 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004663 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4664 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004665 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004666 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004667 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
4668 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004669 return err;
4670 return 0;
4671}
4672
Takashi Iwai05f5f472009-08-25 13:10:18 +02004673static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004674{
Takashi Iwai05f5f472009-08-25 13:10:18 +02004675 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
4676 return (pincap & AC_PINCAP_IN) != 0;
4677}
4678
4679/* create playback/capture controls for input pins */
4680static int alc_auto_create_input_ctls(struct hda_codec *codec,
4681 const struct auto_pin_cfg *cfg,
4682 hda_nid_t mixer,
4683 hda_nid_t cap1, hda_nid_t cap2)
4684{
4685 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004686 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01004687 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004688
4689 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02004690 hda_nid_t pin;
4691
4692 pin = cfg->input_pins[i];
4693 if (!alc_is_input_pin(codec, pin))
4694 continue;
4695
4696 if (mixer) {
4697 idx = get_connection_index(codec, mixer, pin);
4698 if (idx >= 0) {
4699 err = new_analog_input(spec, pin,
4700 auto_pin_cfg_labels[i],
4701 idx, mixer);
4702 if (err < 0)
4703 return err;
4704 }
4705 }
4706
4707 if (!cap1)
4708 continue;
4709 idx = get_connection_index(codec, cap1, pin);
4710 if (idx < 0 && cap2)
4711 idx = get_connection_index(codec, cap2, pin);
4712 if (idx >= 0) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004713 imux->items[imux->num_items].label =
4714 auto_pin_cfg_labels[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004715 imux->items[imux->num_items].index = idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004716 imux->num_items++;
4717 }
4718 }
4719 return 0;
4720}
4721
Takashi Iwai05f5f472009-08-25 13:10:18 +02004722static int alc880_auto_create_input_ctls(struct hda_codec *codec,
4723 const struct auto_pin_cfg *cfg)
4724{
4725 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
4726}
4727
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004728static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
4729 unsigned int pin_type)
4730{
4731 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4732 pin_type);
4733 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01004734 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
4735 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004736}
4737
Kailang Yangdf694da2005-12-05 19:42:22 +01004738static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
4739 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004740 int dac_idx)
4741{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004742 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004743 /* need the manual connection? */
4744 if (alc880_is_multi_pin(nid)) {
4745 struct alc_spec *spec = codec->spec;
4746 int idx = alc880_multi_pin_idx(nid);
4747 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
4748 AC_VERB_SET_CONNECT_SEL,
4749 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4750 }
4751}
4752
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004753static int get_pin_type(int line_out_type)
4754{
4755 if (line_out_type == AUTO_PIN_HP_OUT)
4756 return PIN_HP;
4757 else
4758 return PIN_OUT;
4759}
4760
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004761static void alc880_auto_init_multi_out(struct hda_codec *codec)
4762{
4763 struct alc_spec *spec = codec->spec;
4764 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004765
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004766 for (i = 0; i < spec->autocfg.line_outs; i++) {
4767 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004768 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4769 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004770 }
4771}
4772
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004773static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004774{
4775 struct alc_spec *spec = codec->spec;
4776 hda_nid_t pin;
4777
Takashi Iwai82bc9552006-03-21 11:24:42 +01004778 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004779 if (pin) /* connect to front */
4780 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004781 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004782 if (pin) /* connect to front */
4783 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4784}
4785
4786static void alc880_auto_init_analog_input(struct hda_codec *codec)
4787{
4788 struct alc_spec *spec = codec->spec;
4789 int i;
4790
4791 for (i = 0; i < AUTO_PIN_LAST; i++) {
4792 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +02004793 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01004794 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01004795 if (nid != ALC880_PIN_CD_NID &&
4796 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004797 snd_hda_codec_write(codec, nid, 0,
4798 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004799 AMP_OUT_MUTE);
4800 }
4801 }
4802}
4803
4804/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004805/* return 1 if successful, 0 if the proper config is not found,
4806 * or a negative error code
4807 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004808static int alc880_parse_auto_config(struct hda_codec *codec)
4809{
4810 struct alc_spec *spec = codec->spec;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004811 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004812 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004813
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004814 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4815 alc880_ignore);
4816 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004818 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004819 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004820
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004821 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4822 if (err < 0)
4823 return err;
4824 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4825 if (err < 0)
4826 return err;
4827 err = alc880_auto_create_extra_out(spec,
4828 spec->autocfg.speaker_pins[0],
4829 "Speaker");
4830 if (err < 0)
4831 return err;
4832 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4833 "Headphone");
4834 if (err < 0)
4835 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02004836 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004837 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004838 return err;
4839
4840 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4841
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004842 /* check multiple SPDIF-out (for recent codecs) */
4843 for (i = 0; i < spec->autocfg.dig_outs; i++) {
4844 hda_nid_t dig_nid;
4845 err = snd_hda_get_connections(codec,
4846 spec->autocfg.dig_out_pins[i],
4847 &dig_nid, 1);
4848 if (err < 0)
4849 continue;
4850 if (!i)
4851 spec->multiout.dig_out_nid = dig_nid;
4852 else {
4853 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004854 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004855 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +01004856 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +01004857 }
4858 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004859 if (spec->autocfg.dig_in_pin)
4860 spec->dig_in_nid = ALC880_DIGIN_NID;
4861
Takashi Iwai603c4012008-07-30 15:01:44 +02004862 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004863 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004864
Takashi Iwaid88897e2008-10-31 15:01:37 +01004865 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004867 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02004868 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869
Kailang Yang6227cdc2010-02-25 08:36:52 +01004870 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02004871
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004872 return 1;
4873}
4874
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004875/* additional initialization for auto-configuration model */
4876static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004877{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004878 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004879 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004880 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004881 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004882 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004883 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884}
4885
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004886/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
4887 * one of two digital mic pins, e.g. on ALC272
4888 */
4889static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004890{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004891 struct alc_spec *spec = codec->spec;
4892 int i;
4893
4894 for (i = 0; i < spec->num_adc_nids; i++) {
4895 hda_nid_t cap = spec->capsrc_nids ?
4896 spec->capsrc_nids[i] : spec->adc_nids[i];
4897 int iidx, eidx;
4898
4899 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
4900 if (iidx < 0)
4901 continue;
4902 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
4903 if (eidx < 0)
4904 continue;
4905 spec->int_mic.mux_idx = iidx;
4906 spec->ext_mic.mux_idx = eidx;
4907 if (spec->capsrc_nids)
4908 spec->capsrc_nids += i;
4909 spec->adc_nids += i;
4910 spec->num_adc_nids = 1;
4911 return;
4912 }
4913 snd_printd(KERN_INFO "hda_codec: %s: "
4914 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
4915 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
4916 spec->auto_mic = 0; /* disable auto-mic to be sure */
4917}
4918
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004919/* choose the ADC/MUX containing the input pin and initialize the setup */
4920static void fixup_single_adc(struct hda_codec *codec)
4921{
4922 struct alc_spec *spec = codec->spec;
Frederik Deweerdtd2db09b2010-03-05 16:34:31 +01004923 hda_nid_t pin = 0;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004924 int i;
4925
4926 /* search for the input pin; there must be only one */
4927 for (i = 0; i < AUTO_PIN_LAST; i++) {
4928 if (spec->autocfg.input_pins[i]) {
4929 pin = spec->autocfg.input_pins[i];
4930 break;
4931 }
4932 }
4933 if (!pin)
4934 return;
4935
4936 /* set the default connection to that pin */
4937 for (i = 0; i < spec->num_adc_nids; i++) {
4938 hda_nid_t cap = spec->capsrc_nids ?
4939 spec->capsrc_nids[i] : spec->adc_nids[i];
4940 int idx;
4941
4942 idx = get_connection_index(codec, cap, pin);
4943 if (idx < 0)
4944 continue;
4945 /* use only this ADC */
4946 if (spec->capsrc_nids)
4947 spec->capsrc_nids += i;
4948 spec->adc_nids += i;
4949 spec->num_adc_nids = 1;
4950 /* select or unmute this route */
4951 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
4952 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
4953 HDA_AMP_MUTE, 0);
4954 } else {
4955 snd_hda_codec_write_cache(codec, cap, 0,
4956 AC_VERB_SET_CONNECT_SEL, idx);
4957 }
4958 return;
4959 }
4960}
4961
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004962static void set_capture_mixer(struct hda_codec *codec)
4963{
4964 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01004965 static struct snd_kcontrol_new *caps[2][3] = {
4966 { alc_capture_mixer_nosrc1,
4967 alc_capture_mixer_nosrc2,
4968 alc_capture_mixer_nosrc3 },
4969 { alc_capture_mixer1,
4970 alc_capture_mixer2,
4971 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004972 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01004973 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004974 int mux = 0;
4975 if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02004976 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01004977 else if (spec->input_mux) {
4978 if (spec->input_mux->num_items > 1)
4979 mux = 1;
4980 else if (spec->input_mux->num_items == 1)
4981 fixup_single_adc(codec);
4982 }
Takashi Iwaia23b6882009-03-23 15:21:36 +01004983 spec->cap_mixer = caps[mux][spec->num_adc_nids - 1];
4984 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004985}
4986
Takashi Iwai67d634c2009-11-16 15:35:59 +01004987#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004988#define set_beep_amp(spec, nid, idx, dir) \
4989 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwai67d634c2009-11-16 15:35:59 +01004990#else
4991#define set_beep_amp(spec, nid, idx, dir) /* NOP */
4992#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004993
4994/*
4995 * OK, here we have finally the patch for ALC880
4996 */
4997
Linus Torvalds1da177e2005-04-16 15:20:36 -07004998static int patch_alc880(struct hda_codec *codec)
4999{
5000 struct alc_spec *spec;
5001 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005002 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005003
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005004 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005005 if (spec == NULL)
5006 return -ENOMEM;
5007
5008 codec->spec = spec;
5009
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005010 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5011 alc880_models,
5012 alc880_cfg_tbl);
5013 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005014 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5015 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005016 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005017 }
5018
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005019 if (board_config == ALC880_AUTO) {
5020 /* automatic parse from the BIOS config */
5021 err = alc880_parse_auto_config(codec);
5022 if (err < 0) {
5023 alc_free(codec);
5024 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005025 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005026 printk(KERN_INFO
5027 "hda_codec: Cannot set up configuration "
5028 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005029 board_config = ALC880_3ST;
5030 }
5031 }
5032
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005033 err = snd_hda_attach_beep_device(codec, 0x1);
5034 if (err < 0) {
5035 alc_free(codec);
5036 return err;
5037 }
5038
Kailang Yangdf694da2005-12-05 19:42:22 +01005039 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005040 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005041
Linus Torvalds1da177e2005-04-16 15:20:36 -07005042 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5043 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005044 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005045
Linus Torvalds1da177e2005-04-16 15:20:36 -07005046 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5047 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5048
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005049 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005051 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005052 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005053 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 if (wcap != AC_WID_AUD_IN) {
5055 spec->adc_nids = alc880_adc_nids_alt;
5056 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005057 } else {
5058 spec->adc_nids = alc880_adc_nids;
5059 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005060 }
5061 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005062 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005063 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005064
Takashi Iwai2134ea42008-01-10 16:53:55 +01005065 spec->vmaster_nid = 0x0c;
5066
Linus Torvalds1da177e2005-04-16 15:20:36 -07005067 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005068 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005069 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005070#ifdef CONFIG_SND_HDA_POWER_SAVE
5071 if (!spec->loopback.amplist)
5072 spec->loopback.amplist = alc880_loopbacks;
5073#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005074
5075 return 0;
5076}
5077
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005078
Linus Torvalds1da177e2005-04-16 15:20:36 -07005079/*
5080 * ALC260 support
5081 */
5082
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005083static hda_nid_t alc260_dac_nids[1] = {
5084 /* front */
5085 0x02,
5086};
5087
5088static hda_nid_t alc260_adc_nids[1] = {
5089 /* ADC0 */
5090 0x04,
5091};
5092
Kailang Yangdf694da2005-12-05 19:42:22 +01005093static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005094 /* ADC1 */
5095 0x05,
5096};
5097
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005098/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5099 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5100 */
5101static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005102 /* ADC0, ADC1 */
5103 0x04, 0x05
5104};
5105
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005106#define ALC260_DIGOUT_NID 0x03
5107#define ALC260_DIGIN_NID 0x06
5108
5109static struct hda_input_mux alc260_capture_source = {
5110 .num_items = 4,
5111 .items = {
5112 { "Mic", 0x0 },
5113 { "Front Mic", 0x1 },
5114 { "Line", 0x2 },
5115 { "CD", 0x4 },
5116 },
5117};
5118
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005119/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005120 * headphone jack and the internal CD lines since these are the only pins at
5121 * which audio can appear. For flexibility, also allow the option of
5122 * recording the mixer output on the second ADC (ADC0 doesn't have a
5123 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005124 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005125static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5126 {
5127 .num_items = 3,
5128 .items = {
5129 { "Mic/Line", 0x0 },
5130 { "CD", 0x4 },
5131 { "Headphone", 0x2 },
5132 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005133 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005134 {
5135 .num_items = 4,
5136 .items = {
5137 { "Mic/Line", 0x0 },
5138 { "CD", 0x4 },
5139 { "Headphone", 0x2 },
5140 { "Mixer", 0x5 },
5141 },
5142 },
5143
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005144};
5145
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005146/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5147 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005148 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005149static struct hda_input_mux alc260_acer_capture_sources[2] = {
5150 {
5151 .num_items = 4,
5152 .items = {
5153 { "Mic", 0x0 },
5154 { "Line", 0x2 },
5155 { "CD", 0x4 },
5156 { "Headphone", 0x5 },
5157 },
5158 },
5159 {
5160 .num_items = 5,
5161 .items = {
5162 { "Mic", 0x0 },
5163 { "Line", 0x2 },
5164 { "CD", 0x4 },
5165 { "Headphone", 0x6 },
5166 { "Mixer", 0x5 },
5167 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005168 },
5169};
Michael Schwingencc959482009-02-22 18:58:45 +01005170
5171/* Maxdata Favorit 100XS */
5172static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5173 {
5174 .num_items = 2,
5175 .items = {
5176 { "Line/Mic", 0x0 },
5177 { "CD", 0x4 },
5178 },
5179 },
5180 {
5181 .num_items = 3,
5182 .items = {
5183 { "Line/Mic", 0x0 },
5184 { "CD", 0x4 },
5185 { "Mixer", 0x5 },
5186 },
5187 },
5188};
5189
Linus Torvalds1da177e2005-04-16 15:20:36 -07005190/*
5191 * This is just place-holder, so there's something for alc_build_pcms to look
5192 * at when it calculates the maximum number of channels. ALC260 has no mixer
5193 * element which allows changing the channel mode, so the verb list is
5194 * never used.
5195 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005196static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005197 { 2, NULL },
5198};
5199
Kailang Yangdf694da2005-12-05 19:42:22 +01005200
5201/* Mixer combinations
5202 *
5203 * basic: base_output + input + pc_beep + capture
5204 * HP: base_output + input + capture_alt
5205 * HP_3013: hp_3013 + input + capture
5206 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005207 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005208 */
5209
5210static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005211 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005212 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005213 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5214 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5215 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5216 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5217 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005218};
Kailang Yangdf694da2005-12-05 19:42:22 +01005219
5220static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005221 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5222 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5223 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5224 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5225 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5226 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5227 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005229 { } /* end */
5230};
5231
Takashi Iwaibec15c32008-01-28 18:16:30 +01005232/* update HP, line and mono out pins according to the master switch */
5233static void alc260_hp_master_update(struct hda_codec *codec,
5234 hda_nid_t hp, hda_nid_t line,
5235 hda_nid_t mono)
5236{
5237 struct alc_spec *spec = codec->spec;
5238 unsigned int val = spec->master_sw ? PIN_HP : 0;
5239 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005240 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005241 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005242 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005243 val);
5244 /* mono (speaker) depending on the HP jack sense */
5245 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005246 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005247 val);
5248}
5249
5250static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5251 struct snd_ctl_elem_value *ucontrol)
5252{
5253 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5254 struct alc_spec *spec = codec->spec;
5255 *ucontrol->value.integer.value = spec->master_sw;
5256 return 0;
5257}
5258
5259static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5260 struct snd_ctl_elem_value *ucontrol)
5261{
5262 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5263 struct alc_spec *spec = codec->spec;
5264 int val = !!*ucontrol->value.integer.value;
5265 hda_nid_t hp, line, mono;
5266
5267 if (val == spec->master_sw)
5268 return 0;
5269 spec->master_sw = val;
5270 hp = (kcontrol->private_value >> 16) & 0xff;
5271 line = (kcontrol->private_value >> 8) & 0xff;
5272 mono = kcontrol->private_value & 0xff;
5273 alc260_hp_master_update(codec, hp, line, mono);
5274 return 1;
5275}
5276
5277static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5278 {
5279 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5280 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005281 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005282 .info = snd_ctl_boolean_mono_info,
5283 .get = alc260_hp_master_sw_get,
5284 .put = alc260_hp_master_sw_put,
5285 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5286 },
5287 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5288 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5289 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5290 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5291 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5292 HDA_OUTPUT),
5293 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5294 { } /* end */
5295};
5296
5297static struct hda_verb alc260_hp_unsol_verbs[] = {
5298 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5299 {},
5300};
5301
5302static void alc260_hp_automute(struct hda_codec *codec)
5303{
5304 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005305
Wu Fengguang864f92b2009-11-18 12:38:02 +08005306 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005307 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5308}
5309
5310static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5311{
5312 if ((res >> 26) == ALC880_HP_EVENT)
5313 alc260_hp_automute(codec);
5314}
5315
Kailang Yangdf694da2005-12-05 19:42:22 +01005316static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005317 {
5318 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5319 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005320 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005321 .info = snd_ctl_boolean_mono_info,
5322 .get = alc260_hp_master_sw_get,
5323 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005324 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005325 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005326 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5327 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5328 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5329 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5330 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005332 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5333 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005334 { } /* end */
5335};
5336
Kailang Yang3f878302008-08-26 13:02:23 +02005337static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5338 .ops = &snd_hda_bind_vol,
5339 .values = {
5340 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5341 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5342 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5343 0
5344 },
5345};
5346
5347static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5348 .ops = &snd_hda_bind_sw,
5349 .values = {
5350 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5351 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5352 0
5353 },
5354};
5355
5356static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5357 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5358 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5359 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5361 { } /* end */
5362};
5363
Takashi Iwaibec15c32008-01-28 18:16:30 +01005364static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5365 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5366 {},
5367};
5368
5369static void alc260_hp_3013_automute(struct hda_codec *codec)
5370{
5371 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005372
Wu Fengguang864f92b2009-11-18 12:38:02 +08005373 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005374 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005375}
5376
5377static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5378 unsigned int res)
5379{
5380 if ((res >> 26) == ALC880_HP_EVENT)
5381 alc260_hp_3013_automute(codec);
5382}
5383
Kailang Yang3f878302008-08-26 13:02:23 +02005384static void alc260_hp_3012_automute(struct hda_codec *codec)
5385{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005386 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005387
Kailang Yang3f878302008-08-26 13:02:23 +02005388 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5389 bits);
5390 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5391 bits);
5392 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5393 bits);
5394}
5395
5396static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5397 unsigned int res)
5398{
5399 if ((res >> 26) == ALC880_HP_EVENT)
5400 alc260_hp_3012_automute(codec);
5401}
5402
5403/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005404 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5405 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005406static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005407 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005408 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005409 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005410 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5411 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5412 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5413 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005414 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005415 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5416 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 { } /* end */
5418};
5419
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005420/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5421 * versions of the ALC260 don't act on requests to enable mic bias from NID
5422 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5423 * datasheet doesn't mention this restriction. At this stage it's not clear
5424 * whether this behaviour is intentional or is a hardware bug in chip
5425 * revisions available in early 2006. Therefore for now allow the
5426 * "Headphone Jack Mode" control to span all choices, but if it turns out
5427 * that the lack of mic bias for this NID is intentional we could change the
5428 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5429 *
5430 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5431 * don't appear to make the mic bias available from the "line" jack, even
5432 * though the NID used for this jack (0x14) can supply it. The theory is
5433 * that perhaps Acer have included blocking capacitors between the ALC260
5434 * and the output jack. If this turns out to be the case for all such
5435 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5436 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005437 *
5438 * The C20x Tablet series have a mono internal speaker which is controlled
5439 * via the chip's Mono sum widget and pin complex, so include the necessary
5440 * controls for such models. On models without a "mono speaker" the control
5441 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005442 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005443static struct snd_kcontrol_new alc260_acer_mixer[] = {
5444 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5445 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005446 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005447 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005448 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005449 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005450 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005451 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5452 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5454 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5455 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5456 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5457 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5458 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005459 { } /* end */
5460};
5461
Michael Schwingencc959482009-02-22 18:58:45 +01005462/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5463 */
5464static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5465 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5466 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5467 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5468 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5469 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5470 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5471 { } /* end */
5472};
5473
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005474/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5475 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5476 */
5477static struct snd_kcontrol_new alc260_will_mixer[] = {
5478 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5479 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5481 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5482 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5483 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5484 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5485 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5486 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5487 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005488 { } /* end */
5489};
5490
5491/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5492 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5493 */
5494static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5495 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5496 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5498 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5499 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5500 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5501 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5502 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5503 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5504 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5505 { } /* end */
5506};
5507
Kailang Yangdf694da2005-12-05 19:42:22 +01005508/*
5509 * initialization verbs
5510 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511static struct hda_verb alc260_init_verbs[] = {
5512 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005513 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005514 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005515 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005516 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005517 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005519 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005520 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005523 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005524 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02005525 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005526 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02005527 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005528 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02005529 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5530 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02005531 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005532 /* set connection select to line in (default select for this ADC) */
5533 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02005534 /* mute capture amp left and right */
5535 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5536 /* set connection select to line in (default select for this ADC) */
5537 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02005538 /* set vol=0 Line-Out mixer amp left and right */
5539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5540 /* unmute pin widget amp left and right (no gain on this amp) */
5541 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5542 /* set vol=0 HP mixer amp left and right */
5543 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5544 /* unmute pin widget amp left and right (no gain on this amp) */
5545 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5546 /* set vol=0 Mono mixer amp left and right */
5547 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5548 /* unmute pin widget amp left and right (no gain on this amp) */
5549 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5550 /* unmute LINE-2 out pin */
5551 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005552 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5553 * Line In 2 = 0x03
5554 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005555 /* mute analog inputs */
5556 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5557 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5559 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5560 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005561 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005562 /* mute Front out path */
5563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5564 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5565 /* mute Headphone out path */
5566 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5568 /* mute Mono out path */
5569 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5570 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005571 { }
5572};
5573
Takashi Iwai474167d2006-05-17 17:17:43 +02005574#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01005575static struct hda_verb alc260_hp_init_verbs[] = {
5576 /* Headphone and output */
5577 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5578 /* mono output */
5579 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5580 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5581 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5582 /* Mic2 (front panel) pin widget for input and vref at 80% */
5583 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5584 /* Line In pin widget for input */
5585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5586 /* Line-2 pin widget for output */
5587 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5588 /* CD pin widget for input */
5589 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5590 /* unmute amp left and right */
5591 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5592 /* set connection select to line in (default select for this ADC) */
5593 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5594 /* unmute Line-Out mixer amp left and right (volume = 0) */
5595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5596 /* mute pin widget amp left and right (no gain on this amp) */
5597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5598 /* unmute HP mixer amp left and right (volume = 0) */
5599 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5600 /* mute pin widget amp left and right (no gain on this amp) */
5601 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005602 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5603 * Line In 2 = 0x03
5604 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005605 /* mute analog inputs */
5606 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5607 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5609 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5610 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005611 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5612 /* Unmute Front out path */
5613 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5614 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5615 /* Unmute Headphone out path */
5616 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5617 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5618 /* Unmute Mono out path */
5619 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5620 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5621 { }
5622};
Takashi Iwai474167d2006-05-17 17:17:43 +02005623#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005624
5625static struct hda_verb alc260_hp_3013_init_verbs[] = {
5626 /* Line out and output */
5627 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5628 /* mono output */
5629 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
5630 /* Mic1 (rear panel) pin widget for input and vref at 80% */
5631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5632 /* Mic2 (front panel) pin widget for input and vref at 80% */
5633 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
5634 /* Line In pin widget for input */
5635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5636 /* Headphone pin widget for output */
5637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
5638 /* CD pin widget for input */
5639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
5640 /* unmute amp left and right */
5641 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
5642 /* set connection select to line in (default select for this ADC) */
5643 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
5644 /* unmute Line-Out mixer amp left and right (volume = 0) */
5645 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5646 /* mute pin widget amp left and right (no gain on this amp) */
5647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
5648 /* unmute HP mixer amp left and right (volume = 0) */
5649 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
5650 /* mute pin widget amp left and right (no gain on this amp) */
5651 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005652 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
5653 * Line In 2 = 0x03
5654 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005655 /* mute analog inputs */
5656 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5657 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5658 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5659 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5660 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005661 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
5662 /* Unmute Front out path */
5663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5664 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5665 /* Unmute Headphone out path */
5666 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5668 /* Unmute Mono out path */
5669 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
5670 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
5671 { }
5672};
5673
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005674/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005675 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
5676 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005677 */
5678static struct hda_verb alc260_fujitsu_init_verbs[] = {
5679 /* Disable all GPIOs */
5680 {0x01, AC_VERB_SET_GPIO_MASK, 0},
5681 /* Internal speaker is connected to headphone pin */
5682 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5683 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
5684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005685 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
5686 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5687 /* Ensure all other unused pins are disabled and muted. */
5688 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5689 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005690 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005691 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005692 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005693 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5694 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5695 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005696
Jonathan Woithef7ace402006-02-28 11:46:14 +01005697 /* Disable digital (SPDIF) pins */
5698 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5699 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005700
Kailang Yangea1fb292008-08-26 12:58:38 +02005701 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01005702 * when acting as an output.
5703 */
5704 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5705
5706 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01005707 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5708 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5709 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5710 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5711 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5712 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5713 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5714 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5715 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005716
Jonathan Woithef7ace402006-02-28 11:46:14 +01005717 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
5718 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5719 /* Unmute Line1 pin widget output buffer since it starts as an output.
5720 * If the pin mode is changed by the user the pin mode control will
5721 * take care of enabling the pin's input/output buffers as needed.
5722 * Therefore there's no need to enable the input buffer at this
5723 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005724 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005725 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02005726 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005727 * mixer ctrl)
5728 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01005729 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005730
Jonathan Woithef7ace402006-02-28 11:46:14 +01005731 /* Mute capture amp left and right */
5732 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005733 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01005734 * in (on mic1 pin)
5735 */
5736 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005737
Jonathan Woithef7ace402006-02-28 11:46:14 +01005738 /* Do the same for the second ADC: mute capture input amp and
5739 * set ADC connection to line in (on mic1 pin)
5740 */
5741 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5742 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005743
Jonathan Woithef7ace402006-02-28 11:46:14 +01005744 /* Mute all inputs to mixer widget (even unconnected ones) */
5745 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5746 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5747 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5748 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5749 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5750 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5751 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5752 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005753
5754 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005755};
5756
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005757/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
5758 * similar laptops (adapted from Fujitsu init verbs).
5759 */
5760static struct hda_verb alc260_acer_init_verbs[] = {
5761 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
5762 * the headphone jack. Turn this on and rely on the standard mute
5763 * methods whenever the user wants to turn these outputs off.
5764 */
5765 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5766 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5767 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5768 /* Internal speaker/Headphone jack is connected to Line-out pin */
5769 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5770 /* Internal microphone/Mic jack is connected to Mic1 pin */
5771 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5772 /* Line In jack is connected to Line1 pin */
5773 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01005774 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
5775 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005776 /* Ensure all other unused pins are disabled and muted. */
5777 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5778 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005779 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5780 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5782 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5783 /* Disable digital (SPDIF) pins */
5784 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5785 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5786
Kailang Yangea1fb292008-08-26 12:58:38 +02005787 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005788 * bus when acting as outputs.
5789 */
5790 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5791 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5792
5793 /* Start with output sum widgets muted and their output gains at min */
5794 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5796 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5797 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5798 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5799 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5800 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5801 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5802 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5803
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005804 /* Unmute Line-out pin widget amp left and right
5805 * (no equiv mixer ctrl)
5806 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005807 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01005808 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
5809 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005810 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5811 * inputs. If the pin mode is changed by the user the pin mode control
5812 * will take care of enabling the pin's input/output buffers as needed.
5813 * Therefore there's no need to enable the input buffer at this
5814 * stage.
5815 */
5816 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5818
5819 /* Mute capture amp left and right */
5820 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5821 /* Set ADC connection select to match default mixer setting - mic
5822 * (on mic1 pin)
5823 */
5824 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5825
5826 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005827 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005828 */
5829 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005830 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005831
5832 /* Mute all inputs to mixer widget (even unconnected ones) */
5833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5835 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5836 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5838 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5839 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5840 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5841
5842 { }
5843};
5844
Michael Schwingencc959482009-02-22 18:58:45 +01005845/* Initialisation sequence for Maxdata Favorit 100XS
5846 * (adapted from Acer init verbs).
5847 */
5848static struct hda_verb alc260_favorit100_init_verbs[] = {
5849 /* GPIO 0 enables the output jack.
5850 * Turn this on and rely on the standard mute
5851 * methods whenever the user wants to turn these outputs off.
5852 */
5853 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5854 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5855 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
5856 /* Line/Mic input jack is connected to Mic1 pin */
5857 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
5858 /* Ensure all other unused pins are disabled and muted. */
5859 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5860 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5861 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5862 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5863 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5864 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5865 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5866 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5867 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
5868 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5869 /* Disable digital (SPDIF) pins */
5870 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5871 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5872
5873 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
5874 * bus when acting as outputs.
5875 */
5876 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5877 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5878
5879 /* Start with output sum widgets muted and their output gains at min */
5880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5881 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5882 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5884 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5885 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5886 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5887 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5888 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5889
5890 /* Unmute Line-out pin widget amp left and right
5891 * (no equiv mixer ctrl)
5892 */
5893 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5894 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
5895 * inputs. If the pin mode is changed by the user the pin mode control
5896 * will take care of enabling the pin's input/output buffers as needed.
5897 * Therefore there's no need to enable the input buffer at this
5898 * stage.
5899 */
5900 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5901
5902 /* Mute capture amp left and right */
5903 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5904 /* Set ADC connection select to match default mixer setting - mic
5905 * (on mic1 pin)
5906 */
5907 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5908
5909 /* Do similar with the second ADC: mute capture input amp and
5910 * set ADC connection to mic to match ALSA's default state.
5911 */
5912 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5913 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5914
5915 /* Mute all inputs to mixer widget (even unconnected ones) */
5916 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5917 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5918 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5919 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5920 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5921 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5922 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5923 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5924
5925 { }
5926};
5927
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005928static struct hda_verb alc260_will_verbs[] = {
5929 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5930 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
5931 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
5932 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5933 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5934 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
5935 {}
5936};
5937
5938static struct hda_verb alc260_replacer_672v_verbs[] = {
5939 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
5940 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
5941 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
5942
5943 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
5944 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
5945 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5946
5947 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5948 {}
5949};
5950
5951/* toggle speaker-output according to the hp-jack state */
5952static void alc260_replacer_672v_automute(struct hda_codec *codec)
5953{
5954 unsigned int present;
5955
5956 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08005957 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005958 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005959 snd_hda_codec_write_cache(codec, 0x01, 0,
5960 AC_VERB_SET_GPIO_DATA, 1);
5961 snd_hda_codec_write_cache(codec, 0x0f, 0,
5962 AC_VERB_SET_PIN_WIDGET_CONTROL,
5963 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005964 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005965 snd_hda_codec_write_cache(codec, 0x01, 0,
5966 AC_VERB_SET_GPIO_DATA, 0);
5967 snd_hda_codec_write_cache(codec, 0x0f, 0,
5968 AC_VERB_SET_PIN_WIDGET_CONTROL,
5969 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005970 }
5971}
5972
5973static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5974 unsigned int res)
5975{
5976 if ((res >> 26) == ALC880_HP_EVENT)
5977 alc260_replacer_672v_automute(codec);
5978}
5979
Kailang Yang3f878302008-08-26 13:02:23 +02005980static struct hda_verb alc260_hp_dc7600_verbs[] = {
5981 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5983 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5984 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5985 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5987 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5988 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5989 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5990 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5991 {}
5992};
5993
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005994/* Test configuration for debugging, modelled after the ALC880 test
5995 * configuration.
5996 */
5997#ifdef CONFIG_SND_DEBUG
5998static hda_nid_t alc260_test_dac_nids[1] = {
5999 0x02,
6000};
6001static hda_nid_t alc260_test_adc_nids[2] = {
6002 0x04, 0x05,
6003};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006004/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006005 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006006 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006007 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006008static struct hda_input_mux alc260_test_capture_sources[2] = {
6009 {
6010 .num_items = 7,
6011 .items = {
6012 { "MIC1 pin", 0x0 },
6013 { "MIC2 pin", 0x1 },
6014 { "LINE1 pin", 0x2 },
6015 { "LINE2 pin", 0x3 },
6016 { "CD pin", 0x4 },
6017 { "LINE-OUT pin", 0x5 },
6018 { "HP-OUT pin", 0x6 },
6019 },
6020 },
6021 {
6022 .num_items = 8,
6023 .items = {
6024 { "MIC1 pin", 0x0 },
6025 { "MIC2 pin", 0x1 },
6026 { "LINE1 pin", 0x2 },
6027 { "LINE2 pin", 0x3 },
6028 { "CD pin", 0x4 },
6029 { "Mixer", 0x5 },
6030 { "LINE-OUT pin", 0x6 },
6031 { "HP-OUT pin", 0x7 },
6032 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006033 },
6034};
6035static struct snd_kcontrol_new alc260_test_mixer[] = {
6036 /* Output driver widgets */
6037 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6038 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6039 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6040 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6041 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6042 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6043
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006044 /* Modes for retasking pin widgets
6045 * Note: the ALC260 doesn't seem to act on requests to enable mic
6046 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6047 * mention this restriction. At this stage it's not clear whether
6048 * this behaviour is intentional or is a hardware bug in chip
6049 * revisions available at least up until early 2006. Therefore for
6050 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6051 * choices, but if it turns out that the lack of mic bias for these
6052 * NIDs is intentional we could change their modes from
6053 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6054 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006055 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6056 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6057 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6058 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6059 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6060 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6061
6062 /* Loopback mixer controls */
6063 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6064 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6065 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6066 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6067 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6068 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6069 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6070 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6071 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6072 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006073 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6074 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6075 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6076 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006077
6078 /* Controls for GPIO pins, assuming they are configured as outputs */
6079 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6080 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6081 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6082 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6083
Jonathan Woithe92621f12006-02-28 11:47:47 +01006084 /* Switches to allow the digital IO pins to be enabled. The datasheet
6085 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006086 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006087 */
6088 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6089 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6090
Jonathan Woithef8225f62008-01-08 12:16:54 +01006091 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6092 * this output to turn on an external amplifier.
6093 */
6094 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6095 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6096
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006097 { } /* end */
6098};
6099static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006100 /* Enable all GPIOs as outputs with an initial value of 0 */
6101 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6102 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6103 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6104
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006105 /* Enable retasking pins as output, initially without power amp */
6106 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6107 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6108 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6109 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6110 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6111 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6112
Jonathan Woithe92621f12006-02-28 11:47:47 +01006113 /* Disable digital (SPDIF) pins initially, but users can enable
6114 * them via a mixer switch. In the case of SPDIF-out, this initverb
6115 * payload also sets the generation to 0, output to be in "consumer"
6116 * PCM format, copyright asserted, no pre-emphasis and no validity
6117 * control.
6118 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006119 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6120 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6121
Kailang Yangea1fb292008-08-26 12:58:38 +02006122 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006123 * OUT1 sum bus when acting as an output.
6124 */
6125 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6126 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6127 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6128 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6129
6130 /* Start with output sum widgets muted and their output gains at min */
6131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6132 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6135 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6137 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6138 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6139 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6140
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006141 /* Unmute retasking pin widget output buffers since the default
6142 * state appears to be output. As the pin mode is changed by the
6143 * user the pin mode control will take care of enabling the pin's
6144 * input/output buffers as needed.
6145 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006146 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6147 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6148 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6149 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6150 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6151 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6152 /* Also unmute the mono-out pin widget */
6153 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6154
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006155 /* Mute capture amp left and right */
6156 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006157 /* Set ADC connection select to match default mixer setting (mic1
6158 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006159 */
6160 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6161
6162 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006163 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006164 */
6165 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6166 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6167
6168 /* Mute all inputs to mixer widget (even unconnected ones) */
6169 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6170 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6171 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6172 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6173 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6174 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6175 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6176 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6177
6178 { }
6179};
6180#endif
6181
Takashi Iwai63300792008-01-24 15:31:36 +01006182#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6183#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006184
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006185#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6186#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6187
Kailang Yangdf694da2005-12-05 19:42:22 +01006188/*
6189 * for BIOS auto-configuration
6190 */
6191
6192static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006193 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006194{
6195 hda_nid_t nid_vol;
6196 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006197 int err;
6198
6199 if (nid >= 0x0f && nid < 0x11) {
6200 nid_vol = nid - 0x7;
6201 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6202 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6203 } else if (nid == 0x11) {
6204 nid_vol = nid - 0x7;
6205 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6206 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6207 } else if (nid >= 0x12 && nid <= 0x15) {
6208 nid_vol = 0x08;
6209 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6210 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6211 } else
6212 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006213
Takashi Iwai863b4512008-10-21 17:01:47 +02006214 if (!(*vol_bits & (1 << nid_vol))) {
6215 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006216 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006217 if (err < 0)
6218 return err;
6219 *vol_bits |= (1 << nid_vol);
6220 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006221 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006222 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006223 return err;
6224 return 1;
6225}
6226
6227/* add playback controls from the parsed DAC table */
6228static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6229 const struct auto_pin_cfg *cfg)
6230{
6231 hda_nid_t nid;
6232 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006233 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006234
6235 spec->multiout.num_dacs = 1;
6236 spec->multiout.dac_nids = spec->private_dac_nids;
6237 spec->multiout.dac_nids[0] = 0x02;
6238
6239 nid = cfg->line_out_pins[0];
6240 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006241 const char *pfx;
6242 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6243 pfx = "Master";
6244 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6245 pfx = "Speaker";
6246 else
6247 pfx = "Front";
6248 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006249 if (err < 0)
6250 return err;
6251 }
6252
Takashi Iwai82bc9552006-03-21 11:24:42 +01006253 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006254 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006255 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006256 if (err < 0)
6257 return err;
6258 }
6259
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006260 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006261 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006262 err = alc260_add_playback_controls(spec, nid, "Headphone",
6263 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006264 if (err < 0)
6265 return err;
6266 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006267 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006268}
6269
6270/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006271static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006272 const struct auto_pin_cfg *cfg)
6273{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006274 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006275}
6276
6277static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6278 hda_nid_t nid, int pin_type,
6279 int sel_idx)
6280{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006281 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006282 /* need the manual connection? */
6283 if (nid >= 0x12) {
6284 int idx = nid - 0x12;
6285 snd_hda_codec_write(codec, idx + 0x0b, 0,
6286 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006287 }
6288}
6289
6290static void alc260_auto_init_multi_out(struct hda_codec *codec)
6291{
6292 struct alc_spec *spec = codec->spec;
6293 hda_nid_t nid;
6294
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006295 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006296 if (nid) {
6297 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6298 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6299 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006300
Takashi Iwai82bc9552006-03-21 11:24:42 +01006301 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006302 if (nid)
6303 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6304
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006305 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006306 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006307 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006308}
Kailang Yangdf694da2005-12-05 19:42:22 +01006309
6310#define ALC260_PIN_CD_NID 0x16
6311static void alc260_auto_init_analog_input(struct hda_codec *codec)
6312{
6313 struct alc_spec *spec = codec->spec;
6314 int i;
6315
6316 for (i = 0; i < AUTO_PIN_LAST; i++) {
6317 hda_nid_t nid = spec->autocfg.input_pins[i];
6318 if (nid >= 0x12) {
Takashi Iwai23f0c042009-02-26 13:03:58 +01006319 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006320 if (nid != ALC260_PIN_CD_NID &&
6321 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006322 snd_hda_codec_write(codec, nid, 0,
6323 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006324 AMP_OUT_MUTE);
6325 }
6326 }
6327}
6328
6329/*
6330 * generic initialization of ADC, input mixers and output mixers
6331 */
6332static struct hda_verb alc260_volume_init_verbs[] = {
6333 /*
6334 * Unmute ADC0-1 and set the default input to mic-in
6335 */
6336 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6337 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6338 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6339 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006340
Kailang Yangdf694da2005-12-05 19:42:22 +01006341 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6342 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006343 * Note: PASD motherboards uses the Line In 2 as the input for
6344 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006345 */
6346 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006347 /* mute analog inputs */
6348 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6349 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6350 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6351 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6352 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006353
6354 /*
6355 * Set up output mixers (0x08 - 0x0a)
6356 */
6357 /* set vol=0 to output mixers */
6358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6360 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6361 /* set up input amps for analog loopback */
6362 /* Amp Indices: DAC = 0, mixer = 1 */
6363 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6365 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6366 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6367 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6368 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006369
Kailang Yangdf694da2005-12-05 19:42:22 +01006370 { }
6371};
6372
6373static int alc260_parse_auto_config(struct hda_codec *codec)
6374{
6375 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006376 int err;
6377 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6378
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006379 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6380 alc260_ignore);
6381 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006382 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006383 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6384 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006385 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006386 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006387 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006388 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006389 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006390 return err;
6391
6392 spec->multiout.max_channels = 2;
6393
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006394 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006395 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006396 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006397 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006398
Takashi Iwaid88897e2008-10-31 15:01:37 +01006399 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006400
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006401 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006402 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006403
Kailang Yang6227cdc2010-02-25 08:36:52 +01006404 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006405
Kailang Yangdf694da2005-12-05 19:42:22 +01006406 return 1;
6407}
6408
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006409/* additional initialization for auto-configuration model */
6410static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006411{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006412 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006413 alc260_auto_init_multi_out(codec);
6414 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006415 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006416 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006417}
6418
Takashi Iwaicb53c622007-08-10 17:21:45 +02006419#ifdef CONFIG_SND_HDA_POWER_SAVE
6420static struct hda_amp_list alc260_loopbacks[] = {
6421 { 0x07, HDA_INPUT, 0 },
6422 { 0x07, HDA_INPUT, 1 },
6423 { 0x07, HDA_INPUT, 2 },
6424 { 0x07, HDA_INPUT, 3 },
6425 { 0x07, HDA_INPUT, 4 },
6426 { } /* end */
6427};
6428#endif
6429
Kailang Yangdf694da2005-12-05 19:42:22 +01006430/*
6431 * ALC260 configurations
6432 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006433static const char *alc260_models[ALC260_MODEL_LAST] = {
6434 [ALC260_BASIC] = "basic",
6435 [ALC260_HP] = "hp",
6436 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006437 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006438 [ALC260_FUJITSU_S702X] = "fujitsu",
6439 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006440 [ALC260_WILL] = "will",
6441 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006442 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006443#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006444 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006445#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006446 [ALC260_AUTO] = "auto",
6447};
6448
6449static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006450 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006451 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006452 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006453 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006454 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006455 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006456 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006457 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006458 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006459 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6460 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6461 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6462 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6463 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6464 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6465 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6466 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6467 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006468 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006469 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006470 {}
6471};
6472
Kailang Yangdf694da2005-12-05 19:42:22 +01006473static struct alc_config_preset alc260_presets[] = {
6474 [ALC260_BASIC] = {
6475 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006476 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006477 .init_verbs = { alc260_init_verbs },
6478 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6479 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006480 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006481 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006482 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6483 .channel_mode = alc260_modes,
6484 .input_mux = &alc260_capture_source,
6485 },
6486 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006487 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006488 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006489 .init_verbs = { alc260_init_verbs,
6490 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006491 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6492 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006493 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6494 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006495 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6496 .channel_mode = alc260_modes,
6497 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006498 .unsol_event = alc260_hp_unsol_event,
6499 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006500 },
Kailang Yang3f878302008-08-26 13:02:23 +02006501 [ALC260_HP_DC7600] = {
6502 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006503 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02006504 .init_verbs = { alc260_init_verbs,
6505 alc260_hp_dc7600_verbs },
6506 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6507 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006508 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6509 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02006510 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6511 .channel_mode = alc260_modes,
6512 .input_mux = &alc260_capture_source,
6513 .unsol_event = alc260_hp_3012_unsol_event,
6514 .init_hook = alc260_hp_3012_automute,
6515 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006516 [ALC260_HP_3013] = {
6517 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006518 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006519 .init_verbs = { alc260_hp_3013_init_verbs,
6520 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006521 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6522 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006523 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6524 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006525 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6526 .channel_mode = alc260_modes,
6527 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01006528 .unsol_event = alc260_hp_3013_unsol_event,
6529 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01006530 },
6531 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006532 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006533 .init_verbs = { alc260_fujitsu_init_verbs },
6534 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6535 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01006536 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6537 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006538 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6539 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006540 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
6541 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01006542 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006543 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006544 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006545 .init_verbs = { alc260_acer_init_verbs },
6546 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6547 .dac_nids = alc260_dac_nids,
6548 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6549 .adc_nids = alc260_dual_adc_nids,
6550 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6551 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006552 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
6553 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006554 },
Michael Schwingencc959482009-02-22 18:58:45 +01006555 [ALC260_FAVORIT100] = {
6556 .mixers = { alc260_favorit100_mixer },
6557 .init_verbs = { alc260_favorit100_init_verbs },
6558 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6559 .dac_nids = alc260_dac_nids,
6560 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
6561 .adc_nids = alc260_dual_adc_nids,
6562 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6563 .channel_mode = alc260_modes,
6564 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
6565 .input_mux = alc260_favorit100_capture_sources,
6566 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006567 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006568 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006569 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
6570 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6571 .dac_nids = alc260_dac_nids,
6572 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6573 .adc_nids = alc260_adc_nids,
6574 .dig_out_nid = ALC260_DIGOUT_NID,
6575 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6576 .channel_mode = alc260_modes,
6577 .input_mux = &alc260_capture_source,
6578 },
6579 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006580 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006581 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
6582 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6583 .dac_nids = alc260_dac_nids,
6584 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
6585 .adc_nids = alc260_adc_nids,
6586 .dig_out_nid = ALC260_DIGOUT_NID,
6587 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6588 .channel_mode = alc260_modes,
6589 .input_mux = &alc260_capture_source,
6590 .unsol_event = alc260_replacer_672v_unsol_event,
6591 .init_hook = alc260_replacer_672v_automute,
6592 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006593#ifdef CONFIG_SND_DEBUG
6594 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006595 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006596 .init_verbs = { alc260_test_init_verbs },
6597 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
6598 .dac_nids = alc260_test_dac_nids,
6599 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
6600 .adc_nids = alc260_test_adc_nids,
6601 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6602 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006603 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
6604 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006605 },
6606#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006607};
6608
Linus Torvalds1da177e2005-04-16 15:20:36 -07006609static int patch_alc260(struct hda_codec *codec)
6610{
6611 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006612 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006613
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006614 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006615 if (spec == NULL)
6616 return -ENOMEM;
6617
6618 codec->spec = spec;
6619
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006620 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
6621 alc260_models,
6622 alc260_cfg_tbl);
6623 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02006624 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02006625 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01006626 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02006627 }
6628
Kailang Yangdf694da2005-12-05 19:42:22 +01006629 if (board_config == ALC260_AUTO) {
6630 /* automatic parse from the BIOS config */
6631 err = alc260_parse_auto_config(codec);
6632 if (err < 0) {
6633 alc_free(codec);
6634 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006635 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006636 printk(KERN_INFO
6637 "hda_codec: Cannot set up configuration "
6638 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006639 board_config = ALC260_BASIC;
6640 }
Takashi Iwai16ded522005-06-10 19:58:24 +02006641 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006642
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09006643 err = snd_hda_attach_beep_device(codec, 0x1);
6644 if (err < 0) {
6645 alc_free(codec);
6646 return err;
6647 }
6648
Kailang Yangdf694da2005-12-05 19:42:22 +01006649 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02006650 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006651
Linus Torvalds1da177e2005-04-16 15:20:36 -07006652 spec->stream_analog_playback = &alc260_pcm_analog_playback;
6653 spec->stream_analog_capture = &alc260_pcm_analog_capture;
6654
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006655 spec->stream_digital_playback = &alc260_pcm_digital_playback;
6656 spec->stream_digital_capture = &alc260_pcm_digital_capture;
6657
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006658 if (!spec->adc_nids && spec->input_mux) {
6659 /* check whether NID 0x04 is valid */
6660 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02006661 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01006662 /* get type */
6663 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
6664 spec->adc_nids = alc260_adc_nids_alt;
6665 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
6666 } else {
6667 spec->adc_nids = alc260_adc_nids;
6668 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
6669 }
6670 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02006671 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006672 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006673
Takashi Iwai2134ea42008-01-10 16:53:55 +01006674 spec->vmaster_nid = 0x08;
6675
Linus Torvalds1da177e2005-04-16 15:20:36 -07006676 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006677 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006678 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006679#ifdef CONFIG_SND_HDA_POWER_SAVE
6680 if (!spec->loopback.amplist)
6681 spec->loopback.amplist = alc260_loopbacks;
6682#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006683
6684 return 0;
6685}
6686
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006687
Linus Torvalds1da177e2005-04-16 15:20:36 -07006688/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006689 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07006690 *
6691 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
6692 * configuration. Each pin widget can choose any input DACs and a mixer.
6693 * Each ADC is connected from a mixer of all inputs. This makes possible
6694 * 6-channel independent captures.
6695 *
6696 * In addition, an independent DAC for the multi-playback (not used in this
6697 * driver yet).
6698 */
Kailang Yangdf694da2005-12-05 19:42:22 +01006699#define ALC882_DIGOUT_NID 0x06
6700#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02006701#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
6702#define ALC883_DIGIN_NID ALC882_DIGIN_NID
6703#define ALC1200_DIGOUT_NID 0x10
6704
Linus Torvalds1da177e2005-04-16 15:20:36 -07006705
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01006706static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07006707 { 8, NULL }
6708};
6709
Takashi Iwai4953550a2009-06-30 15:28:30 +02006710/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006711static hda_nid_t alc882_dac_nids[4] = {
6712 /* front, rear, clfe, rear_surr */
6713 0x02, 0x03, 0x04, 0x05
6714};
Takashi Iwai4953550a2009-06-30 15:28:30 +02006715#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006716
Takashi Iwai4953550a2009-06-30 15:28:30 +02006717/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01006718#define alc882_adc_nids alc880_adc_nids
6719#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02006720#define alc883_adc_nids alc882_adc_nids_alt
6721static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
6722static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
6723#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07006724
Takashi Iwaie1406342008-02-11 18:32:32 +01006725static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
6726static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02006727#define alc883_capsrc_nids alc882_capsrc_nids_alt
6728static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6729#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01006730
Linus Torvalds1da177e2005-04-16 15:20:36 -07006731/* input MUX */
6732/* FIXME: should be a matrix-type input source selection */
6733
6734static struct hda_input_mux alc882_capture_source = {
6735 .num_items = 4,
6736 .items = {
6737 { "Mic", 0x0 },
6738 { "Front Mic", 0x1 },
6739 { "Line", 0x2 },
6740 { "CD", 0x4 },
6741 },
6742};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006743
Takashi Iwai4953550a2009-06-30 15:28:30 +02006744#define alc883_capture_source alc882_capture_source
6745
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02006746static struct hda_input_mux alc889_capture_source = {
6747 .num_items = 3,
6748 .items = {
6749 { "Front Mic", 0x0 },
6750 { "Mic", 0x3 },
6751 { "Line", 0x2 },
6752 },
6753};
6754
Kacper Szczesniak41d55452009-05-07 12:47:43 +02006755static struct hda_input_mux mb5_capture_source = {
6756 .num_items = 3,
6757 .items = {
6758 { "Mic", 0x1 },
6759 { "Line", 0x2 },
6760 { "CD", 0x4 },
6761 },
6762};
6763
Luke Yelaviche458b1f2010-02-12 16:28:29 +11006764static struct hda_input_mux macmini3_capture_source = {
6765 .num_items = 2,
6766 .items = {
6767 { "Line", 0x2 },
6768 { "CD", 0x4 },
6769 },
6770};
6771
Takashi Iwai4953550a2009-06-30 15:28:30 +02006772static struct hda_input_mux alc883_3stack_6ch_intel = {
6773 .num_items = 4,
6774 .items = {
6775 { "Mic", 0x1 },
6776 { "Front Mic", 0x0 },
6777 { "Line", 0x2 },
6778 { "CD", 0x4 },
6779 },
6780};
6781
6782static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6783 .num_items = 2,
6784 .items = {
6785 { "Mic", 0x1 },
6786 { "Line", 0x2 },
6787 },
6788};
6789
6790static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6791 .num_items = 4,
6792 .items = {
6793 { "Mic", 0x0 },
6794 { "iMic", 0x1 },
6795 { "Line", 0x2 },
6796 { "CD", 0x4 },
6797 },
6798};
6799
6800static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6801 .num_items = 2,
6802 .items = {
6803 { "Mic", 0x0 },
6804 { "Int Mic", 0x1 },
6805 },
6806};
6807
6808static struct hda_input_mux alc883_lenovo_sky_capture_source = {
6809 .num_items = 3,
6810 .items = {
6811 { "Mic", 0x0 },
6812 { "Front Mic", 0x1 },
6813 { "Line", 0x4 },
6814 },
6815};
6816
6817static struct hda_input_mux alc883_asus_eee1601_capture_source = {
6818 .num_items = 2,
6819 .items = {
6820 { "Mic", 0x0 },
6821 { "Line", 0x2 },
6822 },
6823};
6824
6825static struct hda_input_mux alc889A_mb31_capture_source = {
6826 .num_items = 2,
6827 .items = {
6828 { "Mic", 0x0 },
6829 /* Front Mic (0x01) unused */
6830 { "Line", 0x2 },
6831 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02006832 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02006833 },
6834};
6835
6836/*
6837 * 2ch mode
6838 */
6839static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6840 { 2, NULL }
6841};
6842
Kailang Yangdf694da2005-12-05 19:42:22 +01006843/*
Kailang Yang272a5272007-05-14 11:00:38 +02006844 * 2ch mode
6845 */
6846static struct hda_verb alc882_3ST_ch2_init[] = {
6847 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6848 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6849 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6850 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6851 { } /* end */
6852};
6853
6854/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02006855 * 4ch mode
6856 */
6857static struct hda_verb alc882_3ST_ch4_init[] = {
6858 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6859 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6860 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6861 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6862 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6863 { } /* end */
6864};
6865
6866/*
Kailang Yang272a5272007-05-14 11:00:38 +02006867 * 6ch mode
6868 */
6869static struct hda_verb alc882_3ST_ch6_init[] = {
6870 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6871 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6872 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6873 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6874 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6875 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6876 { } /* end */
6877};
6878
Takashi Iwai4953550a2009-06-30 15:28:30 +02006879static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02006880 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02006881 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02006882 { 6, alc882_3ST_ch6_init },
6883};
6884
Takashi Iwai4953550a2009-06-30 15:28:30 +02006885#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
6886
Kailang Yang272a5272007-05-14 11:00:38 +02006887/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04306888 * 2ch mode
6889 */
6890static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
6891 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
6892 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6893 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6894 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6895 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6896 { } /* end */
6897};
6898
6899/*
6900 * 4ch mode
6901 */
6902static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
6903 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6904 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6905 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6906 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6907 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6908 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6909 { } /* end */
6910};
6911
6912/*
6913 * 6ch mode
6914 */
6915static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
6916 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6917 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6918 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6919 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6920 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6921 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6922 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6923 { } /* end */
6924};
6925
6926static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
6927 { 2, alc883_3ST_ch2_clevo_init },
6928 { 4, alc883_3ST_ch4_clevo_init },
6929 { 6, alc883_3ST_ch6_clevo_init },
6930};
6931
6932
6933/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 * 6ch mode
6935 */
6936static struct hda_verb alc882_sixstack_ch6_init[] = {
6937 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6938 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6939 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6940 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6941 { } /* end */
6942};
6943
6944/*
6945 * 8ch mode
6946 */
6947static struct hda_verb alc882_sixstack_ch8_init[] = {
6948 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6949 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6950 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6951 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6952 { } /* end */
6953};
6954
6955static struct hda_channel_mode alc882_sixstack_modes[2] = {
6956 { 6, alc882_sixstack_ch6_init },
6957 { 8, alc882_sixstack_ch8_init },
6958};
6959
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08006960
6961/* Macbook Air 2,1 */
6962
6963static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
6964 { 2, NULL },
6965};
6966
Takashi Iwai87350ad2007-08-16 18:19:38 +02006967/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04006968 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02006969 */
6970
6971/*
6972 * 2ch mode
6973 */
6974static struct hda_verb alc885_mbp_ch2_init[] = {
6975 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6976 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6977 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6978 { } /* end */
6979};
6980
6981/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006982 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02006983 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006984static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006985 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6986 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6987 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6988 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6989 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6990 { } /* end */
6991};
6992
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006993static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02006994 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02006995 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006996};
6997
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02006998/*
6999 * 2ch
7000 * Speakers/Woofer/HP = Front
7001 * LineIn = Input
7002 */
7003static struct hda_verb alc885_mb5_ch2_init[] = {
7004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7006 { } /* end */
7007};
7008
7009/*
7010 * 6ch mode
7011 * Speakers/HP = Front
7012 * Woofer = LFE
7013 * LineIn = Surround
7014 */
7015static struct hda_verb alc885_mb5_ch6_init[] = {
7016 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7017 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7018 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7019 { } /* end */
7020};
7021
7022static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7023 { 2, alc885_mb5_ch2_init },
7024 { 6, alc885_mb5_ch6_init },
7025};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007026
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007027#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007028
7029/*
7030 * 2ch mode
7031 */
7032static struct hda_verb alc883_4ST_ch2_init[] = {
7033 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7034 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7035 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7036 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7037 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7038 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7039 { } /* end */
7040};
7041
7042/*
7043 * 4ch mode
7044 */
7045static struct hda_verb alc883_4ST_ch4_init[] = {
7046 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7047 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7048 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7049 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7050 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7051 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7052 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7053 { } /* end */
7054};
7055
7056/*
7057 * 6ch mode
7058 */
7059static struct hda_verb alc883_4ST_ch6_init[] = {
7060 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7061 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7062 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7063 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7064 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7065 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7066 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7067 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7068 { } /* end */
7069};
7070
7071/*
7072 * 8ch mode
7073 */
7074static struct hda_verb alc883_4ST_ch8_init[] = {
7075 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7076 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7077 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7078 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7079 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7080 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7081 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7082 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7083 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7084 { } /* end */
7085};
7086
7087static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7088 { 2, alc883_4ST_ch2_init },
7089 { 4, alc883_4ST_ch4_init },
7090 { 6, alc883_4ST_ch6_init },
7091 { 8, alc883_4ST_ch8_init },
7092};
7093
7094
7095/*
7096 * 2ch mode
7097 */
7098static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7099 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7100 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7101 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7102 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7103 { } /* end */
7104};
7105
7106/*
7107 * 4ch mode
7108 */
7109static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7110 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7111 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7112 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7113 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7114 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7115 { } /* end */
7116};
7117
7118/*
7119 * 6ch mode
7120 */
7121static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7122 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7123 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7124 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7125 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7126 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7127 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7128 { } /* end */
7129};
7130
7131static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7132 { 2, alc883_3ST_ch2_intel_init },
7133 { 4, alc883_3ST_ch4_intel_init },
7134 { 6, alc883_3ST_ch6_intel_init },
7135};
7136
7137/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007138 * 2ch mode
7139 */
7140static struct hda_verb alc889_ch2_intel_init[] = {
7141 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7142 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7143 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7144 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7145 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7146 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7147 { } /* end */
7148};
7149
7150/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007151 * 6ch mode
7152 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007153static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007154 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7155 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7156 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7157 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7158 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007159 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7160 { } /* end */
7161};
7162
7163/*
7164 * 8ch mode
7165 */
7166static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007167 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7168 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7169 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7170 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7171 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007172 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7173 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007174 { } /* end */
7175};
7176
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007177static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7178 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007179 { 6, alc889_ch6_intel_init },
7180 { 8, alc889_ch8_intel_init },
7181};
7182
7183/*
7184 * 6ch mode
7185 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007186static struct hda_verb alc883_sixstack_ch6_init[] = {
7187 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7188 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7189 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7190 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7191 { } /* end */
7192};
7193
7194/*
7195 * 8ch mode
7196 */
7197static struct hda_verb alc883_sixstack_ch8_init[] = {
7198 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7199 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7200 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7201 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7202 { } /* end */
7203};
7204
7205static struct hda_channel_mode alc883_sixstack_modes[2] = {
7206 { 6, alc883_sixstack_ch6_init },
7207 { 8, alc883_sixstack_ch8_init },
7208};
7209
7210
Linus Torvalds1da177e2005-04-16 15:20:36 -07007211/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7212 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7213 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007214static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007215 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007216 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007217 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007218 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007219 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7220 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007221 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7222 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007223 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007224 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007225 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7226 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7227 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7228 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7229 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007232 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7233 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007234 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007235 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007236 { } /* end */
7237};
7238
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007239/* Macbook Air 2,1 same control for HP and internal Speaker */
7240
7241static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7242 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7243 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7244 { }
7245};
7246
7247
Takashi Iwai87350ad2007-08-16 18:19:38 +02007248static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007249 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7250 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7251 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7252 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7253 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007254 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7255 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007256 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7257 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007258 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007259 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7260 { } /* end */
7261};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007262
7263static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007264 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7265 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7266 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7267 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7268 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7269 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307270 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7271 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007272 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7273 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7274 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7275 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7276 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7277 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7278 { } /* end */
7279};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007280
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007281static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7282 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7283 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7284 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7285 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7286 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7287 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7288 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7289 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7290 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7291 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7292 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7293 { } /* end */
7294};
7295
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007296static struct snd_kcontrol_new alc885_imac91_mixer[] = {
7297 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7298 HDA_BIND_MUTE ("Line-Out Playback Switch", 0x0c, 0x02, HDA_INPUT),
7299 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
7300 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7301 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7302 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7303 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7304 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
7305 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7306 { } /* end */
7307};
7308
7309
Kailang Yangbdd148a2007-05-08 15:19:08 +02007310static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7312 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7313 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7314 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7315 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7316 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7318 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7319 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007320 { } /* end */
7321};
7322
Kailang Yang272a5272007-05-14 11:00:38 +02007323static struct snd_kcontrol_new alc882_targa_mixer[] = {
7324 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7325 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7328 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7329 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7330 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007333 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007334 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7335 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007336 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007337 { } /* end */
7338};
7339
7340/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7341 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7342 */
7343static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7344 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7345 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7346 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7347 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7348 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7349 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7350 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7351 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7352 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7353 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007357 { } /* end */
7358};
7359
Takashi Iwai914759b2007-09-06 14:52:04 +02007360static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7361 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7362 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7363 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7364 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7366 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7367 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007371 { } /* end */
7372};
7373
Kailang Yangdf694da2005-12-05 19:42:22 +01007374static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7375 {
7376 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7377 .name = "Channel Mode",
7378 .info = alc_ch_mode_info,
7379 .get = alc_ch_mode_get,
7380 .put = alc_ch_mode_put,
7381 },
7382 { } /* end */
7383};
7384
Takashi Iwai4953550a2009-06-30 15:28:30 +02007385static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007386 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7388 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007389 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007390 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007392 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007393 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7394 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007395 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007396 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7397 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007398
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007399 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007401 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007402 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007403 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007404 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007406 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007407 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007408 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007409 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007410 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007411 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007412 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007413 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007414 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007415 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7418 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007419 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007420 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7421 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007422 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007423 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7424 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7425 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7426 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7427 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007428 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007429 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007430
7431 /* FIXME: use matrix-type input source selection */
7432 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007433 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007434 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007435 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007437 /* ADC2: mute amp left and right */
7438 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007439 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007440 /* ADC3: mute amp left and right */
7441 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007442 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007443
7444 { }
7445};
7446
Takashi Iwai4953550a2009-06-30 15:28:30 +02007447static struct hda_verb alc882_adc1_init_verbs[] = {
7448 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7450 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7451 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7452 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7453 /* ADC1: mute amp left and right */
7454 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7455 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7456 { }
7457};
7458
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007459static struct hda_verb alc882_eapd_verbs[] = {
7460 /* change to EAPD mode */
7461 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007462 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007463 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007464};
7465
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007466static struct hda_verb alc889_eapd_verbs[] = {
7467 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7468 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7469 { }
7470};
7471
Wu Fengguang6732bd02009-07-30 09:19:14 +02007472static struct hda_verb alc_hp15_unsol_verbs[] = {
7473 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7475 {}
7476};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007477
7478static struct hda_verb alc885_init_verbs[] = {
7479 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007480 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7481 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007482 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007483 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7484 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007485 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007486 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7487 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007488 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007489 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7490 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007491
7492 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02007493 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007494 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7495 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7496 /* Front Pin: output 0 (0x0c) */
7497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7498 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7499 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7500 /* Rear Pin: output 1 (0x0d) */
7501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7503 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
7504 /* CLFE Pin: output 2 (0x0e) */
7505 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7506 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7507 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7508 /* Side Pin: output 3 (0x0f) */
7509 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7511 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7512 /* Mic (rear) pin: input vref at 80% */
7513 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7514 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7515 /* Front Mic pin: input vref at 80% */
7516 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7517 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7518 /* Line In pin: input */
7519 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7520 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7521
7522 /* Mixer elements: 0x18, , 0x1a, 0x1b */
7523 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01007524 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007525 /* Input mixer2 */
7526 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007527 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01007528 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007529 /* ADC2: mute amp left and right */
7530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7531 /* ADC3: mute amp left and right */
7532 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7533
7534 { }
7535};
7536
7537static struct hda_verb alc885_init_input_verbs[] = {
7538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7540 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
7541 { }
7542};
7543
7544
7545/* Unmute Selector 24h and set the default input to front mic */
7546static struct hda_verb alc889_init_input_verbs[] = {
7547 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
7548 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7549 { }
7550};
7551
7552
Takashi Iwai4953550a2009-06-30 15:28:30 +02007553#define alc883_init_verbs alc882_base_init_verbs
7554
Tobin Davis9102cd12006-12-15 10:02:12 +01007555/* Mac Pro test */
7556static struct snd_kcontrol_new alc882_macpro_mixer[] = {
7557 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7558 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7559 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
7560 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
7561 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007562 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01007563 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
7564 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007565 */
Tobin Davis9102cd12006-12-15 10:02:12 +01007566 { } /* end */
7567};
7568
7569static struct hda_verb alc882_macpro_init_verbs[] = {
7570 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7571 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7574 /* Front Pin: output 0 (0x0c) */
7575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7578 /* Front Mic pin: input vref at 80% */
7579 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7580 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7581 /* Speaker: output */
7582 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7583 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7584 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
7585 /* Headphone output (output 0 - 0x0c) */
7586 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7587 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7588 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7589
7590 /* FIXME: use matrix-type input source selection */
7591 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7592 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7597 /* Input mixer2 */
7598 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7602 /* Input mixer3 */
7603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7606 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7607 /* ADC1: mute amp left and right */
7608 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7609 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7610 /* ADC2: mute amp left and right */
7611 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7612 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7613 /* ADC3: mute amp left and right */
7614 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7615 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7616
7617 { }
7618};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007619
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007620/* Macbook 5,1 */
7621static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007622 /* DACs */
7623 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7624 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7625 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7626 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007627 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7629 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7630 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007631 /* Surround mixer */
7632 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7633 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7634 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7635 /* LFE mixer */
7636 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7637 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7638 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7639 /* HP mixer */
7640 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7641 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7642 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7643 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007644 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7645 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007646 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7647 /* LFE Pin (0x0e) */
7648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7649 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7650 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7651 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007652 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7653 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007654 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10307655 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007656 /* Front Mic pin: input vref at 80% */
7657 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7658 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7659 /* Line In pin */
7660 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7662
7663 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7664 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7667 { }
7668};
7669
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007670/* Macmini 3,1 */
7671static struct hda_verb alc885_macmini3_init_verbs[] = {
7672 /* DACs */
7673 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7674 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7675 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7676 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7677 /* Front mixer */
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7680 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7681 /* Surround mixer */
7682 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7683 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7684 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7685 /* LFE mixer */
7686 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7687 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7688 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7689 /* HP mixer */
7690 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7693 /* Front Pin (0x0c) */
7694 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7695 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7696 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7697 /* LFE Pin (0x0e) */
7698 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
7699 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7700 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
7701 /* HP Pin (0x0f) */
7702 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7703 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7704 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
7705 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7706 /* Line In pin */
7707 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7708 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7709
7710 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7711 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7712 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7713 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7714 { }
7715};
7716
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007717
7718static struct hda_verb alc885_mba21_init_verbs[] = {
7719 /*Internal and HP Speaker Mixer*/
7720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7723 /*Internal Speaker Pin (0x0c)*/
7724 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
7725 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7726 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7727 /* HP Pin: output 0 (0x0e) */
7728 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
7729 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7730 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7731 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
7732 /* Line in (is hp when jack connected)*/
7733 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
7734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7735
7736 { }
7737 };
7738
7739
Takashi Iwai87350ad2007-08-16 18:19:38 +02007740/* Macbook Pro rev3 */
7741static struct hda_verb alc885_mbp3_init_verbs[] = {
7742 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7744 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7745 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7746 /* Rear mixer */
7747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7748 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7749 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007750 /* HP mixer */
7751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7752 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7753 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007754 /* Front Pin: output 0 (0x0c) */
7755 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7756 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7757 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007758 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02007759 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007760 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02007762 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7763 /* Mic (rear) pin: input vref at 80% */
7764 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7765 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7766 /* Front Mic pin: input vref at 80% */
7767 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7768 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7769 /* Line In pin: use output 1 when in LineOut mode */
7770 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7771 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7772 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7773
7774 /* FIXME: use matrix-type input source selection */
7775 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7776 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7777 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7778 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7779 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7780 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7781 /* Input mixer2 */
7782 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7783 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7784 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7785 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7786 /* Input mixer3 */
7787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7789 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7791 /* ADC1: mute amp left and right */
7792 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7793 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7794 /* ADC2: mute amp left and right */
7795 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7796 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7797 /* ADC3: mute amp left and right */
7798 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7799 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7800
7801 { }
7802};
7803
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007804/* iMac 9,1 */
7805static struct hda_verb alc885_imac91_init_verbs[] = {
7806 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
7807 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7810 /* Rear mixer */
7811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7812 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7813 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7814 /* HP Pin: output 0 (0x0c) */
7815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7817 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7818 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7819 /* Internal Speakers: output 0 (0x0d) */
7820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7822 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7823 /* Mic (rear) pin: input vref at 80% */
7824 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7826 /* Front Mic pin: input vref at 80% */
7827 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7828 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7829 /* Line In pin: use output 1 when in LineOut mode */
7830 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7831 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7832 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
7833
7834 /* FIXME: use matrix-type input source selection */
7835 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7836 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7841 /* Input mixer2 */
7842 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7843 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7844 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7845 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7846 /* Input mixer3 */
7847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7849 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7850 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7851 /* ADC1: mute amp left and right */
7852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7853 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7854 /* ADC2: mute amp left and right */
7855 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7856 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7857 /* ADC3: mute amp left and right */
7858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7859 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7860
7861 { }
7862};
7863
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007864/* iMac 24 mixer. */
7865static struct snd_kcontrol_new alc885_imac24_mixer[] = {
7866 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7867 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
7868 { } /* end */
7869};
7870
7871/* iMac 24 init verbs. */
7872static struct hda_verb alc885_imac24_init_verbs[] = {
7873 /* Internal speakers: output 0 (0x0c) */
7874 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7875 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7876 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
7877 /* Internal speakers: output 0 (0x0c) */
7878 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7879 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7880 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7881 /* Headphone: output 0 (0x0c) */
7882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7883 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7884 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7885 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7886 /* Front Mic: input vref at 80% */
7887 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7888 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7889 { }
7890};
7891
7892/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007893static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007894{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007895 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007896
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007897 spec->autocfg.hp_pins[0] = 0x14;
7898 spec->autocfg.speaker_pins[0] = 0x18;
7899 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007900}
7901
Takashi Iwai9d54f082010-02-22 08:34:40 +01007902#define alc885_mb5_setup alc885_imac24_setup
7903#define alc885_macmini3_setup alc885_imac24_setup
7904
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007905/* Macbook Air 2,1 */
7906static void alc885_mba21_setup(struct hda_codec *codec)
7907{
7908 struct alc_spec *spec = codec->spec;
7909
7910 spec->autocfg.hp_pins[0] = 0x14;
7911 spec->autocfg.speaker_pins[0] = 0x18;
7912}
7913
7914
7915
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007916static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007917{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007918 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02007919
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007920 spec->autocfg.hp_pins[0] = 0x15;
7921 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02007922}
7923
Takashi Iwai9d54f082010-02-22 08:34:40 +01007924static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10307925{
Takashi Iwai9d54f082010-02-22 08:34:40 +01007926 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10307927
Takashi Iwai9d54f082010-02-22 08:34:40 +01007928 spec->autocfg.hp_pins[0] = 0x14;
7929 spec->autocfg.speaker_pins[0] = 0x15;
7930 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007931}
Takashi Iwai87350ad2007-08-16 18:19:38 +02007932
Kailang Yang272a5272007-05-14 11:00:38 +02007933static struct hda_verb alc882_targa_verbs[] = {
7934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7936
7937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7938 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007939
Kailang Yang272a5272007-05-14 11:00:38 +02007940 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7941 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7942 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7943
7944 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02007945 { } /* end */
7946};
7947
7948/* toggle speaker-output according to the hp-jack state */
7949static void alc882_targa_automute(struct hda_codec *codec)
7950{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007951 struct alc_spec *spec = codec->spec;
7952 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007953 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007954 spec->jack_present ? 1 : 3);
7955}
7956
Takashi Iwai4f5d17062009-08-11 18:17:46 +02007957static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007958{
7959 struct alc_spec *spec = codec->spec;
7960
7961 spec->autocfg.hp_pins[0] = 0x14;
7962 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02007963}
7964
7965static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
7966{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02007967 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02007968 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02007969}
7970
7971static struct hda_verb alc882_asus_a7j_verbs[] = {
7972 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7973 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7974
7975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7976 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007978
Kailang Yang272a5272007-05-14 11:00:38 +02007979 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7981 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7982
7983 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7984 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7985 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7986 { } /* end */
7987};
7988
Takashi Iwai914759b2007-09-06 14:52:04 +02007989static struct hda_verb alc882_asus_a7m_verbs[] = {
7990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7992
7993 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7994 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007996
Takashi Iwai914759b2007-09-06 14:52:04 +02007997 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
7998 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7999 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8000
8001 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8002 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8003 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8004 { } /* end */
8005};
8006
Tobin Davis9102cd12006-12-15 10:02:12 +01008007static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8008{
8009 unsigned int gpiostate, gpiomask, gpiodir;
8010
8011 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8012 AC_VERB_GET_GPIO_DATA, 0);
8013
8014 if (!muted)
8015 gpiostate |= (1 << pin);
8016 else
8017 gpiostate &= ~(1 << pin);
8018
8019 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8020 AC_VERB_GET_GPIO_MASK, 0);
8021 gpiomask |= (1 << pin);
8022
8023 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8024 AC_VERB_GET_GPIO_DIRECTION, 0);
8025 gpiodir |= (1 << pin);
8026
8027
8028 snd_hda_codec_write(codec, codec->afg, 0,
8029 AC_VERB_SET_GPIO_MASK, gpiomask);
8030 snd_hda_codec_write(codec, codec->afg, 0,
8031 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8032
8033 msleep(1);
8034
8035 snd_hda_codec_write(codec, codec->afg, 0,
8036 AC_VERB_SET_GPIO_DATA, gpiostate);
8037}
8038
Takashi Iwai7debbe52007-08-16 15:01:03 +02008039/* set up GPIO at initialization */
8040static void alc885_macpro_init_hook(struct hda_codec *codec)
8041{
8042 alc882_gpio_mute(codec, 0, 0);
8043 alc882_gpio_mute(codec, 1, 0);
8044}
8045
8046/* set up GPIO and update auto-muting at initialization */
8047static void alc885_imac24_init_hook(struct hda_codec *codec)
8048{
8049 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008050 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008051}
8052
Kailang Yangdf694da2005-12-05 19:42:22 +01008053/*
8054 * generic initialization of ADC, input mixers and output mixers
8055 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008056static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008057 /*
8058 * Unmute ADC0-2 and set the default input to mic-in
8059 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008060 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8061 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8062 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8063 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8064
Kailang Yangdf694da2005-12-05 19:42:22 +01008065 /*
8066 * Set up output mixers (0x0c - 0x0f)
8067 */
8068 /* set vol=0 to output mixers */
8069 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8072 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8073 /* set up input amps for analog loopback */
8074 /* Amp Indices: DAC = 0, mixer = 1 */
8075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8083 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8084 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8085
8086 /* FIXME: use matrix-type input source selection */
8087 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008088 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008090 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008091 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008092 { }
8093};
8094
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008095/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8096static struct hda_verb alc889A_mb31_ch2_init[] = {
8097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8098 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8099 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8100 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8101 { } /* end */
8102};
8103
8104/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8105static struct hda_verb alc889A_mb31_ch4_init[] = {
8106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8107 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8109 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8110 { } /* end */
8111};
8112
8113/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8114static struct hda_verb alc889A_mb31_ch5_init[] = {
8115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8116 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8117 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8118 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8119 { } /* end */
8120};
8121
8122/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8123static struct hda_verb alc889A_mb31_ch6_init[] = {
8124 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8125 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8126 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8127 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8128 { } /* end */
8129};
8130
8131static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8132 { 2, alc889A_mb31_ch2_init },
8133 { 4, alc889A_mb31_ch4_init },
8134 { 5, alc889A_mb31_ch5_init },
8135 { 6, alc889A_mb31_ch6_init },
8136};
8137
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008138static struct hda_verb alc883_medion_eapd_verbs[] = {
8139 /* eanable EAPD on medion laptop */
8140 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8141 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8142 { }
8143};
8144
Takashi Iwai4953550a2009-06-30 15:28:30 +02008145#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008146
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008147static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8148 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8149 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8150 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8151 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8152 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8153 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8155 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8156 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8157 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8158 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8159 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8160 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008161 { } /* end */
8162};
8163
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008164static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008165 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8166 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8167 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8168 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8170 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8172 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8173 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8174 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008175 { } /* end */
8176};
8177
Jiang zhefb97dc62008-03-06 11:07:11 +01008178static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8179 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8180 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8181 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8182 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8183 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8184 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8185 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8186 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8187 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8188 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008189 { } /* end */
8190};
8191
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008192static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8193 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8194 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8196 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8197 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8198 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8199 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008201 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008202 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008204 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008205 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008206 { } /* end */
8207};
8208
8209static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8210 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8211 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8212 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8213 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8214 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8215 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8216 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8217 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8219 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8220 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8223 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008224 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008227 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008228 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008229 { } /* end */
8230};
8231
Jiang zhe17bba1b2008-06-04 12:11:07 +02008232static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8233 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8234 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8235 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8236 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8237 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8238 HDA_OUTPUT),
8239 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8240 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8241 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8245 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8246 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8247 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8248 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8251 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8252 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008253 { } /* end */
8254};
8255
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008256static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8257 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8258 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8259 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8260 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8261 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8262 HDA_OUTPUT),
8263 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8264 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8265 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8266 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8267 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8268 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8269 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8270 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8272 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8273 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8274 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8275 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8276 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8277 { } /* end */
8278};
8279
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008280static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008281 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008282 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008283 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008284 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008285 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8286 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008287 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8288 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008289 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8290 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8291 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8292 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8293 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8294 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008295 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008296 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8297 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008298 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008299 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008300 { } /* end */
8301};
8302
Sasha Alexandrc2592492009-06-16 14:52:54 -04008303static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008304 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008305 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008306 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008307 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008308 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8309 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8310 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8311 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8312 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8313 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8314 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8315 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8316 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8317 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8318 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008319 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008321 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008322};
Kailang Yangccc656c2006-10-17 12:32:26 +02008323
Sasha Alexandrc2592492009-06-16 14:52:54 -04008324static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008325 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008326 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008327 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008328 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008332 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008333 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008334 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8335 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8336 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008337 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008338};
Kailang Yangccc656c2006-10-17 12:32:26 +02008339
Takashi Iwaib99dba32009-09-17 18:23:00 +02008340static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8341 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8342 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8343 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8344 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8345 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8346 { } /* end */
8347};
8348
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008349static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8350 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8351 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008352 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8353 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8355 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8357 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008358 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008359};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008360
Kailang Yang272a5272007-05-14 11:00:38 +02008361static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8362 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8363 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8364 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8365 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8366 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8369 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8370 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008371 { } /* end */
8372};
8373
8374static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8375 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8376 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8377 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8382 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8383 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008384 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008385};
Kailang Yang272a5272007-05-14 11:00:38 +02008386
Tobin Davis2880a862007-08-07 11:50:26 +02008387static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008388 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8389 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008391 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8392 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8394 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008396 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008397};
Tobin Davis2880a862007-08-07 11:50:26 +02008398
Tony Vroond2fd4b02009-06-21 00:40:10 +01008399static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8400 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8401 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8402 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8403 HDA_BIND_MUTE("LFE Playback Switch", 0x0f, 2, HDA_INPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008404 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8405 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008406 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8407 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8409 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8411 { } /* end */
8412};
8413
Kailang Yange2757d52008-08-26 13:17:46 +02008414static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8415 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8417 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8418 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8419 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8420 0x0d, 1, 0x0, HDA_OUTPUT),
8421 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8422 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8423 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8424 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8425 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008426 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8427 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8428 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8429 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8430 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8431 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8432 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8433 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8434 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8435 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008436 { } /* end */
8437};
8438
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008439static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8440 /* Output mixers */
8441 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8442 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8443 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8444 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8445 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8446 HDA_OUTPUT),
8447 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8449 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8450 /* Output switches */
8451 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8452 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8453 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8454 /* Boost mixers */
8455 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8456 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8457 /* Input mixers */
8458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8462 { } /* end */
8463};
8464
Guido Günther3e1647c2009-06-05 00:47:26 +02008465static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
8466 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8467 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8468 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8469 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8470 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8471 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8472 { } /* end */
8473};
8474
Kailang Yange2757d52008-08-26 13:17:46 +02008475static struct hda_bind_ctls alc883_bind_cap_vol = {
8476 .ops = &snd_hda_bind_vol,
8477 .values = {
8478 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8479 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8480 0
8481 },
8482};
8483
8484static struct hda_bind_ctls alc883_bind_cap_switch = {
8485 .ops = &snd_hda_bind_sw,
8486 .values = {
8487 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
8488 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
8489 0
8490 },
8491};
8492
8493static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
8494 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8495 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8496 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8497 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8498 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8499 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8500 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008502 { } /* end */
8503};
8504
8505static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02008506 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
8507 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
8508 {
8509 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8510 /* .name = "Capture Source", */
8511 .name = "Input Source",
8512 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008513 .info = alc_mux_enum_info,
8514 .get = alc_mux_enum_get,
8515 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02008516 },
8517 { } /* end */
8518};
8519
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008520static struct snd_kcontrol_new alc883_chmode_mixer[] = {
8521 {
8522 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8523 .name = "Channel Mode",
8524 .info = alc_ch_mode_info,
8525 .get = alc_ch_mode_get,
8526 .put = alc_ch_mode_put,
8527 },
8528 { } /* end */
8529};
8530
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008531/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008532static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008533{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008534 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008535
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008536 spec->autocfg.hp_pins[0] = 0x15;
8537 spec->autocfg.speaker_pins[0] = 0x14;
8538 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008539}
8540
8541/* auto-toggle front mic */
8542/*
8543static void alc883_mitac_mic_automute(struct hda_codec *codec)
8544{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008545 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008546
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008547 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
8548}
8549*/
8550
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008551static struct hda_verb alc883_mitac_verbs[] = {
8552 /* HP */
8553 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8554 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8555 /* Subwoofer */
8556 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8557 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8558
8559 /* enable unsolicited event */
8560 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8561 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
8562
8563 { } /* end */
8564};
8565
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04308566static struct hda_verb alc883_clevo_m540r_verbs[] = {
8567 /* HP */
8568 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8569 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8570 /* Int speaker */
8571 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
8572
8573 /* enable unsolicited event */
8574 /*
8575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8576 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8577 */
8578
8579 { } /* end */
8580};
8581
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008582static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008583 /* HP */
8584 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8585 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8586 /* Int speaker */
8587 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
8588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8589
8590 /* enable unsolicited event */
8591 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008592 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01008593
8594 { } /* end */
8595};
8596
Jiang zhefb97dc62008-03-06 11:07:11 +01008597static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
8598 /* HP */
8599 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8600 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8601 /* Subwoofer */
8602 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
8603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8604
8605 /* enable unsolicited event */
8606 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8607
8608 { } /* end */
8609};
8610
Sasha Alexandrc2592492009-06-16 14:52:54 -04008611static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008612 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8613 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8614
8615 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8616 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008617
David Heidelberger64a8be72009-06-08 16:15:18 +02008618/* Connect Line-Out side jack (SPDIF) to Side */
8619 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8620 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8621 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8622/* Connect Mic jack to CLFE */
8623 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8624 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8625 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
8626/* Connect Line-in jack to Surround */
8627 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8629 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8630/* Connect HP out jack to Front */
8631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8633 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02008634
8635 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02008636
8637 { } /* end */
8638};
8639
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008640static struct hda_verb alc883_lenovo_101e_verbs[] = {
8641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8642 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
8643 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
8644 { } /* end */
8645};
8646
Kailang Yang272a5272007-05-14 11:00:38 +02008647static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
8648 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8650 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8651 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8652 { } /* end */
8653};
8654
8655static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
8656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8658 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8659 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
8660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8661 { } /* end */
8662};
8663
Kailang Yang189609a2007-08-20 11:31:23 +02008664static struct hda_verb alc883_haier_w66_verbs[] = {
8665 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8666 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8667
8668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8669
8670 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8671 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8672 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8673 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8674 { } /* end */
8675};
8676
Kailang Yange2757d52008-08-26 13:17:46 +02008677static struct hda_verb alc888_lenovo_sky_verbs[] = {
8678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8680 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8681 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8682 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8683 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8684 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8685 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8686 { } /* end */
8687};
8688
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008689static struct hda_verb alc888_6st_dell_verbs[] = {
8690 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8691 { }
8692};
8693
Guido Günther3e1647c2009-06-05 00:47:26 +02008694static struct hda_verb alc883_vaiott_verbs[] = {
8695 /* HP */
8696 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8697 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8698
8699 /* enable unsolicited event */
8700 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8701
8702 { } /* end */
8703};
8704
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008705static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008706{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008707 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008708
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008709 spec->autocfg.hp_pins[0] = 0x1b;
8710 spec->autocfg.speaker_pins[0] = 0x14;
8711 spec->autocfg.speaker_pins[1] = 0x16;
8712 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008713}
8714
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008715static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008716 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01008717 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
8718 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008719 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03008720 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008721};
8722
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008723/*
8724 * 2ch mode
8725 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008726static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008727 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8728 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8729 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
8730 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008731 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008732};
8733
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008734/*
8735 * 4ch mode
8736 */
8737static struct hda_verb alc888_3st_hp_4ch_init[] = {
8738 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
8739 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
8740 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8741 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
8742 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8743 { } /* end */
8744};
8745
8746/*
8747 * 6ch mode
8748 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008749static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008750 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8751 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008752 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008753 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
8754 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008755 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
8756 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008757};
8758
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008759static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008760 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03008761 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008762 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008763};
8764
Kailang Yang272a5272007-05-14 11:00:38 +02008765/* toggle front-jack and RCA according to the hp-jack state */
8766static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
8767{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008768 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02008769
Takashi Iwai47fd8302007-08-10 17:11:07 +02008770 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8771 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8772 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8773 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008774}
8775
8776/* toggle RCA according to the front-jack state */
8777static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
8778{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008779 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02008780
Takashi Iwai47fd8302007-08-10 17:11:07 +02008781 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8782 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02008783}
Takashi Iwai47fd8302007-08-10 17:11:07 +02008784
Kailang Yang272a5272007-05-14 11:00:38 +02008785static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
8786 unsigned int res)
8787{
8788 if ((res >> 26) == ALC880_HP_EVENT)
8789 alc888_lenovo_ms7195_front_automute(codec);
8790 if ((res >> 26) == ALC880_FRONT_EVENT)
8791 alc888_lenovo_ms7195_rca_automute(codec);
8792}
8793
8794static struct hda_verb alc883_medion_md2_verbs[] = {
8795 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8796 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8797
8798 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8799
8800 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8801 { } /* end */
8802};
8803
8804/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008805static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02008806{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008807 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008808
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008809 spec->autocfg.hp_pins[0] = 0x14;
8810 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02008811}
8812
Kailang Yangccc656c2006-10-17 12:32:26 +02008813/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04008814#define alc883_targa_init_hook alc882_targa_init_hook
8815#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01008816
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008817static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
8818{
8819 unsigned int present;
8820
Takashi Iwaid56757a2009-11-18 08:00:14 +01008821 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008822 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
8823 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8824}
8825
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008826static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008827{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008828 struct alc_spec *spec = codec->spec;
8829
8830 spec->autocfg.hp_pins[0] = 0x15;
8831 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008832}
8833
8834static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
8835{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008836 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008837 alc883_clevo_m720_mic_automute(codec);
8838}
8839
8840static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01008841 unsigned int res)
8842{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008843 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008844 case ALC880_MIC_EVENT:
8845 alc883_clevo_m720_mic_automute(codec);
8846 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008847 default:
8848 alc_automute_amp_unsol_event(codec, res);
8849 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008850 }
Jiang zhe368c7a92008-03-04 11:20:33 +01008851}
8852
Jiang zhefb97dc62008-03-06 11:07:11 +01008853/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008854static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008855{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008856 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008857
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008858 spec->autocfg.hp_pins[0] = 0x14;
8859 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01008860}
8861
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008862static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01008863{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008864 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01008865
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008866 spec->autocfg.hp_pins[0] = 0x1b;
8867 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02008868}
8869
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008870static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
8871{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008872 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008873
Takashi Iwai47fd8302007-08-10 17:11:07 +02008874 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8875 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008876}
8877
8878static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
8879{
Wu Fengguang864f92b2009-11-18 12:38:02 +08008880 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008881
Takashi Iwai47fd8302007-08-10 17:11:07 +02008882 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8883 HDA_AMP_MUTE, bits);
8884 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8885 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008886}
8887
8888static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
8889 unsigned int res)
8890{
8891 if ((res >> 26) == ALC880_HP_EVENT)
8892 alc883_lenovo_101e_all_automute(codec);
8893 if ((res >> 26) == ALC880_FRONT_EVENT)
8894 alc883_lenovo_101e_ispeaker_automute(codec);
8895}
8896
Takashi Iwai676a9b52007-08-16 15:23:35 +02008897/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008898static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02008899{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008900 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008901
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008902 spec->autocfg.hp_pins[0] = 0x14;
8903 spec->autocfg.speaker_pins[0] = 0x15;
8904 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02008905}
8906
Kailang Yangd1a991a2007-08-15 16:21:59 +02008907static struct hda_verb alc883_acer_eapd_verbs[] = {
8908 /* HP Pin: output 0 (0x0c) */
8909 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8910 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8911 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8912 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008913 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8914 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008915 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008916 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8917 /* eanable EAPD on medion laptop */
8918 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8919 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008920 /* enable unsolicited event */
8921 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008922 { }
8923};
8924
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02008925static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
8926 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8927 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
8928 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8929 { } /* end */
8930};
8931
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008932static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008933{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008934 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02008935
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008936 spec->autocfg.hp_pins[0] = 0x1b;
8937 spec->autocfg.speaker_pins[0] = 0x14;
8938 spec->autocfg.speaker_pins[1] = 0x15;
8939 spec->autocfg.speaker_pins[2] = 0x16;
8940 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008941}
8942
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008943static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008944{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008945 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008946
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008947 spec->autocfg.hp_pins[0] = 0x1b;
8948 spec->autocfg.speaker_pins[0] = 0x14;
8949 spec->autocfg.speaker_pins[1] = 0x15;
8950 spec->autocfg.speaker_pins[2] = 0x16;
8951 spec->autocfg.speaker_pins[3] = 0x17;
8952 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02008953}
8954
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008955static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02008956{
8957 struct alc_spec *spec = codec->spec;
8958
8959 spec->autocfg.hp_pins[0] = 0x15;
8960 spec->autocfg.speaker_pins[0] = 0x14;
8961 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02008962}
8963
Kailang Yange2757d52008-08-26 13:17:46 +02008964static struct hda_verb alc888_asus_m90v_verbs[] = {
8965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8966 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8967 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8968 /* enable unsolicited event */
8969 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8970 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8971 { } /* end */
8972};
8973
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008974static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02008975{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008976 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02008977
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008978 spec->autocfg.hp_pins[0] = 0x1b;
8979 spec->autocfg.speaker_pins[0] = 0x14;
8980 spec->autocfg.speaker_pins[1] = 0x15;
8981 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008982 spec->ext_mic.pin = 0x18;
8983 spec->int_mic.pin = 0x19;
8984 spec->ext_mic.mux_idx = 0;
8985 spec->int_mic.mux_idx = 1;
8986 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02008987}
8988
8989static struct hda_verb alc888_asus_eee1601_verbs[] = {
8990 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8991 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8992 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8993 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8994 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8995 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8996 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8997 /* enable unsolicited event */
8998 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8999 { } /* end */
9000};
9001
Kailang Yange2757d52008-08-26 13:17:46 +02009002static void alc883_eee1601_inithook(struct hda_codec *codec)
9003{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009004 struct alc_spec *spec = codec->spec;
9005
9006 spec->autocfg.hp_pins[0] = 0x14;
9007 spec->autocfg.speaker_pins[0] = 0x1b;
9008 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009009}
9010
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009011static struct hda_verb alc889A_mb31_verbs[] = {
9012 /* Init rear pin (used as headphone output) */
9013 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9014 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9015 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9016 /* Init line pin (used as output in 4ch and 6ch mode) */
9017 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9018 /* Init line 2 pin (used as headphone out by default) */
9019 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9020 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9021 { } /* end */
9022};
9023
9024/* Mute speakers according to the headphone jack state */
9025static void alc889A_mb31_automute(struct hda_codec *codec)
9026{
9027 unsigned int present;
9028
9029 /* Mute only in 2ch or 4ch mode */
9030 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9031 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009032 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009033 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9034 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9035 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9036 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9037 }
9038}
9039
9040static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9041{
9042 if ((res >> 26) == ALC880_HP_EVENT)
9043 alc889A_mb31_automute(codec);
9044}
9045
Takashi Iwai4953550a2009-06-30 15:28:30 +02009046
Takashi Iwaicb53c622007-08-10 17:21:45 +02009047#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009048#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009049#endif
9050
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009051/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009052#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9053#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9054#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9055#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9056
9057static hda_nid_t alc883_slave_dig_outs[] = {
9058 ALC1200_DIGOUT_NID, 0,
9059};
9060
9061static hda_nid_t alc1200_slave_dig_outs[] = {
9062 ALC883_DIGOUT_NID, 0,
9063};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009064
9065/*
9066 * configuration and preset
9067 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009068static const char *alc882_models[ALC882_MODEL_LAST] = {
9069 [ALC882_3ST_DIG] = "3stack-dig",
9070 [ALC882_6ST_DIG] = "6stack-dig",
9071 [ALC882_ARIMA] = "arima",
9072 [ALC882_W2JC] = "w2jc",
9073 [ALC882_TARGA] = "targa",
9074 [ALC882_ASUS_A7J] = "asus-a7j",
9075 [ALC882_ASUS_A7M] = "asus-a7m",
9076 [ALC885_MACPRO] = "macpro",
9077 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009078 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009079 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009080 [ALC885_MBP3] = "mbp3",
9081 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009082 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009083 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009084 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9085 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009086 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009087 [ALC883_TARGA_DIG] = "targa-dig",
9088 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009089 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009090 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009091 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009092 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009093 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009094 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009095 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009096 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009097 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009098 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009099 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009100 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9101 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009102 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009103 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009104 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009105 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009106 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309107 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009108 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009109 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009110 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009111 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009112 [ALC889A_INTEL] = "intel-alc889a",
9113 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009114 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009115 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009116 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009117 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009118};
9119
Takashi Iwai4953550a2009-06-30 15:28:30 +02009120static struct snd_pci_quirk alc882_cfg_tbl[] = {
9121 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9122
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009123 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009124 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009125 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009126 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9127 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009128 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009129 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9130 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009131 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009132 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009133 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9134 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009135 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9136 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009137 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9138 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009139 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009140 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009141 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009142 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009143 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9144 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009145 /* default Acer -- disabled as it causes more problems.
9146 * model=auto should work fine now
9147 */
9148 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009149
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009150 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009151
Tobin Davisfebe3372007-06-12 11:27:46 +02009152 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009153 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9154 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009155 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009156 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009157 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009158
9159 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9160 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9161 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009162 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009163 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9164 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9165 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009166 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009167 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009168 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009169 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009170
9171 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009172 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009173 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009174 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009175 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9176 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009177 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009178 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009179 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9180
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009181 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9182 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9183 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009184 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009185 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009186 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009187 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009188 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009189 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9190 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9191 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9192 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9193 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9194 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009195 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009196 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9197 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9198 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009199 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009200 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009201 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9202 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009203 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009204 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009205 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009206 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009207 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009208 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009209 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009210 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009211 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009212
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009213 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009214 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9215 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309216 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009217 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009218 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009219 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009220 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009221 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009222 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009223 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009224 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009225 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009226 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009227 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9228 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009229 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009230 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009231 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009232 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009233 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009234
Jiang zhe17bba1b2008-06-04 12:11:07 +02009235 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9236 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009237 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009238 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9239 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9240 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009241 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009242
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009243 {}
9244};
9245
Takashi Iwai4953550a2009-06-30 15:28:30 +02009246/* codec SSID table for Intel Mac */
9247static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9248 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9249 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9250 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9251 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9252 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9253 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9254 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
9255 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9256 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9257 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009258 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009259 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009260 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9261 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009262 */
9263 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009264 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009265 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009266 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009267};
9268
Takashi Iwai4953550a2009-06-30 15:28:30 +02009269static struct alc_config_preset alc882_presets[] = {
9270 [ALC882_3ST_DIG] = {
9271 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009272 .init_verbs = { alc882_base_init_verbs,
9273 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009274 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9275 .dac_nids = alc882_dac_nids,
9276 .dig_out_nid = ALC882_DIGOUT_NID,
9277 .dig_in_nid = ALC882_DIGIN_NID,
9278 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9279 .channel_mode = alc882_ch_modes,
9280 .need_dac_fix = 1,
9281 .input_mux = &alc882_capture_source,
9282 },
9283 [ALC882_6ST_DIG] = {
9284 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009285 .init_verbs = { alc882_base_init_verbs,
9286 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009287 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9288 .dac_nids = alc882_dac_nids,
9289 .dig_out_nid = ALC882_DIGOUT_NID,
9290 .dig_in_nid = ALC882_DIGIN_NID,
9291 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9292 .channel_mode = alc882_sixstack_modes,
9293 .input_mux = &alc882_capture_source,
9294 },
9295 [ALC882_ARIMA] = {
9296 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009297 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9298 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009299 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9300 .dac_nids = alc882_dac_nids,
9301 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9302 .channel_mode = alc882_sixstack_modes,
9303 .input_mux = &alc882_capture_source,
9304 },
9305 [ALC882_W2JC] = {
9306 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009307 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9308 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009309 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9310 .dac_nids = alc882_dac_nids,
9311 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9312 .channel_mode = alc880_threestack_modes,
9313 .need_dac_fix = 1,
9314 .input_mux = &alc882_capture_source,
9315 .dig_out_nid = ALC882_DIGOUT_NID,
9316 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009317 [ALC885_MBA21] = {
9318 .mixers = { alc885_mba21_mixer },
9319 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9320 .num_dacs = 2,
9321 .dac_nids = alc882_dac_nids,
9322 .channel_mode = alc885_mba21_ch_modes,
9323 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9324 .input_mux = &alc882_capture_source,
9325 .unsol_event = alc_automute_amp_unsol_event,
9326 .setup = alc885_mba21_setup,
9327 .init_hook = alc_automute_amp,
9328 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009329 [ALC885_MBP3] = {
9330 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9331 .init_verbs = { alc885_mbp3_init_verbs,
9332 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009333 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009334 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009335 .hp_nid = 0x04,
9336 .channel_mode = alc885_mbp_4ch_modes,
9337 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009338 .input_mux = &alc882_capture_source,
9339 .dig_out_nid = ALC882_DIGOUT_NID,
9340 .dig_in_nid = ALC882_DIGIN_NID,
9341 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009342 .setup = alc885_mbp3_setup,
9343 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009344 },
9345 [ALC885_MB5] = {
9346 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9347 .init_verbs = { alc885_mb5_init_verbs,
9348 alc880_gpio1_init_verbs },
9349 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9350 .dac_nids = alc882_dac_nids,
9351 .channel_mode = alc885_mb5_6ch_modes,
9352 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9353 .input_mux = &mb5_capture_source,
9354 .dig_out_nid = ALC882_DIGOUT_NID,
9355 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009356 .unsol_event = alc_automute_amp_unsol_event,
9357 .setup = alc885_mb5_setup,
9358 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009359 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009360 [ALC885_MACMINI3] = {
9361 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9362 .init_verbs = { alc885_macmini3_init_verbs,
9363 alc880_gpio1_init_verbs },
9364 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9365 .dac_nids = alc882_dac_nids,
9366 .channel_mode = alc885_macmini3_6ch_modes,
9367 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9368 .input_mux = &macmini3_capture_source,
9369 .dig_out_nid = ALC882_DIGOUT_NID,
9370 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009371 .unsol_event = alc_automute_amp_unsol_event,
9372 .setup = alc885_macmini3_setup,
9373 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009374 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009375 [ALC885_MACPRO] = {
9376 .mixers = { alc882_macpro_mixer },
9377 .init_verbs = { alc882_macpro_init_verbs },
9378 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9379 .dac_nids = alc882_dac_nids,
9380 .dig_out_nid = ALC882_DIGOUT_NID,
9381 .dig_in_nid = ALC882_DIGIN_NID,
9382 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9383 .channel_mode = alc882_ch_modes,
9384 .input_mux = &alc882_capture_source,
9385 .init_hook = alc885_macpro_init_hook,
9386 },
9387 [ALC885_IMAC24] = {
9388 .mixers = { alc885_imac24_mixer },
9389 .init_verbs = { alc885_imac24_init_verbs },
9390 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9391 .dac_nids = alc882_dac_nids,
9392 .dig_out_nid = ALC882_DIGOUT_NID,
9393 .dig_in_nid = ALC882_DIGIN_NID,
9394 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9395 .channel_mode = alc882_ch_modes,
9396 .input_mux = &alc882_capture_source,
9397 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009398 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009399 .init_hook = alc885_imac24_init_hook,
9400 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009401 [ALC885_IMAC91] = {
9402 .mixers = { alc885_imac91_mixer, alc882_chmode_mixer },
9403 .init_verbs = { alc885_imac91_init_verbs,
9404 alc880_gpio1_init_verbs },
9405 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9406 .dac_nids = alc882_dac_nids,
9407 .channel_mode = alc885_mbp_4ch_modes,
9408 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
9409 .input_mux = &alc882_capture_source,
9410 .dig_out_nid = ALC882_DIGOUT_NID,
9411 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009412 .unsol_event = alc_automute_amp_unsol_event,
9413 .setup = alc885_imac91_setup,
9414 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009415 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009416 [ALC882_TARGA] = {
9417 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009418 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009419 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009420 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9421 .dac_nids = alc882_dac_nids,
9422 .dig_out_nid = ALC882_DIGOUT_NID,
9423 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9424 .adc_nids = alc882_adc_nids,
9425 .capsrc_nids = alc882_capsrc_nids,
9426 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9427 .channel_mode = alc882_3ST_6ch_modes,
9428 .need_dac_fix = 1,
9429 .input_mux = &alc882_capture_source,
9430 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009431 .setup = alc882_targa_setup,
9432 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009433 },
9434 [ALC882_ASUS_A7J] = {
9435 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009436 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9437 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009438 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9439 .dac_nids = alc882_dac_nids,
9440 .dig_out_nid = ALC882_DIGOUT_NID,
9441 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9442 .adc_nids = alc882_adc_nids,
9443 .capsrc_nids = alc882_capsrc_nids,
9444 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9445 .channel_mode = alc882_3ST_6ch_modes,
9446 .need_dac_fix = 1,
9447 .input_mux = &alc882_capture_source,
9448 },
9449 [ALC882_ASUS_A7M] = {
9450 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009451 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9452 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009453 alc882_asus_a7m_verbs },
9454 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9455 .dac_nids = alc882_dac_nids,
9456 .dig_out_nid = ALC882_DIGOUT_NID,
9457 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9458 .channel_mode = alc880_threestack_modes,
9459 .need_dac_fix = 1,
9460 .input_mux = &alc882_capture_source,
9461 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009462 [ALC883_3ST_2ch_DIG] = {
9463 .mixers = { alc883_3ST_2ch_mixer },
9464 .init_verbs = { alc883_init_verbs },
9465 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9466 .dac_nids = alc883_dac_nids,
9467 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009468 .dig_in_nid = ALC883_DIGIN_NID,
9469 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9470 .channel_mode = alc883_3ST_2ch_modes,
9471 .input_mux = &alc883_capture_source,
9472 },
9473 [ALC883_3ST_6ch_DIG] = {
9474 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9475 .init_verbs = { alc883_init_verbs },
9476 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9477 .dac_nids = alc883_dac_nids,
9478 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009479 .dig_in_nid = ALC883_DIGIN_NID,
9480 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9481 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009482 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009483 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009484 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009485 [ALC883_3ST_6ch] = {
9486 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9487 .init_verbs = { alc883_init_verbs },
9488 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9489 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009490 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9491 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02009492 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009493 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009494 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02009495 [ALC883_3ST_6ch_INTEL] = {
9496 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
9497 .init_verbs = { alc883_init_verbs },
9498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9499 .dac_nids = alc883_dac_nids,
9500 .dig_out_nid = ALC883_DIGOUT_NID,
9501 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009502 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +02009503 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
9504 .channel_mode = alc883_3ST_6ch_intel_modes,
9505 .need_dac_fix = 1,
9506 .input_mux = &alc883_3stack_6ch_intel,
9507 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009508 [ALC889A_INTEL] = {
9509 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +02009510 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
9511 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009512 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9513 .dac_nids = alc883_dac_nids,
9514 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9515 .adc_nids = alc889_adc_nids,
9516 .dig_out_nid = ALC883_DIGOUT_NID,
9517 .dig_in_nid = ALC883_DIGIN_NID,
9518 .slave_dig_outs = alc883_slave_dig_outs,
9519 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9520 .channel_mode = alc889_8ch_intel_modes,
9521 .capsrc_nids = alc889_capsrc_nids,
9522 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009523 .setup = alc889_automute_setup,
9524 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009525 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009526 .need_dac_fix = 1,
9527 },
9528 [ALC889_INTEL] = {
9529 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
9530 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009531 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009532 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9533 .dac_nids = alc883_dac_nids,
9534 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9535 .adc_nids = alc889_adc_nids,
9536 .dig_out_nid = ALC883_DIGOUT_NID,
9537 .dig_in_nid = ALC883_DIGIN_NID,
9538 .slave_dig_outs = alc883_slave_dig_outs,
9539 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
9540 .channel_mode = alc889_8ch_intel_modes,
9541 .capsrc_nids = alc889_capsrc_nids,
9542 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009543 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +02009544 .init_hook = alc889_intel_init_hook,
9545 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009546 .need_dac_fix = 1,
9547 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009548 [ALC883_6ST_DIG] = {
9549 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9550 .init_verbs = { alc883_init_verbs },
9551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9552 .dac_nids = alc883_dac_nids,
9553 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009554 .dig_in_nid = ALC883_DIGIN_NID,
9555 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9556 .channel_mode = alc883_sixstack_modes,
9557 .input_mux = &alc883_capture_source,
9558 },
Kailang Yangccc656c2006-10-17 12:32:26 +02009559 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009560 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +02009561 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9562 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009563 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9564 .dac_nids = alc883_dac_nids,
9565 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009566 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9567 .channel_mode = alc883_3ST_6ch_modes,
9568 .need_dac_fix = 1,
9569 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009570 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009571 .setup = alc882_targa_setup,
9572 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009573 },
9574 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009575 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +02009576 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
9577 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +02009578 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9579 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009580 .adc_nids = alc883_adc_nids_alt,
9581 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009582 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +02009583 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02009584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9585 .channel_mode = alc883_3ST_2ch_modes,
9586 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009587 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009588 .setup = alc882_targa_setup,
9589 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +02009590 },
David Heidelberger64a8be72009-06-08 16:15:18 +02009591 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +02009592 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
9593 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +02009594 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009595 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +02009596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9597 .dac_nids = alc883_dac_nids,
9598 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9599 .adc_nids = alc883_adc_nids_rev,
9600 .capsrc_nids = alc883_capsrc_nids_rev,
9601 .dig_out_nid = ALC883_DIGOUT_NID,
9602 .dig_in_nid = ALC883_DIGIN_NID,
9603 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
9604 .channel_mode = alc883_4ST_8ch_modes,
9605 .need_dac_fix = 1,
9606 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -04009607 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009608 .setup = alc882_targa_setup,
9609 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +02009610 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009611 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009612 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009613 /* On TravelMate laptops, GPIO 0 enables the internal speaker
9614 * and the headphone jack. Turn this on and rely on the
9615 * standard mute methods whenever the user wants to turn
9616 * these outputs off.
9617 */
9618 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
9619 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9620 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02009621 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9622 .channel_mode = alc883_3ST_2ch_modes,
9623 .input_mux = &alc883_capture_source,
9624 },
Tobin Davis2880a862007-08-07 11:50:26 +02009625 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009626 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02009627 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02009628 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9629 .dac_nids = alc883_dac_nids,
9630 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02009631 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9632 .channel_mode = alc883_3ST_2ch_modes,
9633 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009634 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009635 .setup = alc883_acer_aspire_setup,
9636 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +02009637 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009638 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009639 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009640 alc883_chmode_mixer },
9641 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9642 alc888_acer_aspire_4930g_verbs },
9643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9644 .dac_nids = alc883_dac_nids,
9645 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9646 .adc_nids = alc883_adc_nids_rev,
9647 .capsrc_nids = alc883_capsrc_nids_rev,
9648 .dig_out_nid = ALC883_DIGOUT_NID,
9649 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9650 .channel_mode = alc883_3ST_6ch_modes,
9651 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +01009652 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009653 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009654 ARRAY_SIZE(alc888_2_capture_sources),
9655 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009656 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009657 .setup = alc888_acer_aspire_4930g_setup,
9658 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009659 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01009660 [ALC888_ACER_ASPIRE_6530G] = {
9661 .mixers = { alc888_acer_aspire_6530_mixer },
9662 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9663 alc888_acer_aspire_6530g_verbs },
9664 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9665 .dac_nids = alc883_dac_nids,
9666 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9667 .adc_nids = alc883_adc_nids_rev,
9668 .capsrc_nids = alc883_capsrc_nids_rev,
9669 .dig_out_nid = ALC883_DIGOUT_NID,
9670 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9671 .channel_mode = alc883_3ST_2ch_modes,
9672 .num_mux_defs =
9673 ARRAY_SIZE(alc888_2_capture_sources),
9674 .input_mux = alc888_acer_aspire_6530_sources,
9675 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009676 .setup = alc888_acer_aspire_6530g_setup,
9677 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +01009678 },
Hector Martin3b315d72009-06-02 10:54:19 +02009679 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +01009680 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +02009681 alc883_chmode_mixer },
9682 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +01009683 alc889_acer_aspire_8930g_verbs,
9684 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +02009685 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9686 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +02009687 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
9688 .adc_nids = alc889_adc_nids,
9689 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +02009690 .dig_out_nid = ALC883_DIGOUT_NID,
9691 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9692 .channel_mode = alc883_3ST_6ch_modes,
9693 .need_dac_fix = 1,
9694 .const_channel_count = 6,
9695 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +02009696 ARRAY_SIZE(alc889_capture_sources),
9697 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +02009698 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009699 .setup = alc889_acer_aspire_8930g_setup,
9700 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +01009701#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05009702 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +01009703#endif
Hector Martin3b315d72009-06-02 10:54:19 +02009704 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009705 [ALC888_ACER_ASPIRE_7730G] = {
9706 .mixers = { alc883_3ST_6ch_mixer,
9707 alc883_chmode_mixer },
9708 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
9709 alc888_acer_aspire_7730G_verbs },
9710 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9711 .dac_nids = alc883_dac_nids,
9712 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9713 .adc_nids = alc883_adc_nids_rev,
9714 .capsrc_nids = alc883_capsrc_nids_rev,
9715 .dig_out_nid = ALC883_DIGOUT_NID,
9716 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9717 .channel_mode = alc883_3ST_6ch_modes,
9718 .need_dac_fix = 1,
9719 .const_channel_count = 6,
9720 .input_mux = &alc883_capture_source,
9721 .unsol_event = alc_automute_amp_unsol_event,
9722 .setup = alc888_acer_aspire_6530g_setup,
9723 .init_hook = alc_automute_amp,
9724 },
Tobin Davisc07584c2006-10-13 12:32:16 +02009725 [ALC883_MEDION] = {
9726 .mixers = { alc883_fivestack_mixer,
9727 alc883_chmode_mixer },
9728 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009729 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02009730 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9731 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009732 .adc_nids = alc883_adc_nids_alt,
9733 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009734 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02009735 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9736 .channel_mode = alc883_sixstack_modes,
9737 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009738 },
Kailang Yang272a5272007-05-14 11:00:38 +02009739 [ALC883_MEDION_MD2] = {
9740 .mixers = { alc883_medion_md2_mixer},
9741 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
9742 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9743 .dac_nids = alc883_dac_nids,
9744 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009745 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9746 .channel_mode = alc883_3ST_2ch_modes,
9747 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009748 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009749 .setup = alc883_medion_md2_setup,
9750 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +02009751 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009752 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02009753 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009754 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
9755 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9756 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01009757 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9758 .channel_mode = alc883_3ST_2ch_modes,
9759 .input_mux = &alc883_capture_source,
9760 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309761 [ALC883_CLEVO_M540R] = {
9762 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9763 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
9764 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9765 .dac_nids = alc883_dac_nids,
9766 .dig_out_nid = ALC883_DIGOUT_NID,
9767 .dig_in_nid = ALC883_DIGIN_NID,
9768 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
9769 .channel_mode = alc883_3ST_6ch_clevo_modes,
9770 .need_dac_fix = 1,
9771 .input_mux = &alc883_capture_source,
9772 /* This machine has the hardware HP auto-muting, thus
9773 * we need no software mute via unsol event
9774 */
9775 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009776 [ALC883_CLEVO_M720] = {
9777 .mixers = { alc883_clevo_m720_mixer },
9778 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01009779 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9780 .dac_nids = alc883_dac_nids,
9781 .dig_out_nid = ALC883_DIGOUT_NID,
9782 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9783 .channel_mode = alc883_3ST_2ch_modes,
9784 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009785 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009786 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009787 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +01009788 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009789 [ALC883_LENOVO_101E_2ch] = {
9790 .mixers = { alc883_lenovo_101e_2ch_mixer},
9791 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
9792 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9793 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009794 .adc_nids = alc883_adc_nids_alt,
9795 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009796 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009797 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9798 .channel_mode = alc883_3ST_2ch_modes,
9799 .input_mux = &alc883_lenovo_101e_capture_source,
9800 .unsol_event = alc883_lenovo_101e_unsol_event,
9801 .init_hook = alc883_lenovo_101e_all_automute,
9802 },
Kailang Yang272a5272007-05-14 11:00:38 +02009803 [ALC883_LENOVO_NB0763] = {
9804 .mixers = { alc883_lenovo_nb0763_mixer },
9805 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
9806 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9807 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02009808 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9809 .channel_mode = alc883_3ST_2ch_modes,
9810 .need_dac_fix = 1,
9811 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009812 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009813 .setup = alc883_medion_md2_setup,
9814 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +02009815 },
9816 [ALC888_LENOVO_MS7195_DIG] = {
9817 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9818 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
9819 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9820 .dac_nids = alc883_dac_nids,
9821 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02009822 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9823 .channel_mode = alc883_3ST_6ch_modes,
9824 .need_dac_fix = 1,
9825 .input_mux = &alc883_capture_source,
9826 .unsol_event = alc883_lenovo_ms7195_unsol_event,
9827 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02009828 },
9829 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -04009830 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +02009831 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
9832 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9833 .dac_nids = alc883_dac_nids,
9834 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02009835 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9836 .channel_mode = alc883_3ST_2ch_modes,
9837 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009838 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009839 .setup = alc883_haier_w66_setup,
9840 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009841 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009842 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01009843 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009844 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9846 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009847 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
9848 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009849 .need_dac_fix = 1,
9850 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009851 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009852 .setup = alc888_3st_hp_setup,
9853 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009854 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009855 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01009856 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009857 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
9858 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9859 .dac_nids = alc883_dac_nids,
9860 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009861 .dig_in_nid = ALC883_DIGIN_NID,
9862 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9863 .channel_mode = alc883_sixstack_modes,
9864 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009865 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009866 .setup = alc888_6st_dell_setup,
9867 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009868 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009869 [ALC883_MITAC] = {
9870 .mixers = { alc883_mitac_mixer },
9871 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
9872 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9873 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009874 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9875 .channel_mode = alc883_3ST_2ch_modes,
9876 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009877 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009878 .setup = alc883_mitac_setup,
9879 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009880 },
Jiang zhefb97dc62008-03-06 11:07:11 +01009881 [ALC883_FUJITSU_PI2515] = {
9882 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
9883 .init_verbs = { alc883_init_verbs,
9884 alc883_2ch_fujitsu_pi2515_verbs},
9885 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9886 .dac_nids = alc883_dac_nids,
9887 .dig_out_nid = ALC883_DIGOUT_NID,
9888 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9889 .channel_mode = alc883_3ST_2ch_modes,
9890 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009891 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009892 .setup = alc883_2ch_fujitsu_pi2515_setup,
9893 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +01009894 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009895 [ALC888_FUJITSU_XA3530] = {
9896 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
9897 .init_verbs = { alc883_init_verbs,
9898 alc888_fujitsu_xa3530_verbs },
9899 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9900 .dac_nids = alc883_dac_nids,
9901 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
9902 .adc_nids = alc883_adc_nids_rev,
9903 .capsrc_nids = alc883_capsrc_nids_rev,
9904 .dig_out_nid = ALC883_DIGOUT_NID,
9905 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
9906 .channel_mode = alc888_4ST_8ch_intel_modes,
9907 .num_mux_defs =
9908 ARRAY_SIZE(alc888_2_capture_sources),
9909 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009910 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009911 .setup = alc888_fujitsu_xa3530_setup,
9912 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009913 },
Kailang Yange2757d52008-08-26 13:17:46 +02009914 [ALC888_LENOVO_SKY] = {
9915 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
9916 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
9917 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9918 .dac_nids = alc883_dac_nids,
9919 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02009920 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9921 .channel_mode = alc883_sixstack_modes,
9922 .need_dac_fix = 1,
9923 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009924 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009925 .setup = alc888_lenovo_sky_setup,
9926 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +02009927 },
9928 [ALC888_ASUS_M90V] = {
9929 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
9930 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
9931 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9932 .dac_nids = alc883_dac_nids,
9933 .dig_out_nid = ALC883_DIGOUT_NID,
9934 .dig_in_nid = ALC883_DIGIN_NID,
9935 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
9936 .channel_mode = alc883_3ST_6ch_modes,
9937 .need_dac_fix = 1,
9938 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009939 .unsol_event = alc_sku_unsol_event,
9940 .setup = alc883_mode2_setup,
9941 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +02009942 },
9943 [ALC888_ASUS_EEE1601] = {
9944 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009945 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02009946 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
9947 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9948 .dac_nids = alc883_dac_nids,
9949 .dig_out_nid = ALC883_DIGOUT_NID,
9950 .dig_in_nid = ALC883_DIGIN_NID,
9951 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9952 .channel_mode = alc883_3ST_2ch_modes,
9953 .need_dac_fix = 1,
9954 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009955 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +02009956 .init_hook = alc883_eee1601_inithook,
9957 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01009958 [ALC1200_ASUS_P5Q] = {
9959 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
9960 .init_verbs = { alc883_init_verbs },
9961 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9962 .dac_nids = alc883_dac_nids,
9963 .dig_out_nid = ALC1200_DIGOUT_NID,
9964 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08009965 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01009966 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
9967 .channel_mode = alc883_sixstack_modes,
9968 .input_mux = &alc883_capture_source,
9969 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009970 [ALC889A_MB31] = {
9971 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
9972 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
9973 alc880_gpio1_init_verbs },
9974 .adc_nids = alc883_adc_nids,
9975 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +01009976 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009977 .dac_nids = alc883_dac_nids,
9978 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9979 .channel_mode = alc889A_mb31_6ch_modes,
9980 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
9981 .input_mux = &alc889A_mb31_capture_source,
9982 .dig_out_nid = ALC883_DIGOUT_NID,
9983 .unsol_event = alc889A_mb31_unsol_event,
9984 .init_hook = alc889A_mb31_automute,
9985 },
Guido Günther3e1647c2009-06-05 00:47:26 +02009986 [ALC883_SONY_VAIO_TT] = {
9987 .mixers = { alc883_vaiott_mixer },
9988 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
9989 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
9990 .dac_nids = alc883_dac_nids,
9991 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
9992 .channel_mode = alc883_3ST_2ch_modes,
9993 .input_mux = &alc883_capture_source,
9994 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009995 .setup = alc883_vaiott_setup,
9996 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +02009997 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009998};
9999
10000
10001/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010002 * Pin config fixes
10003 */
10004enum {
10005 PINFIX_ABIT_AW9D_MAX
10006};
10007
10008static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
10009 { 0x15, 0x01080104 }, /* side */
10010 { 0x16, 0x01011012 }, /* rear */
10011 { 0x17, 0x01016011 }, /* clfe */
10012 { }
10013};
10014
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010015static const struct alc_fixup alc882_fixups[] = {
10016 [PINFIX_ABIT_AW9D_MAX] = {
10017 .pins = alc882_abit_aw9d_pinfix
10018 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010019};
10020
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010021static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +020010022 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10023 {}
10024};
10025
10026/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010027 * BIOS auto configuration
10028 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010029static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10030 const struct auto_pin_cfg *cfg)
10031{
10032 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10033}
10034
Takashi Iwai4953550a2009-06-30 15:28:30 +020010035static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010036 hda_nid_t nid, int pin_type,
10037 int dac_idx)
10038{
10039 /* set as output */
10040 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010041 int idx;
10042
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010043 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010044 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10045 idx = 4;
10046 else
10047 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010048 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10049
10050}
10051
Takashi Iwai4953550a2009-06-30 15:28:30 +020010052static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010053{
10054 struct alc_spec *spec = codec->spec;
10055 int i;
10056
10057 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010058 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010059 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010060 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010061 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010062 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010063 }
10064}
10065
Takashi Iwai4953550a2009-06-30 15:28:30 +020010066static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010067{
10068 struct alc_spec *spec = codec->spec;
10069 hda_nid_t pin;
10070
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010071 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010072 if (pin) /* connect to front */
10073 /* use dac 0 */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010074 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010075 pin = spec->autocfg.speaker_pins[0];
10076 if (pin)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010077 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010078}
10079
Takashi Iwai4953550a2009-06-30 15:28:30 +020010080static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010081{
10082 struct alc_spec *spec = codec->spec;
10083 int i;
10084
10085 for (i = 0; i < AUTO_PIN_LAST; i++) {
10086 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010087 if (!nid)
10088 continue;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010089 alc_set_input_pin(codec, nid, i);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010090 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10091 snd_hda_codec_write(codec, nid, 0,
10092 AC_VERB_SET_AMP_GAIN_MUTE,
10093 AMP_OUT_MUTE);
10094 }
10095}
10096
10097static void alc882_auto_init_input_src(struct hda_codec *codec)
10098{
10099 struct alc_spec *spec = codec->spec;
10100 int c;
10101
10102 for (c = 0; c < spec->num_adc_nids; c++) {
10103 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10104 hda_nid_t nid = spec->capsrc_nids[c];
10105 unsigned int mux_idx;
10106 const struct hda_input_mux *imux;
10107 int conns, mute, idx, item;
10108
10109 conns = snd_hda_get_connections(codec, nid, conn_list,
10110 ARRAY_SIZE(conn_list));
10111 if (conns < 0)
10112 continue;
10113 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10114 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010115 if (!imux->num_items && mux_idx > 0)
10116 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010117 for (idx = 0; idx < conns; idx++) {
10118 /* if the current connection is the selected one,
10119 * unmute it as default - otherwise mute it
10120 */
10121 mute = AMP_IN_MUTE(idx);
10122 for (item = 0; item < imux->num_items; item++) {
10123 if (imux->items[item].index == idx) {
10124 if (spec->cur_mux[c] == item)
10125 mute = AMP_IN_UNMUTE(idx);
10126 break;
10127 }
10128 }
10129 /* check if we have a selector or mixer
10130 * we could check for the widget type instead, but
10131 * just check for Amp-In presence (in case of mixer
10132 * without amp-in there is something wrong, this
10133 * function shouldn't be used or capsrc nid is wrong)
10134 */
10135 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010136 snd_hda_codec_write(codec, nid, 0,
10137 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010138 mute);
10139 else if (mute != AMP_IN_MUTE(idx))
10140 snd_hda_codec_write(codec, nid, 0,
10141 AC_VERB_SET_CONNECT_SEL,
10142 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010143 }
10144 }
10145}
10146
Takashi Iwai4953550a2009-06-30 15:28:30 +020010147/* add mic boosts if needed */
10148static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010149{
10150 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010151 int err;
10152 hda_nid_t nid;
10153
10154 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
10155 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10156 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10157 "Mic Boost",
10158 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10159 if (err < 0)
10160 return err;
10161 }
10162 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
10163 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
10164 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10165 "Front Mic Boost",
10166 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10167 if (err < 0)
10168 return err;
10169 }
10170 return 0;
10171}
10172
10173/* almost identical with ALC880 parser... */
10174static int alc882_parse_auto_config(struct hda_codec *codec)
10175{
10176 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010177 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
10178 int i, err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010179
Takashi Iwai05f5f472009-08-25 13:10:18 +020010180 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10181 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010182 if (err < 0)
10183 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010184 if (!spec->autocfg.line_outs)
10185 return 0; /* can't find valid BIOS pin config */
10186
10187 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10188 if (err < 0)
10189 return err;
10190 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10191 if (err < 0)
10192 return err;
10193 err = alc880_auto_create_extra_out(spec,
10194 spec->autocfg.speaker_pins[0],
10195 "Speaker");
10196 if (err < 0)
10197 return err;
10198 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10199 "Headphone");
10200 if (err < 0)
10201 return err;
10202 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10203 if (err < 0)
10204 return err;
10205
10206 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10207
10208 /* check multiple SPDIF-out (for recent codecs) */
10209 for (i = 0; i < spec->autocfg.dig_outs; i++) {
10210 hda_nid_t dig_nid;
10211 err = snd_hda_get_connections(codec,
10212 spec->autocfg.dig_out_pins[i],
10213 &dig_nid, 1);
10214 if (err < 0)
10215 continue;
10216 if (!i)
10217 spec->multiout.dig_out_nid = dig_nid;
10218 else {
10219 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010220 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
Takashi Iwai05f5f472009-08-25 13:10:18 +020010221 break;
Roel Kluin71121d9f2009-11-10 20:11:55 +010010222 spec->slave_dig_outs[i - 1] = dig_nid;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010223 }
10224 }
10225 if (spec->autocfg.dig_in_pin)
10226 spec->dig_in_nid = ALC880_DIGIN_NID;
10227
10228 if (spec->kctls.list)
10229 add_mixer(spec, spec->kctls.list);
10230
10231 add_verb(spec, alc883_auto_init_verbs);
10232 /* if ADC 0x07 is available, initialize it, too */
10233 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10234 add_verb(spec, alc882_adc1_init_verbs);
10235
10236 spec->num_mux_defs = 1;
10237 spec->input_mux = &spec->private_imux[0];
10238
Kailang Yang6227cdc2010-02-25 08:36:52 +010010239 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010240
10241 err = alc_auto_add_mic_boost(codec);
10242 if (err < 0)
10243 return err;
10244
Takashi Iwai776e1842007-08-29 15:07:11 +020010245 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010246}
10247
10248/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010249static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010250{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010251 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010252 alc882_auto_init_multi_out(codec);
10253 alc882_auto_init_hp_out(codec);
10254 alc882_auto_init_analog_input(codec);
10255 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010256 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010257 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010258}
10259
Takashi Iwai4953550a2009-06-30 15:28:30 +020010260static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010261{
10262 struct alc_spec *spec;
10263 int err, board_config;
10264
10265 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10266 if (spec == NULL)
10267 return -ENOMEM;
10268
10269 codec->spec = spec;
10270
Takashi Iwai4953550a2009-06-30 15:28:30 +020010271 switch (codec->vendor_id) {
10272 case 0x10ec0882:
10273 case 0x10ec0885:
10274 break;
10275 default:
10276 /* ALC883 and variants */
10277 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10278 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010279 }
10280
Takashi Iwai4953550a2009-06-30 15:28:30 +020010281 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10282 alc882_models,
10283 alc882_cfg_tbl);
10284
10285 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10286 board_config = snd_hda_check_board_codec_sid_config(codec,
10287 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10288
10289 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010290 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010291 codec->chip_name);
10292 board_config = ALC882_AUTO;
10293 }
10294
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010295 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010296
10297 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010298 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010299 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010300 if (err < 0) {
10301 alc_free(codec);
10302 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010303 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010304 printk(KERN_INFO
10305 "hda_codec: Cannot set up configuration "
10306 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010307 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010308 }
10309 }
10310
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010311 err = snd_hda_attach_beep_device(codec, 0x1);
10312 if (err < 0) {
10313 alc_free(codec);
10314 return err;
10315 }
10316
Takashi Iwai4953550a2009-06-30 15:28:30 +020010317 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010318 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010319
Takashi Iwai4953550a2009-06-30 15:28:30 +020010320 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10321 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10322 /* FIXME: setup DAC5 */
10323 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10324 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10325
10326 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10327 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10328
10329 if (codec->vendor_id == 0x10ec0888)
Takashi Iwai4a79ba32009-04-22 16:31:35 +020010330 spec->init_amp = ALC_INIT_DEFAULT; /* always initialize */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010331
10332 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010333 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010334 spec->num_adc_nids = 0;
10335 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010336 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010337 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010338 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010339 hda_nid_t nid = alc882_adc_nids[i];
10340 unsigned int wcap = get_wcaps(codec, nid);
10341 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010342 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010343 if (wcap != AC_WID_AUD_IN)
10344 continue;
10345 spec->private_adc_nids[spec->num_adc_nids] = nid;
10346 err = snd_hda_get_connections(codec, nid, &cap, 1);
10347 if (err < 0)
10348 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010349 err = snd_hda_get_connections(codec, cap, items,
10350 ARRAY_SIZE(items));
10351 if (err < 0)
10352 continue;
10353 for (j = 0; j < imux->num_items; j++)
10354 if (imux->items[j].index >= err)
10355 break;
10356 if (j < imux->num_items)
10357 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010358 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10359 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010360 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010361 spec->adc_nids = spec->private_adc_nids;
10362 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010363 }
10364
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010365 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010010366 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010367
Takashi Iwai2134ea42008-01-10 16:53:55 +010010368 spec->vmaster_nid = 0x0c;
10369
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010370 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010371 if (board_config == ALC882_AUTO)
10372 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010373#ifdef CONFIG_SND_HDA_POWER_SAVE
10374 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010375 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010376#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010377
10378 return 0;
10379}
10380
Takashi Iwai4953550a2009-06-30 15:28:30 +020010381
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010382/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010383 * ALC262 support
10384 */
10385
10386#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10387#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10388
10389#define alc262_dac_nids alc260_dac_nids
10390#define alc262_adc_nids alc882_adc_nids
10391#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010392#define alc262_capsrc_nids alc882_capsrc_nids
10393#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010394
10395#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010396#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010397
Kailang Yang4e555fe2008-08-26 13:05:55 +020010398static hda_nid_t alc262_dmic_adc_nids[1] = {
10399 /* ADC0 */
10400 0x09
10401};
10402
10403static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10404
Kailang Yangdf694da2005-12-05 19:42:22 +010010405static struct snd_kcontrol_new alc262_base_mixer[] = {
10406 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10407 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10408 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10409 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10410 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10411 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010414 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010415 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10416 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010417 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010418 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10419 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10420 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10421 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010422 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010423};
10424
Takashi Iwaice875f02008-01-28 18:17:43 +010010425/* update HP, line and mono-out pins according to the master switch */
10426static void alc262_hp_master_update(struct hda_codec *codec)
10427{
10428 struct alc_spec *spec = codec->spec;
10429 int val = spec->master_sw;
10430
10431 /* HP & line-out */
10432 snd_hda_codec_write_cache(codec, 0x1b, 0,
10433 AC_VERB_SET_PIN_WIDGET_CONTROL,
10434 val ? PIN_HP : 0);
10435 snd_hda_codec_write_cache(codec, 0x15, 0,
10436 AC_VERB_SET_PIN_WIDGET_CONTROL,
10437 val ? PIN_HP : 0);
10438 /* mono (speaker) depending on the HP jack sense */
10439 val = val && !spec->jack_present;
10440 snd_hda_codec_write_cache(codec, 0x16, 0,
10441 AC_VERB_SET_PIN_WIDGET_CONTROL,
10442 val ? PIN_OUT : 0);
10443}
10444
10445static void alc262_hp_bpc_automute(struct hda_codec *codec)
10446{
10447 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010448
10449 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010010450 alc262_hp_master_update(codec);
10451}
10452
10453static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
10454{
10455 if ((res >> 26) != ALC880_HP_EVENT)
10456 return;
10457 alc262_hp_bpc_automute(codec);
10458}
10459
10460static void alc262_hp_wildwest_automute(struct hda_codec *codec)
10461{
10462 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080010463
10464 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010010465 alc262_hp_master_update(codec);
10466}
10467
10468static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
10469 unsigned int res)
10470{
10471 if ((res >> 26) != ALC880_HP_EVENT)
10472 return;
10473 alc262_hp_wildwest_automute(codec);
10474}
10475
Takashi Iwaib72519b2009-05-08 14:31:55 +020010476#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010010477
10478static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
10479 struct snd_ctl_elem_value *ucontrol)
10480{
10481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10482 struct alc_spec *spec = codec->spec;
10483 int val = !!*ucontrol->value.integer.value;
10484
10485 if (val == spec->master_sw)
10486 return 0;
10487 spec->master_sw = val;
10488 alc262_hp_master_update(codec);
10489 return 1;
10490}
10491
Takashi Iwaib72519b2009-05-08 14:31:55 +020010492#define ALC262_HP_MASTER_SWITCH \
10493 { \
10494 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10495 .name = "Master Playback Switch", \
10496 .info = snd_ctl_boolean_mono_info, \
10497 .get = alc262_hp_master_sw_get, \
10498 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010499 }, \
10500 { \
10501 .iface = NID_MAPPING, \
10502 .name = "Master Playback Switch", \
10503 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020010504 }
10505
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010506
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010507static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010508 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010509 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10510 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10511 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010512 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10513 HDA_OUTPUT),
10514 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10515 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10517 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010518 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010519 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10520 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010521 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010522 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10523 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10524 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10525 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010526 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
10527 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
10528 { } /* end */
10529};
10530
Kailang Yangcd7509a2007-01-26 18:33:17 +010010531static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020010532 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010010533 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10534 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
10535 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010010537 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
10538 HDA_OUTPUT),
10539 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
10540 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010541 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
10542 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010543 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010544 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10545 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10546 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10547 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010548 { } /* end */
10549};
10550
10551static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
10552 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10553 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010554 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010555 { } /* end */
10556};
10557
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010558/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010559static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010560{
10561 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010562
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010563 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010010564 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010565}
10566
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010567static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010010568 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10569 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010570 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10571 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10572 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10573 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10574 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10575 { } /* end */
10576};
10577
10578static struct hda_verb alc262_hp_t5735_verbs[] = {
10579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10580 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10581
10582 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10583 { }
10584};
10585
Kailang Yang8c427222008-01-10 13:03:59 +010010586static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010010587 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10588 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010010589 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
10590 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010010591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
10592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
10593 { } /* end */
10594};
10595
10596static struct hda_verb alc262_hp_rp5700_verbs[] = {
10597 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10598 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10599 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10600 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10601 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10602 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10604 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10606 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
10607 {}
10608};
10609
10610static struct hda_input_mux alc262_hp_rp5700_capture_source = {
10611 .num_items = 1,
10612 .items = {
10613 { "Line", 0x1 },
10614 },
10615};
10616
Takashi Iwai42171c12009-05-08 14:11:43 +020010617/* bind hp and internal speaker mute (with plug check) as master switch */
10618static void alc262_hippo_master_update(struct hda_codec *codec)
10619{
10620 struct alc_spec *spec = codec->spec;
10621 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10622 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10623 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10624 unsigned int mute;
10625
10626 /* HP */
10627 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
10628 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
10629 HDA_AMP_MUTE, mute);
10630 /* mute internal speaker per jack sense */
10631 if (spec->jack_present)
10632 mute = HDA_AMP_MUTE;
10633 if (line_nid)
10634 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
10635 HDA_AMP_MUTE, mute);
10636 if (speaker_nid && speaker_nid != line_nid)
10637 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
10638 HDA_AMP_MUTE, mute);
10639}
10640
10641#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
10642
10643static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
10644 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020010645{
10646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020010647 struct alc_spec *spec = codec->spec;
10648 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010649
Takashi Iwai42171c12009-05-08 14:11:43 +020010650 if (val == spec->master_sw)
10651 return 0;
10652 spec->master_sw = val;
10653 alc262_hippo_master_update(codec);
10654 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020010655}
Takashi Iwai5b319542007-07-26 11:49:22 +020010656
Takashi Iwai42171c12009-05-08 14:11:43 +020010657#define ALC262_HIPPO_MASTER_SWITCH \
10658 { \
10659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
10660 .name = "Master Playback Switch", \
10661 .info = snd_ctl_boolean_mono_info, \
10662 .get = alc262_hippo_master_sw_get, \
10663 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010010664 }, \
10665 { \
10666 .iface = NID_MAPPING, \
10667 .name = "Master Playback Switch", \
10668 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
10669 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020010670 }
10671
10672static struct snd_kcontrol_new alc262_hippo_mixer[] = {
10673 ALC262_HIPPO_MASTER_SWITCH,
10674 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10675 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10676 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10677 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10678 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10679 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10680 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10681 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10682 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10683 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10684 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10685 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10686 { } /* end */
10687};
10688
10689static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
10690 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10691 ALC262_HIPPO_MASTER_SWITCH,
10692 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10693 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10694 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10695 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10696 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10697 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10699 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10700 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10701 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10702 { } /* end */
10703};
10704
10705/* mute/unmute internal speaker according to the hp jack and mute state */
10706static void alc262_hippo_automute(struct hda_codec *codec)
10707{
10708 struct alc_spec *spec = codec->spec;
10709 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020010710
Wu Fengguang864f92b2009-11-18 12:38:02 +080010711 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020010712 alc262_hippo_master_update(codec);
10713}
10714
10715static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
10716{
10717 if ((res >> 26) != ALC880_HP_EVENT)
10718 return;
10719 alc262_hippo_automute(codec);
10720}
10721
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010722static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010723{
10724 struct alc_spec *spec = codec->spec;
10725
10726 spec->autocfg.hp_pins[0] = 0x15;
10727 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010728}
10729
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010730static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020010731{
10732 struct alc_spec *spec = codec->spec;
10733
10734 spec->autocfg.hp_pins[0] = 0x1b;
10735 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020010736}
10737
10738
Kailang Yang272a5272007-05-14 11:00:38 +020010739static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020010740 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020010741 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020010742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10744 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10745 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10746 { } /* end */
10747};
10748
Kailang Yang83c34212007-07-05 11:43:05 +020010749static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020010750 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10751 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020010752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10755 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10756 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10757 { } /* end */
10758};
Kailang Yang272a5272007-05-14 11:00:38 +020010759
Tony Vroonba340e82009-02-02 19:01:30 +000010760static struct snd_kcontrol_new alc262_tyan_mixer[] = {
10761 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10762 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
10763 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
10764 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
10765 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10766 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10769 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10770 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10771 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10772 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10773 { } /* end */
10774};
10775
10776static struct hda_verb alc262_tyan_verbs[] = {
10777 /* Headphone automute */
10778 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10779 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10781
10782 /* P11 AUX_IN, white 4-pin connector */
10783 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10784 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
10785 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
10786 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
10787
10788 {}
10789};
10790
10791/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010792static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000010793{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010794 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000010795
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010796 spec->autocfg.hp_pins[0] = 0x1b;
10797 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000010798}
10799
Tony Vroonba340e82009-02-02 19:01:30 +000010800
Kailang Yangdf694da2005-12-05 19:42:22 +010010801#define alc262_capture_mixer alc882_capture_mixer
10802#define alc262_capture_alt_mixer alc882_capture_alt_mixer
10803
10804/*
10805 * generic initialization of ADC, input mixers and output mixers
10806 */
10807static struct hda_verb alc262_init_verbs[] = {
10808 /*
10809 * Unmute ADC0-2 and set the default input to mic-in
10810 */
10811 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10812 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10813 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10814 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10815 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10816 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10817
Takashi Iwaicb53c622007-08-10 17:21:45 +020010818 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010819 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010820 * Note: PASD motherboards uses the Line In 2 as the input for
10821 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010822 */
10823 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010824 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10825 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10826 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10828 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010829
10830 /*
10831 * Set up output mixers (0x0c - 0x0e)
10832 */
10833 /* set vol=0 to output mixers */
10834 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10835 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10836 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10837 /* set up input amps for analog loopback */
10838 /* Amp Indices: DAC = 0, mixer = 1 */
10839 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10841 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10842 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10843 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10844 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10845
10846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10849 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10850 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10851 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10852
10853 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10855 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10857 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020010858
Kailang Yangdf694da2005-12-05 19:42:22 +010010859 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10860 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020010861
Kailang Yangdf694da2005-12-05 19:42:22 +010010862 /* FIXME: use matrix-type input source selection */
10863 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10864 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10868 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10869 /* Input mixer2 */
10870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10871 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10872 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10873 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10874 /* Input mixer3 */
10875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10877 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010878 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010010879
10880 { }
10881};
10882
Kailang Yang4e555fe2008-08-26 13:05:55 +020010883static struct hda_verb alc262_eapd_verbs[] = {
10884 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10885 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10886 { }
10887};
10888
Kailang Yangccc656c2006-10-17 12:32:26 +020010889static struct hda_verb alc262_hippo1_unsol_verbs[] = {
10890 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10891 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10892 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
10893
10894 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10895 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10896 {}
10897};
10898
Kailang Yang272a5272007-05-14 11:00:38 +020010899static struct hda_verb alc262_sony_unsol_verbs[] = {
10900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10901 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10902 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
10903
10904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090010906 {}
Kailang Yang272a5272007-05-14 11:00:38 +020010907};
10908
Kailang Yang4e555fe2008-08-26 13:05:55 +020010909static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
10910 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10911 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10912 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10913 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10914 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020010915 { } /* end */
10916};
10917
10918static struct hda_verb alc262_toshiba_s06_verbs[] = {
10919 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10920 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10922 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10923 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
10924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10925 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10926 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10927 {}
10928};
10929
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010930static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020010931{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010932 struct alc_spec *spec = codec->spec;
10933
10934 spec->autocfg.hp_pins[0] = 0x15;
10935 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010936 spec->ext_mic.pin = 0x18;
10937 spec->ext_mic.mux_idx = 0;
10938 spec->int_mic.pin = 0x12;
10939 spec->int_mic.mux_idx = 9;
10940 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020010941}
10942
Takashi Iwai834be882006-03-01 14:16:17 +010010943/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010944 * nec model
10945 * 0x15 = headphone
10946 * 0x16 = internal speaker
10947 * 0x18 = external mic
10948 */
10949
10950static struct snd_kcontrol_new alc262_nec_mixer[] = {
10951 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
10952 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
10953
10954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10957
10958 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
10959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10960 { } /* end */
10961};
10962
10963static struct hda_verb alc262_nec_verbs[] = {
10964 /* Unmute Speaker */
10965 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10966
10967 /* Headphone */
10968 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10969 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10970
10971 /* External mic to headphone */
10972 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10973 /* External mic to speaker */
10974 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10975 {}
10976};
10977
10978/*
Takashi Iwai834be882006-03-01 14:16:17 +010010979 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010010980 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
10981 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010010982 */
10983
10984#define ALC_HP_EVENT 0x37
10985
10986static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
10987 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10988 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010010989 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10990 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010010991 {}
10992};
10993
Jiang zhe0e31daf2008-03-20 12:12:39 +010010994static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
10995 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
10996 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10997 {}
10998};
10999
Daniel T Chene2595322009-12-19 18:19:02 -050011000static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11001 /* Front Mic pin: input vref at 50% */
11002 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11003 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11004 {}
11005};
11006
Takashi Iwai834be882006-03-01 14:16:17 +010011007static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011008 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011009 .items = {
11010 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011011 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011012 { "CD", 0x4 },
11013 },
11014};
11015
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011016static struct hda_input_mux alc262_HP_capture_source = {
11017 .num_items = 5,
11018 .items = {
11019 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011020 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011021 { "Line", 0x2 },
11022 { "CD", 0x4 },
11023 { "AUX IN", 0x6 },
11024 },
11025};
11026
zhejiangaccbe492007-08-31 12:36:05 +020011027static struct hda_input_mux alc262_HP_D7000_capture_source = {
11028 .num_items = 4,
11029 .items = {
11030 { "Mic", 0x0 },
11031 { "Front Mic", 0x2 },
11032 { "Line", 0x1 },
11033 { "CD", 0x4 },
11034 },
11035};
11036
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011037/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011038static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11039{
11040 struct alc_spec *spec = codec->spec;
11041 unsigned int mute;
11042
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011043 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011044 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11045 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011046 spec->sense_updated = 1;
11047 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011048 /* unmute internal speaker only if both HPs are unplugged and
11049 * master switch is on
11050 */
11051 if (spec->jack_present)
11052 mute = HDA_AMP_MUTE;
11053 else
Takashi Iwai834be882006-03-01 14:16:17 +010011054 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011055 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11056 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011057}
11058
11059/* unsolicited event for HP jack sensing */
11060static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11061 unsigned int res)
11062{
11063 if ((res >> 26) != ALC_HP_EVENT)
11064 return;
11065 alc262_fujitsu_automute(codec, 1);
11066}
11067
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011068static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11069{
11070 alc262_fujitsu_automute(codec, 1);
11071}
11072
Takashi Iwai834be882006-03-01 14:16:17 +010011073/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011074static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11075 .ops = &snd_hda_bind_vol,
11076 .values = {
11077 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11078 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11079 0
11080 },
11081};
Takashi Iwai834be882006-03-01 14:16:17 +010011082
Jiang zhe0e31daf2008-03-20 12:12:39 +010011083/* mute/unmute internal speaker according to the hp jack and mute state */
11084static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11085{
11086 struct alc_spec *spec = codec->spec;
11087 unsigned int mute;
11088
11089 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011090 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011091 spec->sense_updated = 1;
11092 }
11093 if (spec->jack_present) {
11094 /* mute internal speaker */
11095 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11096 HDA_AMP_MUTE, HDA_AMP_MUTE);
11097 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11098 HDA_AMP_MUTE, HDA_AMP_MUTE);
11099 } else {
11100 /* unmute internal speaker if necessary */
11101 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11102 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11103 HDA_AMP_MUTE, mute);
11104 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11105 HDA_AMP_MUTE, mute);
11106 }
11107}
11108
11109/* unsolicited event for HP jack sensing */
11110static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11111 unsigned int res)
11112{
11113 if ((res >> 26) != ALC_HP_EVENT)
11114 return;
11115 alc262_lenovo_3000_automute(codec, 1);
11116}
11117
Takashi Iwai8de56b72009-07-24 16:51:47 +020011118static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11119 int dir, int idx, long *valp)
11120{
11121 int i, change = 0;
11122
11123 for (i = 0; i < 2; i++, valp++)
11124 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11125 HDA_AMP_MUTE,
11126 *valp ? 0 : HDA_AMP_MUTE);
11127 return change;
11128}
11129
Takashi Iwai834be882006-03-01 14:16:17 +010011130/* bind hp and internal speaker mute (with plug check) */
11131static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11132 struct snd_ctl_elem_value *ucontrol)
11133{
11134 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11135 long *valp = ucontrol->value.integer.value;
11136 int change;
11137
Takashi Iwai8de56b72009-07-24 16:51:47 +020011138 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11139 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011140 if (change)
11141 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011142 return change;
11143}
11144
11145static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011146 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011147 {
11148 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11149 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011150 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011151 .info = snd_hda_mixer_amp_switch_info,
11152 .get = snd_hda_mixer_amp_switch_get,
11153 .put = alc262_fujitsu_master_sw_put,
11154 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11155 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011156 {
11157 .iface = NID_MAPPING,
11158 .name = "Master Playback Switch",
11159 .private_value = 0x1b,
11160 },
Takashi Iwai834be882006-03-01 14:16:17 +010011161 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11162 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11163 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11164 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11165 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011166 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11167 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11168 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011169 { } /* end */
11170};
11171
Jiang zhe0e31daf2008-03-20 12:12:39 +010011172/* bind hp and internal speaker mute (with plug check) */
11173static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11174 struct snd_ctl_elem_value *ucontrol)
11175{
11176 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11177 long *valp = ucontrol->value.integer.value;
11178 int change;
11179
Takashi Iwai8de56b72009-07-24 16:51:47 +020011180 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011181 if (change)
11182 alc262_lenovo_3000_automute(codec, 0);
11183 return change;
11184}
11185
11186static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11187 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11188 {
11189 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11190 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011191 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011192 .info = snd_hda_mixer_amp_switch_info,
11193 .get = snd_hda_mixer_amp_switch_get,
11194 .put = alc262_lenovo_3000_master_sw_put,
11195 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11196 },
11197 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11198 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11199 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11200 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11201 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11202 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11203 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11204 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11205 { } /* end */
11206};
11207
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011208static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11209 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011210 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11212 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11213 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11214 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11215 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11216 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11217 { } /* end */
11218};
11219
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011220/* additional init verbs for Benq laptops */
11221static struct hda_verb alc262_EAPD_verbs[] = {
11222 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11223 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11224 {}
11225};
11226
Kailang Yang83c34212007-07-05 11:43:05 +020011227static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11228 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11229 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11230
11231 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11232 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11233 {}
11234};
11235
Tobin Davisf651b502007-10-26 12:40:47 +020011236/* Samsung Q1 Ultra Vista model setup */
11237static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011238 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11239 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11241 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11242 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011243 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011244 { } /* end */
11245};
11246
11247static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011248 /* output mixer */
11249 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11250 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11251 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11252 /* speaker */
11253 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11254 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11255 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11256 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11257 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11260 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11261 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11263 /* internal mic */
11264 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11266 /* ADC, choose mic */
11267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011277 {}
11278};
11279
Tobin Davisf651b502007-10-26 12:40:47 +020011280/* mute/unmute internal speaker according to the hp jack and mute state */
11281static void alc262_ultra_automute(struct hda_codec *codec)
11282{
11283 struct alc_spec *spec = codec->spec;
11284 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011285
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011286 mute = 0;
11287 /* auto-mute only when HP is used as HP */
11288 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011289 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011290 if (spec->jack_present)
11291 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011292 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011293 /* mute/unmute internal speaker */
11294 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11295 HDA_AMP_MUTE, mute);
11296 /* mute/unmute HP */
11297 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11298 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011299}
11300
11301/* unsolicited event for HP jack sensing */
11302static void alc262_ultra_unsol_event(struct hda_codec *codec,
11303 unsigned int res)
11304{
11305 if ((res >> 26) != ALC880_HP_EVENT)
11306 return;
11307 alc262_ultra_automute(codec);
11308}
11309
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011310static struct hda_input_mux alc262_ultra_capture_source = {
11311 .num_items = 2,
11312 .items = {
11313 { "Mic", 0x1 },
11314 { "Headphone", 0x7 },
11315 },
11316};
11317
11318static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11319 struct snd_ctl_elem_value *ucontrol)
11320{
11321 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11322 struct alc_spec *spec = codec->spec;
11323 int ret;
11324
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011325 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011326 if (!ret)
11327 return 0;
11328 /* reprogram the HP pin as mic or HP according to the input source */
11329 snd_hda_codec_write_cache(codec, 0x15, 0,
11330 AC_VERB_SET_PIN_WIDGET_CONTROL,
11331 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11332 alc262_ultra_automute(codec); /* mute/unmute HP */
11333 return ret;
11334}
11335
11336static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11337 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11338 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11339 {
11340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11341 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011342 .info = alc_mux_enum_info,
11343 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011344 .put = alc262_ultra_mux_enum_put,
11345 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011346 {
11347 .iface = NID_MAPPING,
11348 .name = "Capture Source",
11349 .private_value = 0x15,
11350 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011351 { } /* end */
11352};
11353
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011354/* We use two mixers depending on the output pin; 0x16 is a mono output
11355 * and thus it's bound with a different mixer.
11356 * This function returns which mixer amp should be used.
11357 */
11358static int alc262_check_volbit(hda_nid_t nid)
11359{
11360 if (!nid)
11361 return 0;
11362 else if (nid == 0x16)
11363 return 2;
11364 else
11365 return 1;
11366}
11367
11368static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
11369 const char *pfx, int *vbits)
11370{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011371 unsigned long val;
11372 int vbit;
11373
11374 vbit = alc262_check_volbit(nid);
11375 if (!vbit)
11376 return 0;
11377 if (*vbits & vbit) /* a volume control for this mixer already there */
11378 return 0;
11379 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011380 if (vbit == 2)
11381 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11382 else
11383 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011384 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011385}
11386
11387static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
11388 const char *pfx)
11389{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011390 unsigned long val;
11391
11392 if (!nid)
11393 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011394 if (nid == 0x16)
11395 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11396 else
11397 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai0afe5f82009-10-02 09:20:00 +020011398 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011399}
11400
Kailang Yangdf694da2005-12-05 19:42:22 +010011401/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011402static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11403 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011404{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011405 const char *pfx;
11406 int vbits;
Kailang Yangdf694da2005-12-05 19:42:22 +010011407 int err;
11408
11409 spec->multiout.num_dacs = 1; /* only use one dac */
11410 spec->multiout.dac_nids = spec->private_dac_nids;
11411 spec->multiout.dac_nids[0] = 2;
11412
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011413 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11414 pfx = "Master";
11415 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11416 pfx = "Speaker";
11417 else
11418 pfx = "Front";
11419 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[0], pfx);
11420 if (err < 0)
11421 return err;
11422 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[0], "Speaker");
11423 if (err < 0)
11424 return err;
11425 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[0], "Headphone");
11426 if (err < 0)
11427 return err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011428
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011429 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
11430 alc262_check_volbit(cfg->speaker_pins[0]) |
11431 alc262_check_volbit(cfg->hp_pins[0]);
11432 if (vbits == 1 || vbits == 2)
11433 pfx = "Master"; /* only one mixer is used */
11434 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11435 pfx = "Speaker";
11436 else
11437 pfx = "Front";
11438 vbits = 0;
11439 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[0], pfx, &vbits);
11440 if (err < 0)
11441 return err;
11442 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[0], "Speaker",
11443 &vbits);
11444 if (err < 0)
11445 return err;
11446 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[0], "Headphone",
11447 &vbits);
11448 if (err < 0)
11449 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011450 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010011451}
11452
Takashi Iwai05f5f472009-08-25 13:10:18 +020011453#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010011454 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010011455
11456/*
11457 * generic initialization of ADC, input mixers and output mixers
11458 */
11459static struct hda_verb alc262_volume_init_verbs[] = {
11460 /*
11461 * Unmute ADC0-2 and set the default input to mic-in
11462 */
11463 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11465 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11466 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11467 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11468 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11469
Takashi Iwaicb53c622007-08-10 17:21:45 +020011470 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011471 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011472 * Note: PASD motherboards uses the Line In 2 as the input for
11473 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011474 */
11475 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011476 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11477 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11478 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11479 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11480 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011481
11482 /*
11483 * Set up output mixers (0x0c - 0x0f)
11484 */
11485 /* set vol=0 to output mixers */
11486 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11488 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020011489
Kailang Yangdf694da2005-12-05 19:42:22 +010011490 /* set up input amps for analog loopback */
11491 /* Amp Indices: DAC = 0, mixer = 1 */
11492 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11493 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11494 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11495 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11496 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11497 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11498
11499 /* FIXME: use matrix-type input source selection */
11500 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11501 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11502 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11503 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11504 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11505 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11506 /* Input mixer2 */
11507 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11509 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11510 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11511 /* Input mixer3 */
11512 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11513 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11516
11517 { }
11518};
11519
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011520static struct hda_verb alc262_HP_BPC_init_verbs[] = {
11521 /*
11522 * Unmute ADC0-2 and set the default input to mic-in
11523 */
11524 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11526 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11527 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11528 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11529 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11530
Takashi Iwaicb53c622007-08-10 17:21:45 +020011531 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011532 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011533 * Note: PASD motherboards uses the Line In 2 as the input for
11534 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011535 */
11536 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020011544
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011545 /*
11546 * Set up output mixers (0x0c - 0x0e)
11547 */
11548 /* set vol=0 to output mixers */
11549 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11550 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11552
11553 /* set up input amps for analog loopback */
11554 /* Amp Indices: DAC = 0, mixer = 1 */
11555 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11557 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11558 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11559 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11560 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11561
Takashi Iwaice875f02008-01-28 18:17:43 +010011562 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011563 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11564 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
11565
11566 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11567 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11568
11569 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11570 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11571
11572 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11573 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11574 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11575 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11576 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11577
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011578 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011579 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11580 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011581 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011582 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11583 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11584
11585
11586 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011587 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
11588 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011590 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11592 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11593 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11594 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11595 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11596 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11597 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011598 /* Input mixer2 */
11599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011600 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11601 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11602 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11603 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11604 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11605 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11606 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11607 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011608 /* Input mixer3 */
11609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020011610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
11611 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11612 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11613 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
11615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
11616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
11617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011618
Takashi Iwaice875f02008-01-28 18:17:43 +010011619 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11620
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011621 { }
11622};
11623
Kailang Yangcd7509a2007-01-26 18:33:17 +010011624static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
11625 /*
11626 * Unmute ADC0-2 and set the default input to mic-in
11627 */
11628 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11630 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11632 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11634
Takashi Iwaicb53c622007-08-10 17:21:45 +020011635 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010011636 * mixer widget
11637 * Note: PASD motherboards uses the Line In 2 as the input for front
11638 * panel mic (mic 2)
11639 */
11640 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11646 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11647 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11648 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010011649 /*
11650 * Set up output mixers (0x0c - 0x0e)
11651 */
11652 /* set vol=0 to output mixers */
11653 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11654 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11656
11657 /* set up input amps for analog loopback */
11658 /* Amp Indices: DAC = 0, mixer = 1 */
11659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11662 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11664 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11665
11666
11667 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
11668 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
11669 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
11670 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
11671 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11672 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
11673 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
11674
11675 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11676 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11677
11678 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11679 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11680
11681 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
11682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11684 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
11685 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11686 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
11687
11688 /* FIXME: use matrix-type input source selection */
11689 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11690 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
11692 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
11693 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
11694 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
11695 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
11696 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11697 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
11698 /* Input mixer2 */
11699 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11700 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11701 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11702 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11703 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11704 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11705 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11706 /* Input mixer3 */
11707 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11708 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11709 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
11710 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
11711 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
11712 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
11713 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
11714
Takashi Iwaice875f02008-01-28 18:17:43 +010011715 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11716
Kailang Yangcd7509a2007-01-26 18:33:17 +010011717 { }
11718};
11719
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011720static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
11721
11722 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
11723 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
11724 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
11725
11726 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
11727 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
11728 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11729 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
11730
11731 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
11732 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11733 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11734 {}
11735};
11736
11737
Takashi Iwaicb53c622007-08-10 17:21:45 +020011738#ifdef CONFIG_SND_HDA_POWER_SAVE
11739#define alc262_loopbacks alc880_loopbacks
11740#endif
11741
Sasha Alexandrdef319f2009-06-16 16:00:15 -040011742/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011743#define alc262_pcm_analog_playback alc880_pcm_analog_playback
11744#define alc262_pcm_analog_capture alc880_pcm_analog_capture
11745#define alc262_pcm_digital_playback alc880_pcm_digital_playback
11746#define alc262_pcm_digital_capture alc880_pcm_digital_capture
11747
11748/*
11749 * BIOS auto configuration
11750 */
11751static int alc262_parse_auto_config(struct hda_codec *codec)
11752{
11753 struct alc_spec *spec = codec->spec;
11754 int err;
11755 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
11756
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011757 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11758 alc262_ignore);
11759 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011760 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011761 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011762 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011763 spec->multiout.max_channels = 2;
11764 spec->no_analog = 1;
11765 goto dig_only;
11766 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011767 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011768 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011769 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
11770 if (err < 0)
11771 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020011772 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011773 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010011774 return err;
11775
11776 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11777
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011778 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011779 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011780 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010011781 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011782 }
Kailang Yangdf694da2005-12-05 19:42:22 +010011783 if (spec->autocfg.dig_in_pin)
11784 spec->dig_in_nid = ALC262_DIGIN_NID;
11785
Takashi Iwai603c4012008-07-30 15:01:44 +020011786 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011787 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010011788
Takashi Iwaid88897e2008-10-31 15:01:37 +010011789 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020011790 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011791 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010011792
Takashi Iwai776e1842007-08-29 15:07:11 +020011793 err = alc_auto_add_mic_boost(codec);
11794 if (err < 0)
11795 return err;
11796
Kailang Yang6227cdc2010-02-25 08:36:52 +010011797 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020011798
Kailang Yangdf694da2005-12-05 19:42:22 +010011799 return 1;
11800}
11801
11802#define alc262_auto_init_multi_out alc882_auto_init_multi_out
11803#define alc262_auto_init_hp_out alc882_auto_init_hp_out
11804#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020011805#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010011806
11807
11808/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011809static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010011810{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011811 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010011812 alc262_auto_init_multi_out(codec);
11813 alc262_auto_init_hp_out(codec);
11814 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020011815 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011816 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011817 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010011818}
11819
11820/*
11821 * configuration and preset
11822 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011823static const char *alc262_models[ALC262_MODEL_LAST] = {
11824 [ALC262_BASIC] = "basic",
11825 [ALC262_HIPPO] = "hippo",
11826 [ALC262_HIPPO_1] = "hippo_1",
11827 [ALC262_FUJITSU] = "fujitsu",
11828 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010011829 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010011830 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010011831 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011832 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020011833 [ALC262_BENQ_T31] = "benq-t31",
11834 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020011835 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011836 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020011837 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010011838 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011839 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000011840 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011841 [ALC262_AUTO] = "auto",
11842};
11843
11844static struct snd_pci_quirk alc262_cfg_tbl[] = {
11845 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011846 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011847 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
11848 ALC262_HP_BPC),
11849 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
11850 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010011851 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
11852 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011853 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011854 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011855 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011856 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011857 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011858 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011859 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011860 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011861 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
11862 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
11863 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011864 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
11865 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010011866 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011867 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011868 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011869 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010011870 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020011871 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050011872 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010011873 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011874#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010011875 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
11876 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010011877#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090011878 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011879 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020011880 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011881 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010011882 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000011883 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010011884 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
11885 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110011886 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011887 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011888 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020011889 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011890 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010011891 {}
11892};
11893
11894static struct alc_config_preset alc262_presets[] = {
11895 [ALC262_BASIC] = {
11896 .mixers = { alc262_base_mixer },
11897 .init_verbs = { alc262_init_verbs },
11898 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11899 .dac_nids = alc262_dac_nids,
11900 .hp_nid = 0x03,
11901 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11902 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010011903 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010011904 },
Kailang Yangccc656c2006-10-17 12:32:26 +020011905 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011906 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020011907 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020011908 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11909 .dac_nids = alc262_dac_nids,
11910 .hp_nid = 0x03,
11911 .dig_out_nid = ALC262_DIGOUT_NID,
11912 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11913 .channel_mode = alc262_modes,
11914 .input_mux = &alc262_capture_source,
11915 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011916 .setup = alc262_hippo_setup,
11917 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011918 },
11919 [ALC262_HIPPO_1] = {
11920 .mixers = { alc262_hippo1_mixer },
11921 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
11922 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11923 .dac_nids = alc262_dac_nids,
11924 .hp_nid = 0x02,
11925 .dig_out_nid = ALC262_DIGOUT_NID,
11926 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11927 .channel_mode = alc262_modes,
11928 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020011929 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011930 .setup = alc262_hippo1_setup,
11931 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020011932 },
Takashi Iwai834be882006-03-01 14:16:17 +010011933 [ALC262_FUJITSU] = {
11934 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011935 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
11936 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010011937 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11938 .dac_nids = alc262_dac_nids,
11939 .hp_nid = 0x03,
11940 .dig_out_nid = ALC262_DIGOUT_NID,
11941 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11942 .channel_mode = alc262_modes,
11943 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011944 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011945 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010011946 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011947 [ALC262_HP_BPC] = {
11948 .mixers = { alc262_HP_BPC_mixer },
11949 .init_verbs = { alc262_HP_BPC_init_verbs },
11950 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11951 .dac_nids = alc262_dac_nids,
11952 .hp_nid = 0x03,
11953 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11954 .channel_mode = alc262_modes,
11955 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011956 .unsol_event = alc262_hp_bpc_unsol_event,
11957 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011958 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011959 [ALC262_HP_BPC_D7000_WF] = {
11960 .mixers = { alc262_HP_BPC_WildWest_mixer },
11961 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11962 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11963 .dac_nids = alc262_dac_nids,
11964 .hp_nid = 0x03,
11965 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11966 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011967 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011968 .unsol_event = alc262_hp_wildwest_unsol_event,
11969 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011970 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010011971 [ALC262_HP_BPC_D7000_WL] = {
11972 .mixers = { alc262_HP_BPC_WildWest_mixer,
11973 alc262_HP_BPC_WildWest_option_mixer },
11974 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
11975 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11976 .dac_nids = alc262_dac_nids,
11977 .hp_nid = 0x03,
11978 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11979 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020011980 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010011981 .unsol_event = alc262_hp_wildwest_unsol_event,
11982 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011983 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011984 [ALC262_HP_TC_T5735] = {
11985 .mixers = { alc262_hp_t5735_mixer },
11986 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
11987 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
11988 .dac_nids = alc262_dac_nids,
11989 .hp_nid = 0x03,
11990 .num_channel_mode = ARRAY_SIZE(alc262_modes),
11991 .channel_mode = alc262_modes,
11992 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011993 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011994 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010011995 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010011996 },
11997 [ALC262_HP_RP5700] = {
11998 .mixers = { alc262_hp_rp5700_mixer },
11999 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12000 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12001 .dac_nids = alc262_dac_nids,
12002 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12003 .channel_mode = alc262_modes,
12004 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012005 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012006 [ALC262_BENQ_ED8] = {
12007 .mixers = { alc262_base_mixer },
12008 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12009 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12010 .dac_nids = alc262_dac_nids,
12011 .hp_nid = 0x03,
12012 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12013 .channel_mode = alc262_modes,
12014 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012015 },
Kailang Yang272a5272007-05-14 11:00:38 +020012016 [ALC262_SONY_ASSAMD] = {
12017 .mixers = { alc262_sony_mixer },
12018 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12019 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12020 .dac_nids = alc262_dac_nids,
12021 .hp_nid = 0x02,
12022 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12023 .channel_mode = alc262_modes,
12024 .input_mux = &alc262_capture_source,
12025 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012026 .setup = alc262_hippo_setup,
12027 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012028 },
12029 [ALC262_BENQ_T31] = {
12030 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012031 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12032 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012033 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12034 .dac_nids = alc262_dac_nids,
12035 .hp_nid = 0x03,
12036 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12037 .channel_mode = alc262_modes,
12038 .input_mux = &alc262_capture_source,
12039 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012040 .setup = alc262_hippo_setup,
12041 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012042 },
Tobin Davisf651b502007-10-26 12:40:47 +020012043 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012044 .mixers = { alc262_ultra_mixer },
12045 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012046 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012047 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12048 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012049 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12050 .channel_mode = alc262_modes,
12051 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012052 .adc_nids = alc262_adc_nids, /* ADC0 */
12053 .capsrc_nids = alc262_capsrc_nids,
12054 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012055 .unsol_event = alc262_ultra_unsol_event,
12056 .init_hook = alc262_ultra_automute,
12057 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012058 [ALC262_LENOVO_3000] = {
12059 .mixers = { alc262_lenovo_3000_mixer },
12060 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012061 alc262_lenovo_3000_unsol_verbs,
12062 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012063 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12064 .dac_nids = alc262_dac_nids,
12065 .hp_nid = 0x03,
12066 .dig_out_nid = ALC262_DIGOUT_NID,
12067 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12068 .channel_mode = alc262_modes,
12069 .input_mux = &alc262_fujitsu_capture_source,
12070 .unsol_event = alc262_lenovo_3000_unsol_event,
12071 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012072 [ALC262_NEC] = {
12073 .mixers = { alc262_nec_mixer },
12074 .init_verbs = { alc262_nec_verbs },
12075 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12076 .dac_nids = alc262_dac_nids,
12077 .hp_nid = 0x03,
12078 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12079 .channel_mode = alc262_modes,
12080 .input_mux = &alc262_capture_source,
12081 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012082 [ALC262_TOSHIBA_S06] = {
12083 .mixers = { alc262_toshiba_s06_mixer },
12084 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12085 alc262_eapd_verbs },
12086 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12087 .capsrc_nids = alc262_dmic_capsrc_nids,
12088 .dac_nids = alc262_dac_nids,
12089 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012090 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012091 .dig_out_nid = ALC262_DIGOUT_NID,
12092 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12093 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012094 .unsol_event = alc_sku_unsol_event,
12095 .setup = alc262_toshiba_s06_setup,
12096 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012097 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012098 [ALC262_TOSHIBA_RX1] = {
12099 .mixers = { alc262_toshiba_rx1_mixer },
12100 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12101 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12102 .dac_nids = alc262_dac_nids,
12103 .hp_nid = 0x03,
12104 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12105 .channel_mode = alc262_modes,
12106 .input_mux = &alc262_capture_source,
12107 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012108 .setup = alc262_hippo_setup,
12109 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012110 },
Tony Vroonba340e82009-02-02 19:01:30 +000012111 [ALC262_TYAN] = {
12112 .mixers = { alc262_tyan_mixer },
12113 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12114 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12115 .dac_nids = alc262_dac_nids,
12116 .hp_nid = 0x02,
12117 .dig_out_nid = ALC262_DIGOUT_NID,
12118 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12119 .channel_mode = alc262_modes,
12120 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012121 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012122 .setup = alc262_tyan_setup,
12123 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012124 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012125};
12126
12127static int patch_alc262(struct hda_codec *codec)
12128{
12129 struct alc_spec *spec;
12130 int board_config;
12131 int err;
12132
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012133 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012134 if (spec == NULL)
12135 return -ENOMEM;
12136
12137 codec->spec = spec;
12138#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012139 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12140 * under-run
12141 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012142 {
12143 int tmp;
12144 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12145 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12146 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12147 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12148 }
12149#endif
12150
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012151 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12152
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012153 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12154 alc262_models,
12155 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012156
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012157 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012158 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12159 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012160 board_config = ALC262_AUTO;
12161 }
12162
12163 if (board_config == ALC262_AUTO) {
12164 /* automatic parse from the BIOS config */
12165 err = alc262_parse_auto_config(codec);
12166 if (err < 0) {
12167 alc_free(codec);
12168 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012169 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012170 printk(KERN_INFO
12171 "hda_codec: Cannot set up configuration "
12172 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012173 board_config = ALC262_BASIC;
12174 }
12175 }
12176
Takashi Iwai07eba612009-02-19 08:06:35 +010012177 if (!spec->no_analog) {
12178 err = snd_hda_attach_beep_device(codec, 0x1);
12179 if (err < 0) {
12180 alc_free(codec);
12181 return err;
12182 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012183 }
12184
Kailang Yangdf694da2005-12-05 19:42:22 +010012185 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012186 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012187
Kailang Yangdf694da2005-12-05 19:42:22 +010012188 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12189 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012190
Kailang Yangdf694da2005-12-05 19:42:22 +010012191 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12192 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12193
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012194 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012195 int i;
12196 /* check whether the digital-mic has to be supported */
12197 for (i = 0; i < spec->input_mux->num_items; i++) {
12198 if (spec->input_mux->items[i].index >= 9)
12199 break;
12200 }
12201 if (i < spec->input_mux->num_items) {
12202 /* use only ADC0 */
12203 spec->adc_nids = alc262_dmic_adc_nids;
12204 spec->num_adc_nids = 1;
12205 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012206 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012207 /* all analog inputs */
12208 /* check whether NID 0x07 is valid */
12209 unsigned int wcap = get_wcaps(codec, 0x07);
12210
12211 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012212 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012213 if (wcap != AC_WID_AUD_IN) {
12214 spec->adc_nids = alc262_adc_nids_alt;
12215 spec->num_adc_nids =
12216 ARRAY_SIZE(alc262_adc_nids_alt);
12217 spec->capsrc_nids = alc262_capsrc_nids_alt;
12218 } else {
12219 spec->adc_nids = alc262_adc_nids;
12220 spec->num_adc_nids =
12221 ARRAY_SIZE(alc262_adc_nids);
12222 spec->capsrc_nids = alc262_capsrc_nids;
12223 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012224 }
12225 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012226 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012227 set_capture_mixer(codec);
Takashi Iwai07eba612009-02-19 08:06:35 +010012228 if (!spec->no_analog)
12229 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012230
Takashi Iwai2134ea42008-01-10 16:53:55 +010012231 spec->vmaster_nid = 0x0c;
12232
Kailang Yangdf694da2005-12-05 19:42:22 +010012233 codec->patch_ops = alc_patch_ops;
12234 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012235 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012236#ifdef CONFIG_SND_HDA_POWER_SAVE
12237 if (!spec->loopback.amplist)
12238 spec->loopback.amplist = alc262_loopbacks;
12239#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012240
Kailang Yangdf694da2005-12-05 19:42:22 +010012241 return 0;
12242}
12243
Kailang Yangdf694da2005-12-05 19:42:22 +010012244/*
Kailang Yanga361d842007-06-05 12:30:55 +020012245 * ALC268 channel source setting (2 channel)
12246 */
12247#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12248#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012249
Kailang Yanga361d842007-06-05 12:30:55 +020012250static hda_nid_t alc268_dac_nids[2] = {
12251 /* front, hp */
12252 0x02, 0x03
12253};
12254
12255static hda_nid_t alc268_adc_nids[2] = {
12256 /* ADC0-1 */
12257 0x08, 0x07
12258};
12259
12260static hda_nid_t alc268_adc_nids_alt[1] = {
12261 /* ADC0 */
12262 0x08
12263};
12264
Takashi Iwaie1406342008-02-11 18:32:32 +010012265static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12266
Kailang Yanga361d842007-06-05 12:30:55 +020012267static struct snd_kcontrol_new alc268_base_mixer[] = {
12268 /* output mixer control */
12269 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12270 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12271 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12272 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12275 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012276 { }
12277};
12278
Takashi Iwai42171c12009-05-08 14:11:43 +020012279static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12280 /* output mixer control */
12281 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12283 ALC262_HIPPO_MASTER_SWITCH,
12284 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12285 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12286 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12287 { }
12288};
12289
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012290/* bind Beep switches of both NID 0x0f and 0x10 */
12291static struct hda_bind_ctls alc268_bind_beep_sw = {
12292 .ops = &snd_hda_bind_sw,
12293 .values = {
12294 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12295 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12296 0
12297 },
12298};
12299
12300static struct snd_kcontrol_new alc268_beep_mixer[] = {
12301 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12302 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12303 { }
12304};
12305
Kailang Yangd1a991a2007-08-15 16:21:59 +020012306static struct hda_verb alc268_eapd_verbs[] = {
12307 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12308 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12309 { }
12310};
12311
Takashi Iwaid2738092007-08-16 14:59:45 +020012312/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012313static struct hda_verb alc268_toshiba_verbs[] = {
12314 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12315 { } /* end */
12316};
12317
12318/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012319/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012320static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12321 .ops = &snd_hda_bind_vol,
12322 .values = {
12323 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12324 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12325 0
12326 },
12327};
12328
Takashi Iwai889c4392007-08-23 18:56:52 +020012329/* mute/unmute internal speaker according to the hp jack and mute state */
12330static void alc268_acer_automute(struct hda_codec *codec, int force)
12331{
12332 struct alc_spec *spec = codec->spec;
12333 unsigned int mute;
12334
12335 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012336 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012337 spec->sense_updated = 1;
12338 }
12339 if (spec->jack_present)
12340 mute = HDA_AMP_MUTE; /* mute internal speaker */
12341 else /* unmute internal speaker if necessary */
12342 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12343 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12344 HDA_AMP_MUTE, mute);
12345}
12346
12347
12348/* bind hp and internal speaker mute (with plug check) */
12349static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12350 struct snd_ctl_elem_value *ucontrol)
12351{
12352 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12353 long *valp = ucontrol->value.integer.value;
12354 int change;
12355
Takashi Iwai8de56b72009-07-24 16:51:47 +020012356 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012357 if (change)
12358 alc268_acer_automute(codec, 0);
12359 return change;
12360}
Takashi Iwaid2738092007-08-16 14:59:45 +020012361
Kailang Yang8ef355d2008-08-26 13:10:22 +020012362static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12363 /* output mixer control */
12364 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12365 {
12366 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12367 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012368 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012369 .info = snd_hda_mixer_amp_switch_info,
12370 .get = snd_hda_mixer_amp_switch_get,
12371 .put = alc268_acer_master_sw_put,
12372 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12373 },
12374 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12375 { }
12376};
12377
Takashi Iwaid2738092007-08-16 14:59:45 +020012378static struct snd_kcontrol_new alc268_acer_mixer[] = {
12379 /* output mixer control */
12380 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12381 {
12382 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12383 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012384 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012385 .info = snd_hda_mixer_amp_switch_info,
12386 .get = snd_hda_mixer_amp_switch_get,
12387 .put = alc268_acer_master_sw_put,
12388 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12389 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012390 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12391 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12392 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020012393 { }
12394};
12395
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012396static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
12397 /* output mixer control */
12398 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12399 {
12400 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12401 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012402 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012403 .info = snd_hda_mixer_amp_switch_info,
12404 .get = snd_hda_mixer_amp_switch_get,
12405 .put = alc268_acer_master_sw_put,
12406 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12407 },
12408 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12409 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12410 { }
12411};
12412
Kailang Yang8ef355d2008-08-26 13:10:22 +020012413static struct hda_verb alc268_acer_aspire_one_verbs[] = {
12414 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12416 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12417 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12418 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
12419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
12420 { }
12421};
12422
Takashi Iwaid2738092007-08-16 14:59:45 +020012423static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012424 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
12425 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020012426 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012428 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12429 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020012430 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12431 { }
12432};
12433
12434/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020012435#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012436#define alc268_toshiba_setup alc262_hippo_setup
12437#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020012438
12439static void alc268_acer_unsol_event(struct hda_codec *codec,
12440 unsigned int res)
12441{
Takashi Iwai889c4392007-08-23 18:56:52 +020012442 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020012443 return;
12444 alc268_acer_automute(codec, 1);
12445}
12446
Takashi Iwai889c4392007-08-23 18:56:52 +020012447static void alc268_acer_init_hook(struct hda_codec *codec)
12448{
12449 alc268_acer_automute(codec, 1);
12450}
12451
Kailang Yang8ef355d2008-08-26 13:10:22 +020012452/* toggle speaker-output according to the hp-jack state */
12453static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
12454{
12455 unsigned int present;
12456 unsigned char bits;
12457
Wu Fengguang864f92b2009-11-18 12:38:02 +080012458 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012459 bits = present ? AMP_IN_MUTE(0) : 0;
12460 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
12461 AMP_IN_MUTE(0), bits);
12462 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
12463 AMP_IN_MUTE(0), bits);
12464}
12465
Kailang Yang8ef355d2008-08-26 13:10:22 +020012466static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
12467 unsigned int res)
12468{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012469 switch (res >> 26) {
12470 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020012471 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012472 break;
12473 case ALC880_MIC_EVENT:
12474 alc_mic_automute(codec);
12475 break;
12476 }
12477}
12478
12479static void alc268_acer_lc_setup(struct hda_codec *codec)
12480{
12481 struct alc_spec *spec = codec->spec;
12482 spec->ext_mic.pin = 0x18;
12483 spec->ext_mic.mux_idx = 0;
12484 spec->int_mic.pin = 0x12;
12485 spec->int_mic.mux_idx = 6;
12486 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020012487}
12488
12489static void alc268_acer_lc_init_hook(struct hda_codec *codec)
12490{
12491 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012492 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020012493}
12494
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012495static struct snd_kcontrol_new alc268_dell_mixer[] = {
12496 /* output mixer control */
12497 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12498 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12499 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12500 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12501 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12502 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12503 { }
12504};
12505
12506static struct hda_verb alc268_dell_verbs[] = {
12507 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12508 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12509 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012510 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012511 { }
12512};
12513
12514/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012515static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012516{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012517 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012518
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012519 spec->autocfg.hp_pins[0] = 0x15;
12520 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012521 spec->ext_mic.pin = 0x18;
12522 spec->ext_mic.mux_idx = 0;
12523 spec->int_mic.pin = 0x19;
12524 spec->int_mic.mux_idx = 1;
12525 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012526}
12527
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012528static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
12529 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12530 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12531 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12533 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12534 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
12535 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
12536 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
12537 { }
12538};
12539
12540static struct hda_verb alc267_quanta_il1_verbs[] = {
12541 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12542 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
12543 { }
12544};
12545
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012546static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012547{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012548 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012549 spec->autocfg.hp_pins[0] = 0x15;
12550 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012551 spec->ext_mic.pin = 0x18;
12552 spec->ext_mic.mux_idx = 0;
12553 spec->int_mic.pin = 0x19;
12554 spec->int_mic.mux_idx = 1;
12555 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012556}
12557
Kailang Yanga361d842007-06-05 12:30:55 +020012558/*
12559 * generic initialization of ADC, input mixers and output mixers
12560 */
12561static struct hda_verb alc268_base_init_verbs[] = {
12562 /* Unmute DAC0-1 and set vol = 0 */
12563 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012564 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012565
12566 /*
12567 * Set up output mixers (0x0c - 0x0e)
12568 */
12569 /* set vol=0 to output mixers */
12570 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012571 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
12572
12573 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12574 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12575
12576 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12577 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
12578 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
12579 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12580 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12581 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12582 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12583 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12584
12585 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12586 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12587 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12588 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012590
12591 /* set PCBEEP vol = 0, mute connections */
12592 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12593 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12594 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012595
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012596 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020012597
Jiang Zhea9b3aa82007-12-20 13:13:13 +010012598 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
12599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12600 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
12601 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012602
Kailang Yanga361d842007-06-05 12:30:55 +020012603 { }
12604};
12605
12606/*
12607 * generic initialization of ADC, input mixers and output mixers
12608 */
12609static struct hda_verb alc268_volume_init_verbs[] = {
12610 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010012611 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12612 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020012613
12614 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12615 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12616 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12617 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12618 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12619
Kailang Yanga361d842007-06-05 12:30:55 +020012620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020012621 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12622 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12623
12624 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020012626
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012627 /* set PCBEEP vol = 0, mute connections */
12628 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12629 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12630 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020012631
12632 { }
12633};
12634
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012635static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
12636 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12637 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12638 { } /* end */
12639};
12640
Kailang Yanga361d842007-06-05 12:30:55 +020012641static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
12642 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12643 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012644 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020012645 { } /* end */
12646};
12647
12648static struct snd_kcontrol_new alc268_capture_mixer[] = {
12649 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12650 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
12651 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
12652 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020012653 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020012654 { } /* end */
12655};
12656
12657static struct hda_input_mux alc268_capture_source = {
12658 .num_items = 4,
12659 .items = {
12660 { "Mic", 0x0 },
12661 { "Front Mic", 0x1 },
12662 { "Line", 0x2 },
12663 { "CD", 0x3 },
12664 },
12665};
12666
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012667static struct hda_input_mux alc268_acer_capture_source = {
12668 .num_items = 3,
12669 .items = {
12670 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012671 { "Internal Mic", 0x1 },
12672 { "Line", 0x2 },
12673 },
12674};
12675
12676static struct hda_input_mux alc268_acer_dmic_capture_source = {
12677 .num_items = 3,
12678 .items = {
12679 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010012680 { "Internal Mic", 0x6 },
12681 { "Line", 0x2 },
12682 },
12683};
12684
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012685#ifdef CONFIG_SND_DEBUG
12686static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012687 /* Volume widgets */
12688 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12689 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
12690 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
12691 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
12692 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
12693 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
12694 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
12695 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
12696 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
12697 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
12698 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
12699 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
12700 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010012701 /* The below appears problematic on some hardwares */
12702 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012703 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
12704 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
12705 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
12706 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
12707
12708 /* Modes for retasking pin widgets */
12709 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
12710 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
12711 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
12712 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
12713
12714 /* Controls for GPIO pins, assuming they are configured as outputs */
12715 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
12716 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
12717 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
12718 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
12719
12720 /* Switches to allow the digital SPDIF output pin to be enabled.
12721 * The ALC268 does not have an SPDIF input.
12722 */
12723 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
12724
12725 /* A switch allowing EAPD to be enabled. Some laptops seem to use
12726 * this output to turn on an external amplifier.
12727 */
12728 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
12729 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
12730
12731 { } /* end */
12732};
12733#endif
12734
Kailang Yanga361d842007-06-05 12:30:55 +020012735/* create input playback/capture controls for the given pin */
12736static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
12737 const char *ctlname, int idx)
12738{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012739 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020012740 int err;
12741
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012742 switch (nid) {
12743 case 0x14:
12744 case 0x16:
12745 dac = 0x02;
12746 break;
12747 case 0x15:
12748 dac = 0x03;
12749 break;
12750 default:
12751 return 0;
12752 }
12753 if (spec->multiout.dac_nids[0] != dac &&
12754 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012755 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012756 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020012757 HDA_OUTPUT));
12758 if (err < 0)
12759 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012760 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
12761 }
12762
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012763 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012764 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020012765 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012766 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012767 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012768 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012769 if (err < 0)
12770 return err;
12771 return 0;
12772}
12773
12774/* add playback controls from the parsed DAC table */
12775static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
12776 const struct auto_pin_cfg *cfg)
12777{
12778 hda_nid_t nid;
12779 int err;
12780
Kailang Yanga361d842007-06-05 12:30:55 +020012781 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020012782
12783 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012784 if (nid) {
12785 const char *name;
12786 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12787 name = "Speaker";
12788 else
12789 name = "Front";
12790 err = alc268_new_analog_output(spec, nid, name, 0);
12791 if (err < 0)
12792 return err;
12793 }
Kailang Yanga361d842007-06-05 12:30:55 +020012794
12795 nid = cfg->speaker_pins[0];
12796 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012797 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020012798 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
12799 if (err < 0)
12800 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012801 } else {
12802 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
12803 if (err < 0)
12804 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020012805 }
12806 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012807 if (nid) {
12808 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
12809 if (err < 0)
12810 return err;
12811 }
Kailang Yanga361d842007-06-05 12:30:55 +020012812
12813 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
12814 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020012815 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020012816 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020012817 if (err < 0)
12818 return err;
12819 }
Kailang Yangea1fb292008-08-26 12:58:38 +020012820 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020012821}
12822
12823/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020012824static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020012825 const struct auto_pin_cfg *cfg)
12826{
Takashi Iwai05f5f472009-08-25 13:10:18 +020012827 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020012828}
12829
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012830static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
12831 hda_nid_t nid, int pin_type)
12832{
12833 int idx;
12834
12835 alc_set_pin_output(codec, nid, pin_type);
12836 if (nid == 0x14 || nid == 0x16)
12837 idx = 0;
12838 else
12839 idx = 1;
12840 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
12841}
12842
12843static void alc268_auto_init_multi_out(struct hda_codec *codec)
12844{
12845 struct alc_spec *spec = codec->spec;
12846 hda_nid_t nid = spec->autocfg.line_out_pins[0];
12847 if (nid) {
12848 int pin_type = get_pin_type(spec->autocfg.line_out_type);
12849 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
12850 }
12851}
12852
12853static void alc268_auto_init_hp_out(struct hda_codec *codec)
12854{
12855 struct alc_spec *spec = codec->spec;
12856 hda_nid_t pin;
12857
12858 pin = spec->autocfg.hp_pins[0];
12859 if (pin)
12860 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
12861 pin = spec->autocfg.speaker_pins[0];
12862 if (pin)
12863 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
12864}
12865
Kailang Yanga361d842007-06-05 12:30:55 +020012866static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
12867{
12868 struct alc_spec *spec = codec->spec;
12869 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
12870 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
12871 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
12872 unsigned int dac_vol1, dac_vol2;
12873
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012874 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020012875 snd_hda_codec_write(codec, speaker_nid, 0,
12876 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012877 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012878 snd_hda_codec_write(codec, 0x0f, 0,
12879 AC_VERB_SET_AMP_GAIN_MUTE,
12880 AMP_IN_UNMUTE(1));
12881 snd_hda_codec_write(codec, 0x10, 0,
12882 AC_VERB_SET_AMP_GAIN_MUTE,
12883 AMP_IN_UNMUTE(1));
12884 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020012885 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020012886 snd_hda_codec_write(codec, 0x0f, 0,
12887 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12888 snd_hda_codec_write(codec, 0x10, 0,
12889 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
12890 }
12891
12892 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020012893 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012894 dac_vol2 = AMP_OUT_ZERO;
12895 else if (line_nid == 0x15)
12896 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020012897 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020012898 dac_vol2 = AMP_OUT_ZERO;
12899 else if (hp_nid == 0x15)
12900 dac_vol1 = AMP_OUT_ZERO;
12901 if (line_nid != 0x16 || hp_nid != 0x16 ||
12902 spec->autocfg.line_out_pins[1] != 0x16 ||
12903 spec->autocfg.line_out_pins[2] != 0x16)
12904 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
12905
12906 snd_hda_codec_write(codec, 0x02, 0,
12907 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
12908 snd_hda_codec_write(codec, 0x03, 0,
12909 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
12910}
12911
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012912/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020012913#define alc268_pcm_analog_playback alc880_pcm_analog_playback
12914#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010012915#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020012916#define alc268_pcm_digital_playback alc880_pcm_digital_playback
12917
12918/*
12919 * BIOS auto configuration
12920 */
12921static int alc268_parse_auto_config(struct hda_codec *codec)
12922{
12923 struct alc_spec *spec = codec->spec;
12924 int err;
12925 static hda_nid_t alc268_ignore[] = { 0 };
12926
12927 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12928 alc268_ignore);
12929 if (err < 0)
12930 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012931 if (!spec->autocfg.line_outs) {
12932 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
12933 spec->multiout.max_channels = 2;
12934 spec->no_analog = 1;
12935 goto dig_only;
12936 }
Kailang Yanga361d842007-06-05 12:30:55 +020012937 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012938 }
Kailang Yanga361d842007-06-05 12:30:55 +020012939 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
12940 if (err < 0)
12941 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012942 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020012943 if (err < 0)
12944 return err;
12945
12946 spec->multiout.max_channels = 2;
12947
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012948 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020012949 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012950 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020012951 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012952 spec->dig_out_type = spec->autocfg.dig_out_type[0];
12953 }
Takashi Iwai603c4012008-07-30 15:01:44 +020012954 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012955 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020012956
Takashi Iwai892981f2009-03-02 08:04:35 +010012957 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012958 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012959
Takashi Iwaid88897e2008-10-31 15:01:37 +010012960 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030012961 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012962 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020012963
Takashi Iwai776e1842007-08-29 15:07:11 +020012964 err = alc_auto_add_mic_boost(codec);
12965 if (err < 0)
12966 return err;
12967
Kailang Yang6227cdc2010-02-25 08:36:52 +010012968 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020012969
Kailang Yanga361d842007-06-05 12:30:55 +020012970 return 1;
12971}
12972
Kailang Yanga361d842007-06-05 12:30:55 +020012973#define alc268_auto_init_analog_input alc882_auto_init_analog_input
12974
12975/* init callback for auto-configuration model -- overriding the default init */
12976static void alc268_auto_init(struct hda_codec *codec)
12977{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012978 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020012979 alc268_auto_init_multi_out(codec);
12980 alc268_auto_init_hp_out(codec);
12981 alc268_auto_init_mono_speaker_out(codec);
12982 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012983 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012984 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020012985}
12986
12987/*
12988 * configuration and preset
12989 */
12990static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020012991 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020012992 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020012993 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020012994 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010012995 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020012996 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012997 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012998 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012999#ifdef CONFIG_SND_DEBUG
13000 [ALC268_TEST] = "test",
13001#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013002 [ALC268_AUTO] = "auto",
13003};
13004
13005static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013006 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013007 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013008 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013009 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013010 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013011 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13012 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013013 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013014 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13015 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013016 /* almost compatible with toshiba but with optional digital outs;
13017 * auto-probing seems working fine
13018 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013019 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013020 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013021 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013022 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013023 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013024 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013025 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013026 SND_PCI_QUIRK(0x1854, 0x1775, "LG R510", ALC268_DELL),
Kailang Yanga361d842007-06-05 12:30:55 +020013027 {}
13028};
13029
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013030/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13031static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13032 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13033 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13034 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13035 ALC268_TOSHIBA),
13036 {}
13037};
13038
Kailang Yanga361d842007-06-05 12:30:55 +020013039static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013040 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013041 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13042 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013043 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13044 alc267_quanta_il1_verbs },
13045 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13046 .dac_nids = alc268_dac_nids,
13047 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13048 .adc_nids = alc268_adc_nids_alt,
13049 .hp_nid = 0x03,
13050 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13051 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013052 .unsol_event = alc_sku_unsol_event,
13053 .setup = alc267_quanta_il1_setup,
13054 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013055 },
Kailang Yanga361d842007-06-05 12:30:55 +020013056 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013057 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13058 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013059 .init_verbs = { alc268_base_init_verbs },
13060 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13061 .dac_nids = alc268_dac_nids,
13062 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13063 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013064 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013065 .hp_nid = 0x03,
13066 .dig_out_nid = ALC268_DIGOUT_NID,
13067 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13068 .channel_mode = alc268_modes,
13069 .input_mux = &alc268_capture_source,
13070 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013071 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013072 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013073 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013074 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13075 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013076 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13077 .dac_nids = alc268_dac_nids,
13078 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13079 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013080 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013081 .hp_nid = 0x03,
13082 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13083 .channel_mode = alc268_modes,
13084 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013085 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013086 .setup = alc268_toshiba_setup,
13087 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013088 },
13089 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013090 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013091 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013092 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13093 alc268_acer_verbs },
13094 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13095 .dac_nids = alc268_dac_nids,
13096 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13097 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013098 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013099 .hp_nid = 0x02,
13100 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13101 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013102 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013103 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013104 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013105 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013106 [ALC268_ACER_DMIC] = {
13107 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13108 alc268_beep_mixer },
13109 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13110 alc268_acer_verbs },
13111 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13112 .dac_nids = alc268_dac_nids,
13113 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13114 .adc_nids = alc268_adc_nids_alt,
13115 .capsrc_nids = alc268_capsrc_nids,
13116 .hp_nid = 0x02,
13117 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13118 .channel_mode = alc268_modes,
13119 .input_mux = &alc268_acer_dmic_capture_source,
13120 .unsol_event = alc268_acer_unsol_event,
13121 .init_hook = alc268_acer_init_hook,
13122 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013123 [ALC268_ACER_ASPIRE_ONE] = {
13124 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013125 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013126 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013127 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13128 alc268_acer_aspire_one_verbs },
13129 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13130 .dac_nids = alc268_dac_nids,
13131 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13132 .adc_nids = alc268_adc_nids_alt,
13133 .capsrc_nids = alc268_capsrc_nids,
13134 .hp_nid = 0x03,
13135 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13136 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013137 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013138 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013139 .init_hook = alc268_acer_lc_init_hook,
13140 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013141 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013142 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13143 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013144 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13145 alc268_dell_verbs },
13146 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13147 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013148 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13149 .adc_nids = alc268_adc_nids_alt,
13150 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013151 .hp_nid = 0x02,
13152 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13153 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013154 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013155 .setup = alc268_dell_setup,
13156 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013157 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013158 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013159 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13160 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013161 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13162 alc268_toshiba_verbs },
13163 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13164 .dac_nids = alc268_dac_nids,
13165 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13166 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013167 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013168 .hp_nid = 0x03,
13169 .dig_out_nid = ALC268_DIGOUT_NID,
13170 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13171 .channel_mode = alc268_modes,
13172 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013173 .setup = alc268_toshiba_setup,
13174 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013175 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013176#ifdef CONFIG_SND_DEBUG
13177 [ALC268_TEST] = {
13178 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13179 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13180 alc268_volume_init_verbs },
13181 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13182 .dac_nids = alc268_dac_nids,
13183 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13184 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013185 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013186 .hp_nid = 0x03,
13187 .dig_out_nid = ALC268_DIGOUT_NID,
13188 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13189 .channel_mode = alc268_modes,
13190 .input_mux = &alc268_capture_source,
13191 },
13192#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013193};
13194
13195static int patch_alc268(struct hda_codec *codec)
13196{
13197 struct alc_spec *spec;
13198 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013199 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013200
Julia Lawallef86f582009-12-19 08:18:03 +010013201 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013202 if (spec == NULL)
13203 return -ENOMEM;
13204
13205 codec->spec = spec;
13206
13207 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13208 alc268_models,
13209 alc268_cfg_tbl);
13210
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013211 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13212 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013213 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013214
Kailang Yanga361d842007-06-05 12:30:55 +020013215 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013216 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13217 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013218 board_config = ALC268_AUTO;
13219 }
13220
13221 if (board_config == ALC268_AUTO) {
13222 /* automatic parse from the BIOS config */
13223 err = alc268_parse_auto_config(codec);
13224 if (err < 0) {
13225 alc_free(codec);
13226 return err;
13227 } else if (!err) {
13228 printk(KERN_INFO
13229 "hda_codec: Cannot set up configuration "
13230 "from BIOS. Using base mode...\n");
13231 board_config = ALC268_3ST;
13232 }
13233 }
13234
13235 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013236 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013237
Kailang Yanga361d842007-06-05 12:30:55 +020013238 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13239 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013240 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013241
Kailang Yanga361d842007-06-05 12:30:55 +020013242 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13243
Takashi Iwai22971e32009-02-10 11:56:44 +010013244 has_beep = 0;
13245 for (i = 0; i < spec->num_mixers; i++) {
13246 if (spec->mixers[i] == alc268_beep_mixer) {
13247 has_beep = 1;
13248 break;
13249 }
13250 }
13251
13252 if (has_beep) {
13253 err = snd_hda_attach_beep_device(codec, 0x1);
13254 if (err < 0) {
13255 alc_free(codec);
13256 return err;
13257 }
13258 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13259 /* override the amp caps for beep generator */
13260 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013261 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13262 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13263 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13264 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013265 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013266
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013267 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013268 /* check whether NID 0x07 is valid */
13269 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013270 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013271
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013272 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013273 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013274 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013275 if (spec->auto_mic ||
13276 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013277 spec->adc_nids = alc268_adc_nids_alt;
13278 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013279 if (spec->auto_mic)
13280 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013281 if (spec->auto_mic || spec->input_mux->num_items == 1)
13282 add_mixer(spec, alc268_capture_nosrc_mixer);
13283 else
13284 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013285 } else {
13286 spec->adc_nids = alc268_adc_nids;
13287 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013288 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013289 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013290 /* set default input source */
13291 for (i = 0; i < spec->num_adc_nids; i++)
13292 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13293 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013294 i < spec->num_mux_defs ?
13295 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013296 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013297 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013298
13299 spec->vmaster_nid = 0x02;
13300
Kailang Yanga361d842007-06-05 12:30:55 +020013301 codec->patch_ops = alc_patch_ops;
13302 if (board_config == ALC268_AUTO)
13303 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013304
Kailang Yanga361d842007-06-05 12:30:55 +020013305 return 0;
13306}
13307
13308/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013309 * ALC269 channel source setting (2 channel)
13310 */
13311#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13312
13313#define alc269_dac_nids alc260_dac_nids
13314
13315static hda_nid_t alc269_adc_nids[1] = {
13316 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013317 0x08,
13318};
13319
Takashi Iwaie01bf502008-08-21 16:25:07 +020013320static hda_nid_t alc269_capsrc_nids[1] = {
13321 0x23,
13322};
13323
Kailang Yang84898e82010-02-04 14:16:14 +010013324static hda_nid_t alc269vb_adc_nids[1] = {
13325 /* ADC1 */
13326 0x09,
13327};
13328
13329static hda_nid_t alc269vb_capsrc_nids[1] = {
13330 0x22,
13331};
13332
Takashi Iwaie01bf502008-08-21 16:25:07 +020013333/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
13334 * not a mux!
13335 */
13336
Kailang Yangf6a92242007-12-13 16:52:54 +010013337#define alc269_modes alc260_modes
13338#define alc269_capture_source alc880_lg_lw_capture_source
13339
13340static struct snd_kcontrol_new alc269_base_mixer[] = {
13341 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13342 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13343 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13344 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13346 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13347 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13348 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13349 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13350 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13351 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13352 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13353 { } /* end */
13354};
13355
Kailang Yang60db6b52008-08-26 13:13:00 +020013356static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13357 /* output mixer control */
13358 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13359 {
13360 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13361 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013362 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013363 .info = snd_hda_mixer_amp_switch_info,
13364 .get = snd_hda_mixer_amp_switch_get,
13365 .put = alc268_acer_master_sw_put,
13366 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13367 },
13368 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13369 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13370 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13371 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13372 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13373 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013374 { }
13375};
13376
Tony Vroon64154832008-11-06 15:08:49 +000013377static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13378 /* output mixer control */
13379 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13380 {
13381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13382 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013383 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013384 .info = snd_hda_mixer_amp_switch_info,
13385 .get = snd_hda_mixer_amp_switch_get,
13386 .put = alc268_acer_master_sw_put,
13387 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13388 },
13389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13391 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13392 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13393 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13394 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13395 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
13396 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
13397 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000013398 { }
13399};
13400
Kailang Yang84898e82010-02-04 14:16:14 +010013401static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020013402 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013403 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020013404 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010013405 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020013406 { } /* end */
13407};
13408
Kailang Yang84898e82010-02-04 14:16:14 +010013409static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
13410 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13411 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13412 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
13413 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13414 { } /* end */
13415};
13416
Kailang Yangf6a92242007-12-13 16:52:54 +010013417/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010013418static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
13419 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13420 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
13421 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13422 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13423 { } /* end */
13424};
13425
13426static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020013427 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
13428 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010013429 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13430 { } /* end */
13431};
13432
Kailang Yang84898e82010-02-04 14:16:14 +010013433static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
13434 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13435 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13436 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13437 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
13438 { } /* end */
13439};
13440
13441static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
13442 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13443 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13444 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13445 { } /* end */
13446};
13447
Takashi Iwai26f5df22008-11-03 17:39:46 +010013448/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010013449#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020013450
Kailang Yang60db6b52008-08-26 13:13:00 +020013451static struct hda_verb alc269_quanta_fl1_verbs[] = {
13452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13453 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13454 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13455 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13456 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13457 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13458 { }
13459};
13460
Tony Vroon64154832008-11-06 15:08:49 +000013461static struct hda_verb alc269_lifebook_verbs[] = {
13462 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13463 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
13464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13465 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13468 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13469 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13470 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13471 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13472 { }
13473};
13474
Kailang Yang60db6b52008-08-26 13:13:00 +020013475/* toggle speaker-output according to the hp-jack state */
13476static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
13477{
13478 unsigned int present;
13479 unsigned char bits;
13480
Wu Fengguang864f92b2009-11-18 12:38:02 +080013481 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang60db6b52008-08-26 13:13:00 +020013482 bits = present ? AMP_IN_MUTE(0) : 0;
13483 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13484 AMP_IN_MUTE(0), bits);
13485 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13486 AMP_IN_MUTE(0), bits);
13487
13488 snd_hda_codec_write(codec, 0x20, 0,
13489 AC_VERB_SET_COEF_INDEX, 0x0c);
13490 snd_hda_codec_write(codec, 0x20, 0,
13491 AC_VERB_SET_PROC_COEF, 0x680);
13492
13493 snd_hda_codec_write(codec, 0x20, 0,
13494 AC_VERB_SET_COEF_INDEX, 0x0c);
13495 snd_hda_codec_write(codec, 0x20, 0,
13496 AC_VERB_SET_PROC_COEF, 0x480);
13497}
13498
Tony Vroon64154832008-11-06 15:08:49 +000013499/* toggle speaker-output according to the hp-jacks state */
13500static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
13501{
13502 unsigned int present;
13503 unsigned char bits;
13504
13505 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013506 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000013507
13508 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080013509 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000013510
13511 bits = present ? AMP_IN_MUTE(0) : 0;
13512 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13513 AMP_IN_MUTE(0), bits);
13514 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13515 AMP_IN_MUTE(0), bits);
13516
13517 snd_hda_codec_write(codec, 0x20, 0,
13518 AC_VERB_SET_COEF_INDEX, 0x0c);
13519 snd_hda_codec_write(codec, 0x20, 0,
13520 AC_VERB_SET_PROC_COEF, 0x680);
13521
13522 snd_hda_codec_write(codec, 0x20, 0,
13523 AC_VERB_SET_COEF_INDEX, 0x0c);
13524 snd_hda_codec_write(codec, 0x20, 0,
13525 AC_VERB_SET_PROC_COEF, 0x480);
13526}
13527
Tony Vroon64154832008-11-06 15:08:49 +000013528static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
13529{
13530 unsigned int present_laptop;
13531 unsigned int present_dock;
13532
Wu Fengguang864f92b2009-11-18 12:38:02 +080013533 present_laptop = snd_hda_jack_detect(codec, 0x18);
13534 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000013535
13536 /* Laptop mic port overrides dock mic port, design decision */
13537 if (present_dock)
13538 snd_hda_codec_write(codec, 0x23, 0,
13539 AC_VERB_SET_CONNECT_SEL, 0x3);
13540 if (present_laptop)
13541 snd_hda_codec_write(codec, 0x23, 0,
13542 AC_VERB_SET_CONNECT_SEL, 0x0);
13543 if (!present_dock && !present_laptop)
13544 snd_hda_codec_write(codec, 0x23, 0,
13545 AC_VERB_SET_CONNECT_SEL, 0x1);
13546}
13547
Kailang Yang60db6b52008-08-26 13:13:00 +020013548static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
13549 unsigned int res)
13550{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013551 switch (res >> 26) {
13552 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013553 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013554 break;
13555 case ALC880_MIC_EVENT:
13556 alc_mic_automute(codec);
13557 break;
13558 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013559}
13560
Tony Vroon64154832008-11-06 15:08:49 +000013561static void alc269_lifebook_unsol_event(struct hda_codec *codec,
13562 unsigned int res)
13563{
13564 if ((res >> 26) == ALC880_HP_EVENT)
13565 alc269_lifebook_speaker_automute(codec);
13566 if ((res >> 26) == ALC880_MIC_EVENT)
13567 alc269_lifebook_mic_autoswitch(codec);
13568}
13569
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013570static void alc269_quanta_fl1_setup(struct hda_codec *codec)
13571{
13572 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013573 spec->autocfg.hp_pins[0] = 0x15;
13574 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013575 spec->ext_mic.pin = 0x18;
13576 spec->ext_mic.mux_idx = 0;
13577 spec->int_mic.pin = 0x19;
13578 spec->int_mic.mux_idx = 1;
13579 spec->auto_mic = 1;
13580}
13581
Kailang Yang60db6b52008-08-26 13:13:00 +020013582static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
13583{
13584 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013585 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013586}
13587
Tony Vroon64154832008-11-06 15:08:49 +000013588static void alc269_lifebook_init_hook(struct hda_codec *codec)
13589{
13590 alc269_lifebook_speaker_automute(codec);
13591 alc269_lifebook_mic_autoswitch(codec);
13592}
13593
Kailang Yang84898e82010-02-04 14:16:14 +010013594static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013595 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13596 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
13597 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13598 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13599 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13600 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13601 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13602 {}
13603};
13604
Kailang Yang84898e82010-02-04 14:16:14 +010013605static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013606 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13607 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
13608 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
13610 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13611 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13612 {}
13613};
13614
Kailang Yang84898e82010-02-04 14:16:14 +010013615static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
13616 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13617 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
13618 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13619 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13620 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13621 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13622 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13623 {}
13624};
13625
13626static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
13627 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
13628 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
13629 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
13630 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
13631 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13632 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13633 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13634 {}
13635};
13636
Kailang Yang60db6b52008-08-26 13:13:00 +020013637/* toggle speaker-output according to the hp-jack state */
13638static void alc269_speaker_automute(struct hda_codec *codec)
13639{
Kailang Yangebb83ee2009-12-17 12:23:00 +010013640 struct alc_spec *spec = codec->spec;
13641 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020013642 unsigned int present;
13643 unsigned char bits;
13644
Kailang Yangebb83ee2009-12-17 12:23:00 +010013645 present = snd_hda_jack_detect(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020013646 bits = present ? AMP_IN_MUTE(0) : 0;
13647 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
13648 AMP_IN_MUTE(0), bits);
13649 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
13650 AMP_IN_MUTE(0), bits);
13651}
13652
Kailang Yang60db6b52008-08-26 13:13:00 +020013653/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010013654static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020013655 unsigned int res)
13656{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013657 switch (res >> 26) {
13658 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020013659 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013660 break;
13661 case ALC880_MIC_EVENT:
13662 alc_mic_automute(codec);
13663 break;
13664 }
Kailang Yang60db6b52008-08-26 13:13:00 +020013665}
13666
Kailang Yang84898e82010-02-04 14:16:14 +010013667static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013668{
13669 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013670 spec->autocfg.hp_pins[0] = 0x15;
13671 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013672 spec->ext_mic.pin = 0x18;
13673 spec->ext_mic.mux_idx = 0;
13674 spec->int_mic.pin = 0x12;
13675 spec->int_mic.mux_idx = 5;
13676 spec->auto_mic = 1;
13677}
13678
Kailang Yang84898e82010-02-04 14:16:14 +010013679static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
13680{
13681 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013682 spec->autocfg.hp_pins[0] = 0x15;
13683 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang84898e82010-02-04 14:16:14 +010013684 spec->ext_mic.pin = 0x18;
13685 spec->ext_mic.mux_idx = 0;
13686 spec->int_mic.pin = 0x12;
13687 spec->int_mic.mux_idx = 6;
13688 spec->auto_mic = 1;
13689}
13690
13691static void alc269_laptop_amic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013692{
13693 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010013694 spec->autocfg.hp_pins[0] = 0x15;
13695 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013696 spec->ext_mic.pin = 0x18;
13697 spec->ext_mic.mux_idx = 0;
13698 spec->int_mic.pin = 0x19;
13699 spec->int_mic.mux_idx = 1;
13700 spec->auto_mic = 1;
13701}
13702
Kailang Yang84898e82010-02-04 14:16:14 +010013703static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020013704{
13705 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013706 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020013707}
13708
Kailang Yangf6a92242007-12-13 16:52:54 +010013709/*
13710 * generic initialization of ADC, input mixers and output mixers
13711 */
13712static struct hda_verb alc269_init_verbs[] = {
13713 /*
13714 * Unmute ADC0 and set the default input to mic-in
13715 */
Kailang Yang84898e82010-02-04 14:16:14 +010013716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010013717
13718 /*
Kailang Yang84898e82010-02-04 14:16:14 +010013719 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010013720 */
13721 /* set vol=0 to output mixers */
13722 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13723 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13724
13725 /* set up input amps for analog loopback */
13726 /* Amp Indices: DAC = 0, mixer = 1 */
13727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13728 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13729 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13730 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13731 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13732 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13733
13734 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13736 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13737 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13738 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13739 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13740 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13741
13742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13743 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010013744
Kailang Yang84898e82010-02-04 14:16:14 +010013745 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010013746 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13747 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010013748 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010013749
13750 /* set EAPD */
13751 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010013752 { }
13753};
13754
13755static struct hda_verb alc269vb_init_verbs[] = {
13756 /*
13757 * Unmute ADC0 and set the default input to mic-in
13758 */
13759 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13760
13761 /*
13762 * Set up output mixers (0x02 - 0x03)
13763 */
13764 /* set vol=0 to output mixers */
13765 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13766 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13767
13768 /* set up input amps for analog loopback */
13769 /* Amp Indices: DAC = 0, mixer = 1 */
13770 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13771 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13772 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13773 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13775 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13776
13777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13778 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13780 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13781 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13782 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13784
13785 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13786 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13787
13788 /* FIXME: use Mux-type input source selection */
13789 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
13790 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
13791 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
13792
13793 /* set EAPD */
13794 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010013795 { }
13796};
13797
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020013798#define alc269_auto_create_multi_out_ctls \
13799 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020013800#define alc269_auto_create_input_ctls \
13801 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010013802
13803#ifdef CONFIG_SND_HDA_POWER_SAVE
13804#define alc269_loopbacks alc880_loopbacks
13805#endif
13806
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013807/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010013808#define alc269_pcm_analog_playback alc880_pcm_analog_playback
13809#define alc269_pcm_analog_capture alc880_pcm_analog_capture
13810#define alc269_pcm_digital_playback alc880_pcm_digital_playback
13811#define alc269_pcm_digital_capture alc880_pcm_digital_capture
13812
Takashi Iwaif03d3112009-03-05 14:18:16 +010013813static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
13814 .substreams = 1,
13815 .channels_min = 2,
13816 .channels_max = 8,
13817 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13818 /* NID is set in alc_build_pcms */
13819 .ops = {
13820 .open = alc880_playback_pcm_open,
13821 .prepare = alc880_playback_pcm_prepare,
13822 .cleanup = alc880_playback_pcm_cleanup
13823 },
13824};
13825
13826static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13827 .substreams = 1,
13828 .channels_min = 2,
13829 .channels_max = 2,
13830 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
13831 /* NID is set in alc_build_pcms */
13832};
13833
Kailang Yangf6a92242007-12-13 16:52:54 +010013834/*
13835 * BIOS auto configuration
13836 */
13837static int alc269_parse_auto_config(struct hda_codec *codec)
13838{
13839 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010013840 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010013841 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
Kailang Yang84898e82010-02-04 14:16:14 +010013842 hda_nid_t real_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010013843
13844 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13845 alc269_ignore);
13846 if (err < 0)
13847 return err;
13848
13849 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
13850 if (err < 0)
13851 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013852 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010013853 if (err < 0)
13854 return err;
13855
13856 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13857
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013858 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010013859 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
13860
Takashi Iwai603c4012008-07-30 15:01:44 +020013861 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013862 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010013863
Kailang Yang84898e82010-02-04 14:16:14 +010013864 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
13865 add_verb(spec, alc269vb_init_verbs);
13866 real_capsrc_nids = alc269vb_capsrc_nids[0];
Kailang Yang6227cdc2010-02-25 08:36:52 +010013867 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010013868 } else {
13869 add_verb(spec, alc269_init_verbs);
13870 real_capsrc_nids = alc269_capsrc_nids[0];
Kailang Yang6227cdc2010-02-25 08:36:52 +010013871 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010013872 }
13873
Kailang Yangf6a92242007-12-13 16:52:54 +010013874 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013875 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020013876 /* set default input source */
Kailang Yang84898e82010-02-04 14:16:14 +010013877 snd_hda_codec_write_cache(codec, real_capsrc_nids,
Takashi Iwaie01bf502008-08-21 16:25:07 +020013878 0, AC_VERB_SET_CONNECT_SEL,
13879 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010013880
13881 err = alc_auto_add_mic_boost(codec);
13882 if (err < 0)
13883 return err;
13884
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013885 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020013886 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020013887
Kailang Yangf6a92242007-12-13 16:52:54 +010013888 return 1;
13889}
13890
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013891#define alc269_auto_init_multi_out alc268_auto_init_multi_out
13892#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010013893#define alc269_auto_init_analog_input alc882_auto_init_analog_input
13894
13895
13896/* init callback for auto-configuration model -- overriding the default init */
13897static void alc269_auto_init(struct hda_codec *codec)
13898{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013899 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010013900 alc269_auto_init_multi_out(codec);
13901 alc269_auto_init_hp_out(codec);
13902 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013903 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013904 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010013905}
13906
13907/*
13908 * configuration and preset
13909 */
13910static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013911 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020013912 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010013913 [ALC269_AMIC] = "laptop-amic",
13914 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000013915 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020013916 [ALC269_LIFEBOOK] = "lifebook",
13917 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010013918};
13919
13920static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020013921 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020013922 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010013923 ALC269_AMIC),
13924 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
13925 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
13926 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
13927 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
13928 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
13929 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
13930 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
13931 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
13932 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
13933 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
13934 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
13935 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
13936 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
13937 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
13938 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
13939 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
13940 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
13941 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
13942 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
13943 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
13944 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
13945 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
13946 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
13947 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
13948 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
13949 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
13950 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
13951 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
13952 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
13953 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
13954 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
13955 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
13956 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
13957 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
13958 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
13959 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020013960 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010013961 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020013962 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010013963 ALC269_DMIC),
13964 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
13965 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010013966 SND_PCI_QUIRK(0x104d, 0x9071, "SONY XTB", ALC269_DMIC),
Tony Vroon64154832008-11-06 15:08:49 +000013967 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010013968 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
13969 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
13970 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
13971 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
13972 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
13973 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010013974 {}
13975};
13976
13977static struct alc_config_preset alc269_presets[] = {
13978 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013979 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010013980 .init_verbs = { alc269_init_verbs },
13981 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13982 .dac_nids = alc269_dac_nids,
13983 .hp_nid = 0x03,
13984 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13985 .channel_mode = alc269_modes,
13986 .input_mux = &alc269_capture_source,
13987 },
Kailang Yang60db6b52008-08-26 13:13:00 +020013988 [ALC269_QUANTA_FL1] = {
13989 .mixers = { alc269_quanta_fl1_mixer },
13990 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
13991 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
13992 .dac_nids = alc269_dac_nids,
13993 .hp_nid = 0x03,
13994 .num_channel_mode = ARRAY_SIZE(alc269_modes),
13995 .channel_mode = alc269_modes,
13996 .input_mux = &alc269_capture_source,
13997 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013998 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020013999 .init_hook = alc269_quanta_fl1_init_hook,
14000 },
Kailang Yang84898e82010-02-04 14:16:14 +010014001 [ALC269_AMIC] = {
14002 .mixers = { alc269_laptop_mixer },
14003 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014004 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014005 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014006 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14007 .dac_nids = alc269_dac_nids,
14008 .hp_nid = 0x03,
14009 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14010 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014011 .unsol_event = alc269_laptop_unsol_event,
14012 .setup = alc269_laptop_amic_setup,
14013 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014014 },
Kailang Yang84898e82010-02-04 14:16:14 +010014015 [ALC269_DMIC] = {
14016 .mixers = { alc269_laptop_mixer },
14017 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014018 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014019 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014020 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14021 .dac_nids = alc269_dac_nids,
14022 .hp_nid = 0x03,
14023 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14024 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014025 .unsol_event = alc269_laptop_unsol_event,
14026 .setup = alc269_laptop_dmic_setup,
14027 .init_hook = alc269_laptop_inithook,
14028 },
14029 [ALC269VB_AMIC] = {
14030 .mixers = { alc269vb_laptop_mixer },
14031 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14032 .init_verbs = { alc269vb_init_verbs,
14033 alc269vb_laptop_amic_init_verbs },
14034 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14035 .dac_nids = alc269_dac_nids,
14036 .hp_nid = 0x03,
14037 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14038 .channel_mode = alc269_modes,
14039 .unsol_event = alc269_laptop_unsol_event,
14040 .setup = alc269_laptop_amic_setup,
14041 .init_hook = alc269_laptop_inithook,
14042 },
14043 [ALC269VB_DMIC] = {
14044 .mixers = { alc269vb_laptop_mixer },
14045 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14046 .init_verbs = { alc269vb_init_verbs,
14047 alc269vb_laptop_dmic_init_verbs },
14048 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14049 .dac_nids = alc269_dac_nids,
14050 .hp_nid = 0x03,
14051 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14052 .channel_mode = alc269_modes,
14053 .unsol_event = alc269_laptop_unsol_event,
14054 .setup = alc269vb_laptop_dmic_setup,
14055 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014056 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014057 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014058 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014059 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014060 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014061 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014062 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14063 .dac_nids = alc269_dac_nids,
14064 .hp_nid = 0x03,
14065 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14066 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014067 .unsol_event = alc269_laptop_unsol_event,
14068 .setup = alc269_laptop_dmic_setup,
14069 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014070 },
Tony Vroon64154832008-11-06 15:08:49 +000014071 [ALC269_LIFEBOOK] = {
14072 .mixers = { alc269_lifebook_mixer },
14073 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14074 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14075 .dac_nids = alc269_dac_nids,
14076 .hp_nid = 0x03,
14077 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14078 .channel_mode = alc269_modes,
14079 .input_mux = &alc269_capture_source,
14080 .unsol_event = alc269_lifebook_unsol_event,
14081 .init_hook = alc269_lifebook_init_hook,
14082 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014083};
14084
14085static int patch_alc269(struct hda_codec *codec)
14086{
14087 struct alc_spec *spec;
14088 int board_config;
14089 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014090 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014091
14092 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14093 if (spec == NULL)
14094 return -ENOMEM;
14095
14096 codec->spec = spec;
14097
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020014098 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14099
Kailang Yang274693f2009-12-03 10:07:50 +010014100 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14101 kfree(codec->chip_name);
14102 codec->chip_name = kstrdup("ALC259", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014103 if (!codec->chip_name) {
14104 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010014105 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010014106 }
Kailang Yang84898e82010-02-04 14:16:14 +010014107 is_alc269vb = 1;
Kailang Yang274693f2009-12-03 10:07:50 +010014108 }
14109
Kailang Yangf6a92242007-12-13 16:52:54 +010014110 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14111 alc269_models,
14112 alc269_cfg_tbl);
14113
14114 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014115 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14116 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014117 board_config = ALC269_AUTO;
14118 }
14119
14120 if (board_config == ALC269_AUTO) {
14121 /* automatic parse from the BIOS config */
14122 err = alc269_parse_auto_config(codec);
14123 if (err < 0) {
14124 alc_free(codec);
14125 return err;
14126 } else if (!err) {
14127 printk(KERN_INFO
14128 "hda_codec: Cannot set up configuration "
14129 "from BIOS. Using base mode...\n");
14130 board_config = ALC269_BASIC;
14131 }
14132 }
14133
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014134 err = snd_hda_attach_beep_device(codec, 0x1);
14135 if (err < 0) {
14136 alc_free(codec);
14137 return err;
14138 }
14139
Kailang Yangf6a92242007-12-13 16:52:54 +010014140 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014141 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014142
Kailang Yang84898e82010-02-04 14:16:14 +010014143 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014144 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14145 * fix the sample rate of analog I/O to 44.1kHz
14146 */
14147 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14148 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
14149 } else {
14150 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14151 spec->stream_analog_capture = &alc269_pcm_analog_capture;
14152 }
Kailang Yangf6a92242007-12-13 16:52:54 +010014153 spec->stream_digital_playback = &alc269_pcm_digital_playback;
14154 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14155
Kailang Yang84898e82010-02-04 14:16:14 +010014156 if (!is_alc269vb) {
14157 spec->adc_nids = alc269_adc_nids;
14158 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14159 spec->capsrc_nids = alc269_capsrc_nids;
14160 } else {
14161 spec->adc_nids = alc269vb_adc_nids;
14162 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14163 spec->capsrc_nids = alc269vb_capsrc_nids;
14164 }
14165
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014166 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014167 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014168 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010014169
Takashi Iwai100d5eb2009-08-10 11:55:51 +020014170 spec->vmaster_nid = 0x02;
14171
Kailang Yangf6a92242007-12-13 16:52:54 +010014172 codec->patch_ops = alc_patch_ops;
14173 if (board_config == ALC269_AUTO)
14174 spec->init_hook = alc269_auto_init;
14175#ifdef CONFIG_SND_HDA_POWER_SAVE
14176 if (!spec->loopback.amplist)
14177 spec->loopback.amplist = alc269_loopbacks;
14178#endif
14179
14180 return 0;
14181}
14182
14183/*
Kailang Yangdf694da2005-12-05 19:42:22 +010014184 * ALC861 channel source setting (2/6 channel selection for 3-stack)
14185 */
14186
14187/*
14188 * set the path ways for 2 channel output
14189 * need to set the codec line out and mic 1 pin widgets to inputs
14190 */
14191static struct hda_verb alc861_threestack_ch2_init[] = {
14192 /* set pin widget 1Ah (line in) for input */
14193 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014194 /* set pin widget 18h (mic1/2) for input, for mic also enable
14195 * the vref
14196 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014197 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14198
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014199 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14200#if 0
14201 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14202 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14203#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014204 { } /* end */
14205};
14206/*
14207 * 6ch mode
14208 * need to set the codec line out and mic 1 pin widgets to outputs
14209 */
14210static struct hda_verb alc861_threestack_ch6_init[] = {
14211 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14212 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14213 /* set pin widget 18h (mic1) for output (CLFE)*/
14214 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14215
14216 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014217 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014218
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014219 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14220#if 0
14221 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14222 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14223#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010014224 { } /* end */
14225};
14226
14227static struct hda_channel_mode alc861_threestack_modes[2] = {
14228 { 2, alc861_threestack_ch2_init },
14229 { 6, alc861_threestack_ch6_init },
14230};
Takashi Iwai22309c32006-08-09 16:57:28 +020014231/* Set mic1 as input and unmute the mixer */
14232static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
14233 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14234 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14235 { } /* end */
14236};
14237/* Set mic1 as output and mute mixer */
14238static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
14239 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14240 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14241 { } /* end */
14242};
14243
14244static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
14245 { 2, alc861_uniwill_m31_ch2_init },
14246 { 4, alc861_uniwill_m31_ch4_init },
14247};
Kailang Yangdf694da2005-12-05 19:42:22 +010014248
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014249/* Set mic1 and line-in as input and unmute the mixer */
14250static struct hda_verb alc861_asus_ch2_init[] = {
14251 /* set pin widget 1Ah (line in) for input */
14252 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014253 /* set pin widget 18h (mic1/2) for input, for mic also enable
14254 * the vref
14255 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014256 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14257
14258 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
14259#if 0
14260 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
14261 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
14262#endif
14263 { } /* end */
14264};
14265/* Set mic1 nad line-in as output and mute mixer */
14266static struct hda_verb alc861_asus_ch6_init[] = {
14267 /* set pin widget 1Ah (line in) for output (Back Surround)*/
14268 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14269 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14270 /* set pin widget 18h (mic1) for output (CLFE)*/
14271 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14272 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
14273 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
14274 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
14275
14276 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
14277#if 0
14278 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
14279 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
14280#endif
14281 { } /* end */
14282};
14283
14284static struct hda_channel_mode alc861_asus_modes[2] = {
14285 { 2, alc861_asus_ch2_init },
14286 { 6, alc861_asus_ch6_init },
14287};
14288
Kailang Yangdf694da2005-12-05 19:42:22 +010014289/* patch-ALC861 */
14290
14291static struct snd_kcontrol_new alc861_base_mixer[] = {
14292 /* output mixer control */
14293 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14294 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14295 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14296 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14297 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14298
14299 /*Input mixer control */
14300 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14301 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14302 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14303 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14304 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14305 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14306 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14307 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14308 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14309 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014310
Kailang Yangdf694da2005-12-05 19:42:22 +010014311 { } /* end */
14312};
14313
14314static struct snd_kcontrol_new alc861_3ST_mixer[] = {
14315 /* output mixer control */
14316 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14317 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14318 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14319 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14320 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14321
14322 /* Input mixer control */
14323 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14324 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14325 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14326 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14327 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14328 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14330 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14331 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14332 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014333
Kailang Yangdf694da2005-12-05 19:42:22 +010014334 {
14335 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14336 .name = "Channel Mode",
14337 .info = alc_ch_mode_info,
14338 .get = alc_ch_mode_get,
14339 .put = alc_ch_mode_put,
14340 .private_value = ARRAY_SIZE(alc861_threestack_modes),
14341 },
14342 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014343};
14344
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014345static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014346 /* output mixer control */
14347 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14348 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14349 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014350
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014351 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014352};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014353
Takashi Iwai22309c32006-08-09 16:57:28 +020014354static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
14355 /* output mixer control */
14356 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14357 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14358 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14359 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14360 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
14361
14362 /* Input mixer control */
14363 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14364 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
14365 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14366 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14367 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14368 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14370 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
14372 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014373
Takashi Iwai22309c32006-08-09 16:57:28 +020014374 {
14375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14376 .name = "Channel Mode",
14377 .info = alc_ch_mode_info,
14378 .get = alc_ch_mode_get,
14379 .put = alc_ch_mode_put,
14380 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
14381 },
14382 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014383};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014384
14385static struct snd_kcontrol_new alc861_asus_mixer[] = {
14386 /* output mixer control */
14387 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
14388 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
14389 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
14390 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
14391 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
14392
14393 /* Input mixer control */
14394 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
14395 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14396 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14397 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
14398 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
14399 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
14400 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
14401 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
14402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014403 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
14404
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014405 {
14406 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14407 .name = "Channel Mode",
14408 .info = alc_ch_mode_info,
14409 .get = alc_ch_mode_get,
14410 .put = alc_ch_mode_put,
14411 .private_value = ARRAY_SIZE(alc861_asus_modes),
14412 },
14413 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014414};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014415
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014416/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010014417static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014418 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
14419 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014420 { }
14421};
14422
Kailang Yangdf694da2005-12-05 19:42:22 +010014423/*
14424 * generic initialization of ADC, input mixers and output mixers
14425 */
14426static struct hda_verb alc861_base_init_verbs[] = {
14427 /*
14428 * Unmute ADC0 and set the default input to mic-in
14429 */
14430 /* port-A for surround (rear panel) */
14431 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14432 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
14433 /* port-B for mic-in (rear panel) with vref */
14434 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14435 /* port-C for line-in (rear panel) */
14436 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14437 /* port-D for Front */
14438 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14439 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14440 /* port-E for HP out (front panel) */
14441 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14442 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014443 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014444 /* port-F for mic-in (front panel) with vref */
14445 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14446 /* port-G for CLFE (rear panel) */
14447 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14448 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
14449 /* port-H for side (rear panel) */
14450 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14451 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
14452 /* CD-in */
14453 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14454 /* route front mic to ADC1*/
14455 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14456 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014457
Kailang Yangdf694da2005-12-05 19:42:22 +010014458 /* Unmute DAC0~3 & spdif out*/
14459 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14460 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14461 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14462 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014464
Kailang Yangdf694da2005-12-05 19:42:22 +010014465 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14466 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14467 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14468 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14469 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014470
Kailang Yangdf694da2005-12-05 19:42:22 +010014471 /* Unmute Stereo Mixer 15 */
14472 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14473 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14474 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014475 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014476
14477 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14478 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14479 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14480 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14481 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14482 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14484 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014485 /* hp used DAC 3 (Front) */
14486 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014487 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14488
14489 { }
14490};
14491
14492static struct hda_verb alc861_threestack_init_verbs[] = {
14493 /*
14494 * Unmute ADC0 and set the default input to mic-in
14495 */
14496 /* port-A for surround (rear panel) */
14497 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14498 /* port-B for mic-in (rear panel) with vref */
14499 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14500 /* port-C for line-in (rear panel) */
14501 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14502 /* port-D for Front */
14503 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14504 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14505 /* port-E for HP out (front panel) */
14506 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
14507 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014508 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010014509 /* port-F for mic-in (front panel) with vref */
14510 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14511 /* port-G for CLFE (rear panel) */
14512 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14513 /* port-H for side (rear panel) */
14514 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14515 /* CD-in */
14516 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14517 /* route front mic to ADC1*/
14518 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14519 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14520 /* Unmute DAC0~3 & spdif out*/
14521 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14522 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14523 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14524 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14525 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014526
Kailang Yangdf694da2005-12-05 19:42:22 +010014527 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14528 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14529 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14530 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14531 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014532
Kailang Yangdf694da2005-12-05 19:42:22 +010014533 /* Unmute Stereo Mixer 15 */
14534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14536 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014537 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010014538
14539 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14540 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14541 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14542 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14544 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14545 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014547 /* hp used DAC 3 (Front) */
14548 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14550 { }
14551};
Takashi Iwai22309c32006-08-09 16:57:28 +020014552
14553static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
14554 /*
14555 * Unmute ADC0 and set the default input to mic-in
14556 */
14557 /* port-A for surround (rear panel) */
14558 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14559 /* port-B for mic-in (rear panel) with vref */
14560 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14561 /* port-C for line-in (rear panel) */
14562 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14563 /* port-D for Front */
14564 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14565 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14566 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014567 /* this has to be set to VREF80 */
14568 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014569 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014570 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020014571 /* port-F for mic-in (front panel) with vref */
14572 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14573 /* port-G for CLFE (rear panel) */
14574 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14575 /* port-H for side (rear panel) */
14576 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14577 /* CD-in */
14578 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14579 /* route front mic to ADC1*/
14580 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14581 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14582 /* Unmute DAC0~3 & spdif out*/
14583 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14584 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14585 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14586 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014588
Takashi Iwai22309c32006-08-09 16:57:28 +020014589 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14590 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14591 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14592 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14593 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014594
Takashi Iwai22309c32006-08-09 16:57:28 +020014595 /* Unmute Stereo Mixer 15 */
14596 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14598 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020014600
14601 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14602 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14603 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14604 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14605 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14607 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014609 /* hp used DAC 3 (Front) */
14610 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020014611 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14612 { }
14613};
14614
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014615static struct hda_verb alc861_asus_init_verbs[] = {
14616 /*
14617 * Unmute ADC0 and set the default input to mic-in
14618 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014619 /* port-A for surround (rear panel)
14620 * according to codec#0 this is the HP jack
14621 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014622 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
14623 /* route front PCM to HP */
14624 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
14625 /* port-B for mic-in (rear panel) with vref */
14626 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14627 /* port-C for line-in (rear panel) */
14628 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14629 /* port-D for Front */
14630 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14631 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
14632 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014633 /* this has to be set to VREF80 */
14634 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014635 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010014636 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014637 /* port-F for mic-in (front panel) with vref */
14638 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
14639 /* port-G for CLFE (rear panel) */
14640 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14641 /* port-H for side (rear panel) */
14642 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
14643 /* CD-in */
14644 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
14645 /* route front mic to ADC1*/
14646 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
14647 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14648 /* Unmute DAC0~3 & spdif out*/
14649 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14650 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14651 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14652 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14653 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14654 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14655 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14656 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14657 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14658 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014659
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014660 /* Unmute Stereo Mixer 15 */
14661 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14662 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014664 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014665
14666 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14668 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14669 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14670 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14671 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14672 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14673 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014674 /* hp used DAC 3 (Front) */
14675 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014676 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14677 { }
14678};
14679
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010014680/* additional init verbs for ASUS laptops */
14681static struct hda_verb alc861_asus_laptop_init_verbs[] = {
14682 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
14683 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
14684 { }
14685};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020014686
Kailang Yangdf694da2005-12-05 19:42:22 +010014687/*
14688 * generic initialization of ADC, input mixers and output mixers
14689 */
14690static struct hda_verb alc861_auto_init_verbs[] = {
14691 /*
14692 * Unmute ADC0 and set the default input to mic-in
14693 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014694 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010014695 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014696
Kailang Yangdf694da2005-12-05 19:42:22 +010014697 /* Unmute DAC0~3 & spdif out*/
14698 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14699 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14700 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14701 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14702 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020014703
Kailang Yangdf694da2005-12-05 19:42:22 +010014704 /* Unmute Mixer 14 (mic) 1c (Line in)*/
14705 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14706 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14707 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14708 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014709
Kailang Yangdf694da2005-12-05 19:42:22 +010014710 /* Unmute Stereo Mixer 15 */
14711 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14712 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14713 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
14715
Takashi Iwai1c209302009-07-22 15:17:45 +020014716 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14717 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14718 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14719 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14720 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14721 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14722 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14723 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014724
14725 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14726 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14728 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014729 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020014731 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14732 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010014733
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014734 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014735
14736 { }
14737};
14738
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014739static struct hda_verb alc861_toshiba_init_verbs[] = {
14740 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014741
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014742 { }
14743};
14744
14745/* toggle speaker-output according to the hp-jack state */
14746static void alc861_toshiba_automute(struct hda_codec *codec)
14747{
Wu Fengguang864f92b2009-11-18 12:38:02 +080014748 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014749
Takashi Iwai47fd8302007-08-10 17:11:07 +020014750 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
14751 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
14752 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
14753 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014754}
14755
14756static void alc861_toshiba_unsol_event(struct hda_codec *codec,
14757 unsigned int res)
14758{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020014759 if ((res >> 26) == ALC880_HP_EVENT)
14760 alc861_toshiba_automute(codec);
14761}
14762
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014763/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014764#define alc861_pcm_analog_playback alc880_pcm_analog_playback
14765#define alc861_pcm_analog_capture alc880_pcm_analog_capture
14766#define alc861_pcm_digital_playback alc880_pcm_digital_playback
14767#define alc861_pcm_digital_capture alc880_pcm_digital_capture
14768
14769
14770#define ALC861_DIGOUT_NID 0x07
14771
14772static struct hda_channel_mode alc861_8ch_modes[1] = {
14773 { 8, NULL }
14774};
14775
14776static hda_nid_t alc861_dac_nids[4] = {
14777 /* front, surround, clfe, side */
14778 0x03, 0x06, 0x05, 0x04
14779};
14780
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014781static hda_nid_t alc660_dac_nids[3] = {
14782 /* front, clfe, surround */
14783 0x03, 0x05, 0x06
14784};
14785
Kailang Yangdf694da2005-12-05 19:42:22 +010014786static hda_nid_t alc861_adc_nids[1] = {
14787 /* ADC0-2 */
14788 0x08,
14789};
14790
14791static struct hda_input_mux alc861_capture_source = {
14792 .num_items = 5,
14793 .items = {
14794 { "Mic", 0x0 },
14795 { "Front Mic", 0x3 },
14796 { "Line", 0x1 },
14797 { "CD", 0x4 },
14798 { "Mixer", 0x5 },
14799 },
14800};
14801
Takashi Iwai1c209302009-07-22 15:17:45 +020014802static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
14803{
14804 struct alc_spec *spec = codec->spec;
14805 hda_nid_t mix, srcs[5];
14806 int i, j, num;
14807
14808 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
14809 return 0;
14810 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14811 if (num < 0)
14812 return 0;
14813 for (i = 0; i < num; i++) {
14814 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020014815 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020014816 if (type != AC_WID_AUD_OUT)
14817 continue;
14818 for (j = 0; j < spec->multiout.num_dacs; j++)
14819 if (spec->multiout.dac_nids[j] == srcs[i])
14820 break;
14821 if (j >= spec->multiout.num_dacs)
14822 return srcs[i];
14823 }
14824 return 0;
14825}
14826
Kailang Yangdf694da2005-12-05 19:42:22 +010014827/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020014828static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014829 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014830{
Takashi Iwai1c209302009-07-22 15:17:45 +020014831 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014832 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020014833 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014834
14835 spec->multiout.dac_nids = spec->private_dac_nids;
14836 for (i = 0; i < cfg->line_outs; i++) {
14837 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020014838 dac = alc861_look_for_dac(codec, nid);
14839 if (!dac)
14840 continue;
14841 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010014842 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014843 return 0;
14844}
14845
Takashi Iwai1c209302009-07-22 15:17:45 +020014846static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
14847 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010014848{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020014849 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020014850 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
14851}
14852
14853/* add playback controls from the parsed DAC table */
14854static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
14855 const struct auto_pin_cfg *cfg)
14856{
14857 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014858 static const char *chname[4] = {
14859 "Front", "Surround", NULL /*CLFE*/, "Side"
14860 };
Kailang Yangdf694da2005-12-05 19:42:22 +010014861 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020014862 int i, err;
14863
14864 if (cfg->line_outs == 1) {
14865 const char *pfx = NULL;
14866 if (!cfg->hp_outs)
14867 pfx = "Master";
14868 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
14869 pfx = "Speaker";
14870 if (pfx) {
14871 nid = spec->multiout.dac_nids[0];
14872 return alc861_create_out_sw(codec, pfx, nid, 3);
14873 }
14874 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014875
14876 for (i = 0; i < cfg->line_outs; i++) {
14877 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014878 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010014879 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020014880 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010014881 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020014882 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014883 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014884 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020014885 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014886 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014887 return err;
14888 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020014889 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010014891 return err;
14892 }
14893 }
14894 return 0;
14895}
14896
Takashi Iwai1c209302009-07-22 15:17:45 +020014897static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014898{
Takashi Iwai1c209302009-07-22 15:17:45 +020014899 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014900 int err;
14901 hda_nid_t nid;
14902
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014903 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010014904 return 0;
14905
14906 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020014907 nid = alc861_look_for_dac(codec, pin);
14908 if (nid) {
14909 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
14910 if (err < 0)
14911 return err;
14912 spec->multiout.hp_nid = nid;
14913 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014914 }
14915 return 0;
14916}
14917
14918/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020014919static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014920 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010014921{
Takashi Iwai05f5f472009-08-25 13:10:18 +020014922 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010014923}
14924
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014925static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
14926 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020014927 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010014928{
Takashi Iwai1c209302009-07-22 15:17:45 +020014929 hda_nid_t mix, srcs[5];
14930 int i, num;
14931
Jacek Luczak564c5be2008-05-03 18:41:23 +020014932 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
14933 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020014934 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020014935 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020014936 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
14937 return;
14938 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
14939 if (num < 0)
14940 return;
14941 for (i = 0; i < num; i++) {
14942 unsigned int mute;
14943 if (srcs[i] == dac || srcs[i] == 0x15)
14944 mute = AMP_IN_UNMUTE(i);
14945 else
14946 mute = AMP_IN_MUTE(i);
14947 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14948 mute);
14949 }
Kailang Yangdf694da2005-12-05 19:42:22 +010014950}
14951
14952static void alc861_auto_init_multi_out(struct hda_codec *codec)
14953{
14954 struct alc_spec *spec = codec->spec;
14955 int i;
14956
14957 for (i = 0; i < spec->autocfg.line_outs; i++) {
14958 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014959 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010014960 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014961 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014962 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014963 }
14964}
14965
14966static void alc861_auto_init_hp_out(struct hda_codec *codec)
14967{
14968 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014969
Takashi Iwai15870f02009-10-05 08:25:13 +020014970 if (spec->autocfg.hp_outs)
14971 alc861_auto_set_output_and_unmute(codec,
14972 spec->autocfg.hp_pins[0],
14973 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020014974 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020014975 if (spec->autocfg.speaker_outs)
14976 alc861_auto_set_output_and_unmute(codec,
14977 spec->autocfg.speaker_pins[0],
14978 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020014979 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010014980}
14981
14982static void alc861_auto_init_analog_input(struct hda_codec *codec)
14983{
14984 struct alc_spec *spec = codec->spec;
14985 int i;
14986
14987 for (i = 0; i < AUTO_PIN_LAST; i++) {
14988 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai23f0c042009-02-26 13:03:58 +010014989 if (nid >= 0x0c && nid <= 0x11)
14990 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010014991 }
14992}
14993
14994/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014995/* return 1 if successful, 0 if the proper config is not found,
14996 * or a negative error code
14997 */
Kailang Yangdf694da2005-12-05 19:42:22 +010014998static int alc861_parse_auto_config(struct hda_codec *codec)
14999{
15000 struct alc_spec *spec = codec->spec;
15001 int err;
15002 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15003
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015004 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15005 alc861_ignore);
15006 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015007 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015008 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015009 return 0; /* can't find valid BIOS pin config */
15010
Takashi Iwai1c209302009-07-22 15:17:45 +020015011 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015012 if (err < 0)
15013 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015014 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015015 if (err < 0)
15016 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015017 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015018 if (err < 0)
15019 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015020 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015021 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015022 return err;
15023
15024 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15025
Takashi Iwai0852d7a2009-02-11 11:35:15 +010015026 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015027 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
15028
Takashi Iwai603c4012008-07-30 15:01:44 +020015029 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015030 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015031
Takashi Iwaid88897e2008-10-31 15:01:37 +010015032 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015033
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015034 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015035 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015036
15037 spec->adc_nids = alc861_adc_nids;
15038 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015039 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015040
Kailang Yang6227cdc2010-02-25 08:36:52 +010015041 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015042
Kailang Yangdf694da2005-12-05 19:42:22 +010015043 return 1;
15044}
15045
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015046/* additional initialization for auto-configuration model */
15047static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015048{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015049 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015050 alc861_auto_init_multi_out(codec);
15051 alc861_auto_init_hp_out(codec);
15052 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015053 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015054 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015055}
15056
Takashi Iwaicb53c622007-08-10 17:21:45 +020015057#ifdef CONFIG_SND_HDA_POWER_SAVE
15058static struct hda_amp_list alc861_loopbacks[] = {
15059 { 0x15, HDA_INPUT, 0 },
15060 { 0x15, HDA_INPUT, 1 },
15061 { 0x15, HDA_INPUT, 2 },
15062 { 0x15, HDA_INPUT, 3 },
15063 { } /* end */
15064};
15065#endif
15066
Kailang Yangdf694da2005-12-05 19:42:22 +010015067
15068/*
15069 * configuration and preset
15070 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015071static const char *alc861_models[ALC861_MODEL_LAST] = {
15072 [ALC861_3ST] = "3stack",
15073 [ALC660_3ST] = "3stack-660",
15074 [ALC861_3ST_DIG] = "3stack-dig",
15075 [ALC861_6ST_DIG] = "6stack-dig",
15076 [ALC861_UNIWILL_M31] = "uniwill-m31",
15077 [ALC861_TOSHIBA] = "toshiba",
15078 [ALC861_ASUS] = "asus",
15079 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15080 [ALC861_AUTO] = "auto",
15081};
15082
15083static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015084 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015085 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15086 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15087 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015088 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015089 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015090 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015091 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15092 * Any other models that need this preset?
15093 */
15094 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015095 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15096 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015097 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15098 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15099 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15100 /* FIXME: the below seems conflict */
15101 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15102 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15103 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015104 {}
15105};
15106
15107static struct alc_config_preset alc861_presets[] = {
15108 [ALC861_3ST] = {
15109 .mixers = { alc861_3ST_mixer },
15110 .init_verbs = { alc861_threestack_init_verbs },
15111 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15112 .dac_nids = alc861_dac_nids,
15113 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15114 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015115 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015116 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15117 .adc_nids = alc861_adc_nids,
15118 .input_mux = &alc861_capture_source,
15119 },
15120 [ALC861_3ST_DIG] = {
15121 .mixers = { alc861_base_mixer },
15122 .init_verbs = { alc861_threestack_init_verbs },
15123 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15124 .dac_nids = alc861_dac_nids,
15125 .dig_out_nid = ALC861_DIGOUT_NID,
15126 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15127 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015128 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015129 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15130 .adc_nids = alc861_adc_nids,
15131 .input_mux = &alc861_capture_source,
15132 },
15133 [ALC861_6ST_DIG] = {
15134 .mixers = { alc861_base_mixer },
15135 .init_verbs = { alc861_base_init_verbs },
15136 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15137 .dac_nids = alc861_dac_nids,
15138 .dig_out_nid = ALC861_DIGOUT_NID,
15139 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
15140 .channel_mode = alc861_8ch_modes,
15141 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15142 .adc_nids = alc861_adc_nids,
15143 .input_mux = &alc861_capture_source,
15144 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015145 [ALC660_3ST] = {
15146 .mixers = { alc861_3ST_mixer },
15147 .init_verbs = { alc861_threestack_init_verbs },
15148 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
15149 .dac_nids = alc660_dac_nids,
15150 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15151 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015152 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015153 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15154 .adc_nids = alc861_adc_nids,
15155 .input_mux = &alc861_capture_source,
15156 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015157 [ALC861_UNIWILL_M31] = {
15158 .mixers = { alc861_uniwill_m31_mixer },
15159 .init_verbs = { alc861_uniwill_m31_init_verbs },
15160 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15161 .dac_nids = alc861_dac_nids,
15162 .dig_out_nid = ALC861_DIGOUT_NID,
15163 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
15164 .channel_mode = alc861_uniwill_m31_modes,
15165 .need_dac_fix = 1,
15166 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15167 .adc_nids = alc861_adc_nids,
15168 .input_mux = &alc861_capture_source,
15169 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015170 [ALC861_TOSHIBA] = {
15171 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015172 .init_verbs = { alc861_base_init_verbs,
15173 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015174 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15175 .dac_nids = alc861_dac_nids,
15176 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15177 .channel_mode = alc883_3ST_2ch_modes,
15178 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15179 .adc_nids = alc861_adc_nids,
15180 .input_mux = &alc861_capture_source,
15181 .unsol_event = alc861_toshiba_unsol_event,
15182 .init_hook = alc861_toshiba_automute,
15183 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015184 [ALC861_ASUS] = {
15185 .mixers = { alc861_asus_mixer },
15186 .init_verbs = { alc861_asus_init_verbs },
15187 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15188 .dac_nids = alc861_dac_nids,
15189 .dig_out_nid = ALC861_DIGOUT_NID,
15190 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
15191 .channel_mode = alc861_asus_modes,
15192 .need_dac_fix = 1,
15193 .hp_nid = 0x06,
15194 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15195 .adc_nids = alc861_adc_nids,
15196 .input_mux = &alc861_capture_source,
15197 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015198 [ALC861_ASUS_LAPTOP] = {
15199 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
15200 .init_verbs = { alc861_asus_init_verbs,
15201 alc861_asus_laptop_init_verbs },
15202 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15203 .dac_nids = alc861_dac_nids,
15204 .dig_out_nid = ALC861_DIGOUT_NID,
15205 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
15206 .channel_mode = alc883_3ST_2ch_modes,
15207 .need_dac_fix = 1,
15208 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15209 .adc_nids = alc861_adc_nids,
15210 .input_mux = &alc861_capture_source,
15211 },
15212};
Kailang Yangdf694da2005-12-05 19:42:22 +010015213
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015214/* Pin config fixes */
15215enum {
15216 PINFIX_FSC_AMILO_PI1505,
15217};
15218
15219static struct alc_pincfg alc861_fsc_amilo_pi1505_pinfix[] = {
15220 { 0x0b, 0x0221101f }, /* HP */
15221 { 0x0f, 0x90170310 }, /* speaker */
15222 { }
15223};
15224
15225static const struct alc_fixup alc861_fixups[] = {
15226 [PINFIX_FSC_AMILO_PI1505] = {
15227 .pins = alc861_fsc_amilo_pi1505_pinfix
15228 },
15229};
15230
15231static struct snd_pci_quirk alc861_fixup_tbl[] = {
15232 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
15233 {}
15234};
Kailang Yangdf694da2005-12-05 19:42:22 +010015235
15236static int patch_alc861(struct hda_codec *codec)
15237{
15238 struct alc_spec *spec;
15239 int board_config;
15240 int err;
15241
Robert P. J. Daydc041e02006-12-19 14:44:15 +010015242 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010015243 if (spec == NULL)
15244 return -ENOMEM;
15245
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015246 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015247
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015248 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
15249 alc861_models,
15250 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015251
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015252 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015253 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15254 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010015255 board_config = ALC861_AUTO;
15256 }
15257
Takashi Iwaicfc9b062009-12-01 12:19:37 +010015258 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups);
15259
Kailang Yangdf694da2005-12-05 19:42:22 +010015260 if (board_config == ALC861_AUTO) {
15261 /* automatic parse from the BIOS config */
15262 err = alc861_parse_auto_config(codec);
15263 if (err < 0) {
15264 alc_free(codec);
15265 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015266 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015267 printk(KERN_INFO
15268 "hda_codec: Cannot set up configuration "
15269 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010015270 board_config = ALC861_3ST_DIG;
15271 }
15272 }
15273
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015274 err = snd_hda_attach_beep_device(codec, 0x23);
15275 if (err < 0) {
15276 alc_free(codec);
15277 return err;
15278 }
15279
Kailang Yangdf694da2005-12-05 19:42:22 +010015280 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015281 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015282
Kailang Yangdf694da2005-12-05 19:42:22 +010015283 spec->stream_analog_playback = &alc861_pcm_analog_playback;
15284 spec->stream_analog_capture = &alc861_pcm_analog_capture;
15285
Kailang Yangdf694da2005-12-05 19:42:22 +010015286 spec->stream_digital_playback = &alc861_pcm_digital_playback;
15287 spec->stream_digital_capture = &alc861_pcm_digital_capture;
15288
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010015289 if (!spec->cap_mixer)
15290 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015291 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
15292
Takashi Iwai2134ea42008-01-10 16:53:55 +010015293 spec->vmaster_nid = 0x03;
15294
Kailang Yangdf694da2005-12-05 19:42:22 +010015295 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050015296 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015297 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015298#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050015299 spec->power_hook = alc_power_eapd;
15300#endif
15301 }
15302#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020015303 if (!spec->loopback.amplist)
15304 spec->loopback.amplist = alc861_loopbacks;
15305#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020015306
Kailang Yangdf694da2005-12-05 19:42:22 +010015307 return 0;
15308}
15309
15310/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015311 * ALC861-VD support
15312 *
15313 * Based on ALC882
15314 *
15315 * In addition, an independent DAC
15316 */
15317#define ALC861VD_DIGOUT_NID 0x06
15318
15319static hda_nid_t alc861vd_dac_nids[4] = {
15320 /* front, surr, clfe, side surr */
15321 0x02, 0x03, 0x04, 0x05
15322};
15323
15324/* dac_nids for ALC660vd are in a different order - according to
15325 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015326 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015327 * of ALC660vd codecs, but for now there is only 3stack mixer
15328 * - and it is the same as in 861vd.
15329 * adc_nids in ALC660vd are (is) the same as in 861vd
15330 */
15331static hda_nid_t alc660vd_dac_nids[3] = {
15332 /* front, rear, clfe, rear_surr */
15333 0x02, 0x04, 0x03
15334};
15335
15336static hda_nid_t alc861vd_adc_nids[1] = {
15337 /* ADC0 */
15338 0x09,
15339};
15340
Takashi Iwaie1406342008-02-11 18:32:32 +010015341static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
15342
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015343/* input MUX */
15344/* FIXME: should be a matrix-type input source selection */
15345static struct hda_input_mux alc861vd_capture_source = {
15346 .num_items = 4,
15347 .items = {
15348 { "Mic", 0x0 },
15349 { "Front Mic", 0x1 },
15350 { "Line", 0x2 },
15351 { "CD", 0x4 },
15352 },
15353};
15354
Kailang Yang272a5272007-05-14 11:00:38 +020015355static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010015356 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020015357 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010015358 { "Ext Mic", 0x0 },
15359 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020015360 },
15361};
15362
Kailang Yangd1a991a2007-08-15 16:21:59 +020015363static struct hda_input_mux alc861vd_hp_capture_source = {
15364 .num_items = 2,
15365 .items = {
15366 { "Front Mic", 0x0 },
15367 { "ATAPI Mic", 0x1 },
15368 },
15369};
15370
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015371/*
15372 * 2ch mode
15373 */
15374static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
15375 { 2, NULL }
15376};
15377
15378/*
15379 * 6ch mode
15380 */
15381static struct hda_verb alc861vd_6stack_ch6_init[] = {
15382 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15383 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15384 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15385 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15386 { } /* end */
15387};
15388
15389/*
15390 * 8ch mode
15391 */
15392static struct hda_verb alc861vd_6stack_ch8_init[] = {
15393 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15394 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15395 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15396 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15397 { } /* end */
15398};
15399
15400static struct hda_channel_mode alc861vd_6stack_modes[2] = {
15401 { 6, alc861vd_6stack_ch6_init },
15402 { 8, alc861vd_6stack_ch8_init },
15403};
15404
15405static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
15406 {
15407 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15408 .name = "Channel Mode",
15409 .info = alc_ch_mode_info,
15410 .get = alc_ch_mode_get,
15411 .put = alc_ch_mode_put,
15412 },
15413 { } /* end */
15414};
15415
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015416/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15417 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15418 */
15419static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
15420 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15421 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15422
15423 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15424 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
15425
15426 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
15427 HDA_OUTPUT),
15428 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
15429 HDA_OUTPUT),
15430 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
15431 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
15432
15433 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
15434 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
15435
15436 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15437
15438 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15439 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15440 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15441
15442 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15443 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15444 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15445
15446 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15447 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15448
15449 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15450 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15451
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015452 { } /* end */
15453};
15454
15455static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
15456 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15457 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15458
15459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15460
15461 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15462 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15463 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15464
15465 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15466 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15467 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15468
15469 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15470 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15471
15472 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15473 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15474
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015475 { } /* end */
15476};
15477
Kailang Yangbdd148a2007-05-08 15:19:08 +020015478static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
15479 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15480 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
15481 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15482
15483 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15484
15485 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
15486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15488
15489 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
15490 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15491 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15492
15493 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15494 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15495
15496 { } /* end */
15497};
15498
Tobin Davisb419f342008-03-07 11:57:51 +010015499/* Pin assignment: Speaker=0x14, HP = 0x15,
15500 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020015501 */
15502static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010015503 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15504 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015505 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15506 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010015507 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
15508 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15509 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15510 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
15511 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15512 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020015513 { } /* end */
15514};
15515
Kailang Yangd1a991a2007-08-15 16:21:59 +020015516/* Pin assignment: Speaker=0x14, Line-out = 0x15,
15517 * Front Mic=0x18, ATAPI Mic = 0x19,
15518 */
15519static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
15520 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15521 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
15522 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15523 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
15524 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15525 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15526 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15527 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015528
Kailang Yangd1a991a2007-08-15 16:21:59 +020015529 { } /* end */
15530};
15531
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015532/*
15533 * generic initialization of ADC, input mixers and output mixers
15534 */
15535static struct hda_verb alc861vd_volume_init_verbs[] = {
15536 /*
15537 * Unmute ADC0 and set the default input to mic-in
15538 */
15539 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15541
15542 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
15543 * the analog-loopback mixer widget
15544 */
15545 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15548 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015551
15552 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020015553 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15555 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015556 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015557
15558 /*
15559 * Set up output mixers (0x02 - 0x05)
15560 */
15561 /* set vol=0 to output mixers */
15562 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15563 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15564 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15565 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15566
15567 /* set up input amps for analog loopback */
15568 /* Amp Indices: DAC = 0, mixer = 1 */
15569 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15570 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15571 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15572 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15573 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15574 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15575 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15576 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15577
15578 { }
15579};
15580
15581/*
15582 * 3-stack pin configuration:
15583 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
15584 */
15585static struct hda_verb alc861vd_3stack_init_verbs[] = {
15586 /*
15587 * Set pin mode and muting
15588 */
15589 /* set front pin widgets 0x14 for output */
15590 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15591 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15592 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15593
15594 /* Mic (rear) pin: input vref at 80% */
15595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15596 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15597 /* Front Mic pin: input vref at 80% */
15598 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15599 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15600 /* Line In pin: input */
15601 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15602 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15603 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15604 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15605 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15606 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15607 /* CD pin widget for input */
15608 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15609
15610 { }
15611};
15612
15613/*
15614 * 6-stack pin configuration:
15615 */
15616static struct hda_verb alc861vd_6stack_init_verbs[] = {
15617 /*
15618 * Set pin mode and muting
15619 */
15620 /* set front pin widgets 0x14 for output */
15621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15623 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
15624
15625 /* Rear Pin: output 1 (0x0d) */
15626 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15627 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
15629 /* CLFE Pin: output 2 (0x0e) */
15630 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15631 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15632 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
15633 /* Side Pin: output 3 (0x0f) */
15634 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15635 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
15637
15638 /* Mic (rear) pin: input vref at 80% */
15639 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15640 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15641 /* Front Mic pin: input vref at 80% */
15642 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15643 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15644 /* Line In pin: input */
15645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15647 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15650 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15651 /* CD pin widget for input */
15652 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15653
15654 { }
15655};
15656
Kailang Yangbdd148a2007-05-08 15:19:08 +020015657static struct hda_verb alc861vd_eapd_verbs[] = {
15658 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15659 { }
15660};
15661
Kailang Yangf9423e72008-05-27 12:32:25 +020015662static struct hda_verb alc660vd_eapd_verbs[] = {
15663 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15664 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15665 { }
15666};
15667
Kailang Yangbdd148a2007-05-08 15:19:08 +020015668static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
15669 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15670 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15671 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
15672 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020015673 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020015674 {}
15675};
15676
Kailang Yangbdd148a2007-05-08 15:19:08 +020015677static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
15678{
15679 unsigned int present;
15680 unsigned char bits;
15681
Wu Fengguang864f92b2009-11-18 12:38:02 +080015682 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020015683 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080015684
Takashi Iwai47fd8302007-08-10 17:11:07 +020015685 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
15686 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015687}
15688
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015689static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020015690{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015691 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015692 spec->autocfg.hp_pins[0] = 0x1b;
15693 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015694}
15695
15696static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
15697{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015698 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020015699 alc861vd_lenovo_mic_automute(codec);
15700}
15701
15702static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
15703 unsigned int res)
15704{
15705 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020015706 case ALC880_MIC_EVENT:
15707 alc861vd_lenovo_mic_automute(codec);
15708 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015709 default:
15710 alc_automute_amp_unsol_event(codec, res);
15711 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020015712 }
15713}
15714
Kailang Yang272a5272007-05-14 11:00:38 +020015715static struct hda_verb alc861vd_dallas_verbs[] = {
15716 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15717 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15718 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15719 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15720
15721 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15722 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15723 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15724 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15725 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15728 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015729
Kailang Yang272a5272007-05-14 11:00:38 +020015730 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15731 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15732 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15733 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15734 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15735 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15736 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15737 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15738
15739 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15740 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
15742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15743 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15744 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15745 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15746 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15747
15748 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15749 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
15752
15753 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015754 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020015755 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15756
15757 { } /* end */
15758};
15759
15760/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015761static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020015762{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015763 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020015764
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015765 spec->autocfg.hp_pins[0] = 0x15;
15766 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020015767}
15768
Takashi Iwaicb53c622007-08-10 17:21:45 +020015769#ifdef CONFIG_SND_HDA_POWER_SAVE
15770#define alc861vd_loopbacks alc880_loopbacks
15771#endif
15772
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015773/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015774#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
15775#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
15776#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
15777#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
15778
15779/*
15780 * configuration and preset
15781 */
15782static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
15783 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015784 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010015785 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015786 [ALC861VD_3ST] = "3stack",
15787 [ALC861VD_3ST_DIG] = "3stack-digout",
15788 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020015789 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020015790 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020015791 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015792 [ALC861VD_AUTO] = "auto",
15793};
15794
15795static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015796 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
15797 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010015798 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020015799 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010015800 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020015801 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015802 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015803 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020015804 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020015805 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020015806 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010015807 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020015808 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010015809 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020015810 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015811 {}
15812};
15813
15814static struct alc_config_preset alc861vd_presets[] = {
15815 [ALC660VD_3ST] = {
15816 .mixers = { alc861vd_3st_mixer },
15817 .init_verbs = { alc861vd_volume_init_verbs,
15818 alc861vd_3stack_init_verbs },
15819 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15820 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015821 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15822 .channel_mode = alc861vd_3stack_2ch_modes,
15823 .input_mux = &alc861vd_capture_source,
15824 },
Mike Crash6963f842007-06-25 12:12:51 +020015825 [ALC660VD_3ST_DIG] = {
15826 .mixers = { alc861vd_3st_mixer },
15827 .init_verbs = { alc861vd_volume_init_verbs,
15828 alc861vd_3stack_init_verbs },
15829 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15830 .dac_nids = alc660vd_dac_nids,
15831 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020015832 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15833 .channel_mode = alc861vd_3stack_2ch_modes,
15834 .input_mux = &alc861vd_capture_source,
15835 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015836 [ALC861VD_3ST] = {
15837 .mixers = { alc861vd_3st_mixer },
15838 .init_verbs = { alc861vd_volume_init_verbs,
15839 alc861vd_3stack_init_verbs },
15840 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15841 .dac_nids = alc861vd_dac_nids,
15842 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15843 .channel_mode = alc861vd_3stack_2ch_modes,
15844 .input_mux = &alc861vd_capture_source,
15845 },
15846 [ALC861VD_3ST_DIG] = {
15847 .mixers = { alc861vd_3st_mixer },
15848 .init_verbs = { alc861vd_volume_init_verbs,
15849 alc861vd_3stack_init_verbs },
15850 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15851 .dac_nids = alc861vd_dac_nids,
15852 .dig_out_nid = ALC861VD_DIGOUT_NID,
15853 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15854 .channel_mode = alc861vd_3stack_2ch_modes,
15855 .input_mux = &alc861vd_capture_source,
15856 },
15857 [ALC861VD_6ST_DIG] = {
15858 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
15859 .init_verbs = { alc861vd_volume_init_verbs,
15860 alc861vd_6stack_init_verbs },
15861 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15862 .dac_nids = alc861vd_dac_nids,
15863 .dig_out_nid = ALC861VD_DIGOUT_NID,
15864 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
15865 .channel_mode = alc861vd_6stack_modes,
15866 .input_mux = &alc861vd_capture_source,
15867 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020015868 [ALC861VD_LENOVO] = {
15869 .mixers = { alc861vd_lenovo_mixer },
15870 .init_verbs = { alc861vd_volume_init_verbs,
15871 alc861vd_3stack_init_verbs,
15872 alc861vd_eapd_verbs,
15873 alc861vd_lenovo_unsol_verbs },
15874 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15875 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015876 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15877 .channel_mode = alc861vd_3stack_2ch_modes,
15878 .input_mux = &alc861vd_capture_source,
15879 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015880 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015881 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020015882 },
Kailang Yang272a5272007-05-14 11:00:38 +020015883 [ALC861VD_DALLAS] = {
15884 .mixers = { alc861vd_dallas_mixer },
15885 .init_verbs = { alc861vd_dallas_verbs },
15886 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15887 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020015888 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15889 .channel_mode = alc861vd_3stack_2ch_modes,
15890 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015891 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015892 .setup = alc861vd_dallas_setup,
15893 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015894 },
15895 [ALC861VD_HP] = {
15896 .mixers = { alc861vd_hp_mixer },
15897 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
15898 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
15899 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015900 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020015901 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15902 .channel_mode = alc861vd_3stack_2ch_modes,
15903 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015904 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015905 .setup = alc861vd_dallas_setup,
15906 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020015907 },
Takashi Iwai13c94742008-11-05 08:06:08 +010015908 [ALC660VD_ASUS_V1S] = {
15909 .mixers = { alc861vd_lenovo_mixer },
15910 .init_verbs = { alc861vd_volume_init_verbs,
15911 alc861vd_3stack_init_verbs,
15912 alc861vd_eapd_verbs,
15913 alc861vd_lenovo_unsol_verbs },
15914 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
15915 .dac_nids = alc660vd_dac_nids,
15916 .dig_out_nid = ALC861VD_DIGOUT_NID,
15917 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
15918 .channel_mode = alc861vd_3stack_2ch_modes,
15919 .input_mux = &alc861vd_capture_source,
15920 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015921 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020015922 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010015923 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015924};
15925
15926/*
15927 * BIOS auto configuration
15928 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015929static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
15930 const struct auto_pin_cfg *cfg)
15931{
Kailang Yang6227cdc2010-02-25 08:36:52 +010015932 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020015933}
15934
15935
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015936static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
15937 hda_nid_t nid, int pin_type, int dac_idx)
15938{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015939 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015940}
15941
15942static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
15943{
15944 struct alc_spec *spec = codec->spec;
15945 int i;
15946
15947 for (i = 0; i <= HDA_SIDE; i++) {
15948 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015949 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015950 if (nid)
15951 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015952 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015953 }
15954}
15955
15956
15957static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
15958{
15959 struct alc_spec *spec = codec->spec;
15960 hda_nid_t pin;
15961
15962 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015963 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015964 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015965 pin = spec->autocfg.speaker_pins[0];
15966 if (pin)
15967 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015968}
15969
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015970#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
15971
15972static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
15973{
15974 struct alc_spec *spec = codec->spec;
15975 int i;
15976
15977 for (i = 0; i < AUTO_PIN_LAST; i++) {
15978 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020015979 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010015980 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010015981 if (nid != ALC861VD_PIN_CD_NID &&
15982 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015983 snd_hda_codec_write(codec, nid, 0,
15984 AC_VERB_SET_AMP_GAIN_MUTE,
15985 AMP_OUT_MUTE);
15986 }
15987 }
15988}
15989
Takashi Iwaif511b012008-08-15 16:46:42 +020015990#define alc861vd_auto_init_input_src alc882_auto_init_input_src
15991
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015992#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
15993#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
15994
15995/* add playback controls from the parsed DAC table */
15996/* Based on ALC880 version. But ALC861VD has separate,
15997 * different NIDs for mute/unmute switch and volume control */
15998static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
15999 const struct auto_pin_cfg *cfg)
16000{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016001 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16002 hda_nid_t nid_v, nid_s;
16003 int i, err;
16004
16005 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016006 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016007 continue;
16008 nid_v = alc861vd_idx_to_mixer_vol(
16009 alc880_dac_to_idx(
16010 spec->multiout.dac_nids[i]));
16011 nid_s = alc861vd_idx_to_mixer_switch(
16012 alc880_dac_to_idx(
16013 spec->multiout.dac_nids[i]));
16014
16015 if (i == 2) {
16016 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016017 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16018 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016019 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16020 HDA_OUTPUT));
16021 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016022 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016023 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16024 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016025 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16026 HDA_OUTPUT));
16027 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016028 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016029 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16030 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016031 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16032 HDA_INPUT));
16033 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016034 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016035 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16036 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016037 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16038 HDA_INPUT));
16039 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016040 return err;
16041 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016042 const char *pfx;
16043 if (cfg->line_outs == 1 &&
16044 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16045 if (!cfg->hp_pins)
16046 pfx = "Speaker";
16047 else
16048 pfx = "PCM";
16049 } else
16050 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016051 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016052 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16053 HDA_OUTPUT));
16054 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016055 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016056 if (cfg->line_outs == 1 &&
16057 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16058 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016059 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016060 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016061 HDA_INPUT));
16062 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016063 return err;
16064 }
16065 }
16066 return 0;
16067}
16068
16069/* add playback controls for speaker and HP outputs */
16070/* Based on ALC880 version. But ALC861VD has separate,
16071 * different NIDs for mute/unmute switch and volume control */
16072static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16073 hda_nid_t pin, const char *pfx)
16074{
16075 hda_nid_t nid_v, nid_s;
16076 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016077
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016078 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016079 return 0;
16080
16081 if (alc880_is_fixed_pin(pin)) {
16082 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16083 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016084 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016085 spec->multiout.hp_nid = nid_v;
16086 else
16087 spec->multiout.extra_out_nid[0] = nid_v;
16088 /* control HP volume/switch on the output mixer amp */
16089 nid_v = alc861vd_idx_to_mixer_vol(
16090 alc880_fixed_pin_idx(pin));
16091 nid_s = alc861vd_idx_to_mixer_switch(
16092 alc880_fixed_pin_idx(pin));
16093
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016094 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016095 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16096 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016097 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016098 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016099 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16100 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016101 return err;
16102 } else if (alc880_is_multi_pin(pin)) {
16103 /* set manual connection */
16104 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016105 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016106 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16107 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016108 return err;
16109 }
16110 return 0;
16111}
16112
16113/* parse the BIOS configuration and set up the alc_spec
16114 * return 1 if successful, 0 if the proper config is not found,
16115 * or a negative error code
16116 * Based on ALC880 version - had to change it to override
16117 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16118static int alc861vd_parse_auto_config(struct hda_codec *codec)
16119{
16120 struct alc_spec *spec = codec->spec;
16121 int err;
16122 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16123
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016124 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16125 alc861vd_ignore);
16126 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016127 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016128 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016129 return 0; /* can't find valid BIOS pin config */
16130
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016131 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16132 if (err < 0)
16133 return err;
16134 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
16135 if (err < 0)
16136 return err;
16137 err = alc861vd_auto_create_extra_out(spec,
16138 spec->autocfg.speaker_pins[0],
16139 "Speaker");
16140 if (err < 0)
16141 return err;
16142 err = alc861vd_auto_create_extra_out(spec,
16143 spec->autocfg.hp_pins[0],
16144 "Headphone");
16145 if (err < 0)
16146 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016147 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016148 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016149 return err;
16150
16151 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16152
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016153 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016154 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
16155
Takashi Iwai603c4012008-07-30 15:01:44 +020016156 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016157 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016158
Takashi Iwaid88897e2008-10-31 15:01:37 +010016159 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016160
16161 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016162 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016163
Takashi Iwai776e1842007-08-29 15:07:11 +020016164 err = alc_auto_add_mic_boost(codec);
16165 if (err < 0)
16166 return err;
16167
Kailang Yang6227cdc2010-02-25 08:36:52 +010016168 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016169
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016170 return 1;
16171}
16172
16173/* additional initialization for auto-configuration model */
16174static void alc861vd_auto_init(struct hda_codec *codec)
16175{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016176 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016177 alc861vd_auto_init_multi_out(codec);
16178 alc861vd_auto_init_hp_out(codec);
16179 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016180 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016181 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016182 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016183}
16184
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016185enum {
16186 ALC660VD_FIX_ASUS_GPIO1
16187};
16188
16189/* reset GPIO1 */
16190static const struct hda_verb alc660vd_fix_asus_gpio1_verbs[] = {
16191 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
16192 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
16193 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
16194 { }
16195};
16196
16197static const struct alc_fixup alc861vd_fixups[] = {
16198 [ALC660VD_FIX_ASUS_GPIO1] = {
16199 .verbs = alc660vd_fix_asus_gpio1_verbs,
16200 },
16201};
16202
16203static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
16204 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
16205 {}
16206};
16207
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016208static int patch_alc861vd(struct hda_codec *codec)
16209{
16210 struct alc_spec *spec;
16211 int err, board_config;
16212
16213 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16214 if (spec == NULL)
16215 return -ENOMEM;
16216
16217 codec->spec = spec;
16218
16219 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
16220 alc861vd_models,
16221 alc861vd_cfg_tbl);
16222
16223 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016224 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16225 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016226 board_config = ALC861VD_AUTO;
16227 }
16228
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016229 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups);
16230
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016231 if (board_config == ALC861VD_AUTO) {
16232 /* automatic parse from the BIOS config */
16233 err = alc861vd_parse_auto_config(codec);
16234 if (err < 0) {
16235 alc_free(codec);
16236 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016237 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016238 printk(KERN_INFO
16239 "hda_codec: Cannot set up configuration "
16240 "from BIOS. Using base mode...\n");
16241 board_config = ALC861VD_3ST;
16242 }
16243 }
16244
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016245 err = snd_hda_attach_beep_device(codec, 0x23);
16246 if (err < 0) {
16247 alc_free(codec);
16248 return err;
16249 }
16250
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016251 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016252 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016253
Kailang Yang2f893282008-05-27 12:14:47 +020016254 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020016255 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010016256 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020016257 }
16258
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016259 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
16260 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
16261
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016262 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
16263 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16264
Takashi Iwaidd704692009-08-11 08:45:11 +020016265 if (!spec->adc_nids) {
16266 spec->adc_nids = alc861vd_adc_nids;
16267 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
16268 }
16269 if (!spec->capsrc_nids)
16270 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016271
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016272 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016273 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016274
Takashi Iwai2134ea42008-01-10 16:53:55 +010016275 spec->vmaster_nid = 0x02;
16276
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016277 codec->patch_ops = alc_patch_ops;
16278
16279 if (board_config == ALC861VD_AUTO)
16280 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016281#ifdef CONFIG_SND_HDA_POWER_SAVE
16282 if (!spec->loopback.amplist)
16283 spec->loopback.amplist = alc861vd_loopbacks;
16284#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016285
16286 return 0;
16287}
16288
16289/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016290 * ALC662 support
16291 *
16292 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
16293 * configuration. Each pin widget can choose any input DACs and a mixer.
16294 * Each ADC is connected from a mixer of all inputs. This makes possible
16295 * 6-channel independent captures.
16296 *
16297 * In addition, an independent DAC for the multi-playback (not used in this
16298 * driver yet).
16299 */
16300#define ALC662_DIGOUT_NID 0x06
16301#define ALC662_DIGIN_NID 0x0a
16302
16303static hda_nid_t alc662_dac_nids[4] = {
16304 /* front, rear, clfe, rear_surr */
16305 0x02, 0x03, 0x04
16306};
16307
Kailang Yang622e84c2009-04-21 07:39:04 +020016308static hda_nid_t alc272_dac_nids[2] = {
16309 0x02, 0x03
16310};
16311
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016312static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016313 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016314 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016315};
Takashi Iwaie1406342008-02-11 18:32:32 +010016316
Kailang Yang622e84c2009-04-21 07:39:04 +020016317static hda_nid_t alc272_adc_nids[1] = {
16318 /* ADC1-2 */
16319 0x08,
16320};
16321
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016322static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020016323static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
16324
Takashi Iwaie1406342008-02-11 18:32:32 +010016325
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016326/* input MUX */
16327/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016328static struct hda_input_mux alc662_capture_source = {
16329 .num_items = 4,
16330 .items = {
16331 { "Mic", 0x0 },
16332 { "Front Mic", 0x1 },
16333 { "Line", 0x2 },
16334 { "CD", 0x4 },
16335 },
16336};
16337
16338static struct hda_input_mux alc662_lenovo_101e_capture_source = {
16339 .num_items = 2,
16340 .items = {
16341 { "Mic", 0x1 },
16342 { "Line", 0x2 },
16343 },
16344};
Kailang Yang291702f2007-10-16 14:28:03 +020016345
Kailang Yang6dda9f42008-05-27 12:05:31 +020016346static struct hda_input_mux alc663_capture_source = {
16347 .num_items = 3,
16348 .items = {
16349 { "Mic", 0x0 },
16350 { "Front Mic", 0x1 },
16351 { "Line", 0x2 },
16352 },
16353};
16354
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016355#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020016356static struct hda_input_mux alc272_nc10_capture_source = {
16357 .num_items = 16,
16358 .items = {
16359 { "Autoselect Mic", 0x0 },
16360 { "Internal Mic", 0x1 },
16361 { "In-0x02", 0x2 },
16362 { "In-0x03", 0x3 },
16363 { "In-0x04", 0x4 },
16364 { "In-0x05", 0x5 },
16365 { "In-0x06", 0x6 },
16366 { "In-0x07", 0x7 },
16367 { "In-0x08", 0x8 },
16368 { "In-0x09", 0x9 },
16369 { "In-0x0a", 0x0a },
16370 { "In-0x0b", 0x0b },
16371 { "In-0x0c", 0x0c },
16372 { "In-0x0d", 0x0d },
16373 { "In-0x0e", 0x0e },
16374 { "In-0x0f", 0x0f },
16375 },
16376};
16377#endif
16378
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016379/*
16380 * 2ch mode
16381 */
16382static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
16383 { 2, NULL }
16384};
16385
16386/*
16387 * 2ch mode
16388 */
16389static struct hda_verb alc662_3ST_ch2_init[] = {
16390 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
16391 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16392 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
16393 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
16394 { } /* end */
16395};
16396
16397/*
16398 * 6ch mode
16399 */
16400static struct hda_verb alc662_3ST_ch6_init[] = {
16401 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16402 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16403 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
16404 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16405 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
16406 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
16407 { } /* end */
16408};
16409
16410static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
16411 { 2, alc662_3ST_ch2_init },
16412 { 6, alc662_3ST_ch6_init },
16413};
16414
16415/*
16416 * 2ch mode
16417 */
16418static struct hda_verb alc662_sixstack_ch6_init[] = {
16419 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16420 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16421 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16422 { } /* end */
16423};
16424
16425/*
16426 * 6ch mode
16427 */
16428static struct hda_verb alc662_sixstack_ch8_init[] = {
16429 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16430 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16431 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16432 { } /* end */
16433};
16434
16435static struct hda_channel_mode alc662_5stack_modes[2] = {
16436 { 2, alc662_sixstack_ch6_init },
16437 { 6, alc662_sixstack_ch8_init },
16438};
16439
16440/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16441 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16442 */
16443
16444static struct snd_kcontrol_new alc662_base_mixer[] = {
16445 /* output mixer control */
16446 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016447 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016448 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016449 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016450 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16451 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016452 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16453 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16455
16456 /*Input mixer control */
16457 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
16458 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
16459 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
16460 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
16461 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
16462 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
16463 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
16464 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016465 { } /* end */
16466};
16467
16468static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
16469 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016470 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16472 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16473 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16474 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16475 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16477 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16478 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16479 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016480 { } /* end */
16481};
16482
16483static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
16484 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016485 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016486 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016487 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016488 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16489 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010016490 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
16491 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016492 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16493 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16494 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16495 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16496 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16497 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16498 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16499 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16500 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016501 { } /* end */
16502};
16503
16504static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
16505 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16506 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010016507 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16508 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016509 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16510 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16511 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16512 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16513 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016514 { } /* end */
16515};
16516
Kailang Yang291702f2007-10-16 14:28:03 +020016517static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016518 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16519 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020016520
16521 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
16522 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16523 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16524
16525 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16526 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16527 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16528 { } /* end */
16529};
16530
Kailang Yang8c427222008-01-10 13:03:59 +010016531static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020016532 ALC262_HIPPO_MASTER_SWITCH,
16533 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016534 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016535 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
16536 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010016537 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
16538 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16539 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16540 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16541 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16542 { } /* end */
16543};
16544
Kailang Yangf1d4e282008-08-26 14:03:29 +020016545static struct hda_bind_ctls alc663_asus_bind_master_vol = {
16546 .ops = &snd_hda_bind_vol,
16547 .values = {
16548 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16549 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
16550 0
16551 },
16552};
16553
16554static struct hda_bind_ctls alc663_asus_one_bind_switch = {
16555 .ops = &snd_hda_bind_sw,
16556 .values = {
16557 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16558 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16559 0
16560 },
16561};
16562
Kailang Yang6dda9f42008-05-27 12:05:31 +020016563static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016564 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16565 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
16566 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16567 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16568 { } /* end */
16569};
16570
16571static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
16572 .ops = &snd_hda_bind_sw,
16573 .values = {
16574 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16575 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16576 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16577 0
16578 },
16579};
16580
16581static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
16582 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16583 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
16584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16585 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16586 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16587 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16588
16589 { } /* end */
16590};
16591
16592static struct hda_bind_ctls alc663_asus_four_bind_switch = {
16593 .ops = &snd_hda_bind_sw,
16594 .values = {
16595 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16596 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16597 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16598 0
16599 },
16600};
16601
16602static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
16603 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16604 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
16605 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16606 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16607 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16608 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16609 { } /* end */
16610};
16611
16612static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020016613 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16614 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16618 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16619 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16620 { } /* end */
16621};
16622
16623static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
16624 .ops = &snd_hda_bind_vol,
16625 .values = {
16626 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
16627 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
16628 0
16629 },
16630};
16631
16632static struct hda_bind_ctls alc663_asus_two_bind_switch = {
16633 .ops = &snd_hda_bind_sw,
16634 .values = {
16635 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16636 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
16637 0
16638 },
16639};
16640
16641static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
16642 HDA_BIND_VOL("Master Playback Volume",
16643 &alc663_asus_two_bind_master_vol),
16644 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16645 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016646 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16647 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16648 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020016649 { } /* end */
16650};
16651
16652static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
16653 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
16654 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
16655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16656 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16657 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16658 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016659 { } /* end */
16660};
16661
16662static struct snd_kcontrol_new alc663_g71v_mixer[] = {
16663 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16664 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16665 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16666 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16668
16669 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16670 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16671 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16672 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16673 { } /* end */
16674};
16675
16676static struct snd_kcontrol_new alc663_g50v_mixer[] = {
16677 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16678 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16679 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16680
16681 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16682 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16683 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16684 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16685 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16686 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16687 { } /* end */
16688};
16689
Kailang Yangebb83ee2009-12-17 12:23:00 +010016690static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
16691 .ops = &snd_hda_bind_sw,
16692 .values = {
16693 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16694 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
16695 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16696 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16697 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
16698 0
16699 },
16700};
16701
16702static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
16703 .ops = &snd_hda_bind_sw,
16704 .values = {
16705 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
16706 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
16707 0
16708 },
16709};
16710
16711static struct snd_kcontrol_new alc663_mode7_mixer[] = {
16712 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16713 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16714 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16715 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16716 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16717 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16718 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16719 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16720 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16721 { } /* end */
16722};
16723
16724static struct snd_kcontrol_new alc663_mode8_mixer[] = {
16725 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
16726 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
16727 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
16728 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
16729 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
16730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16732 { } /* end */
16733};
16734
16735
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016736static struct snd_kcontrol_new alc662_chmode_mixer[] = {
16737 {
16738 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16739 .name = "Channel Mode",
16740 .info = alc_ch_mode_info,
16741 .get = alc_ch_mode_get,
16742 .put = alc_ch_mode_put,
16743 },
16744 { } /* end */
16745};
16746
16747static struct hda_verb alc662_init_verbs[] = {
16748 /* ADC: mute amp left and right */
16749 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16750 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016751
Kailang Yangb60dd392007-09-20 12:50:29 +020016752 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16753 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16754 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16755 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16756 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16757 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016758
16759 /* Front Pin: output 0 (0x0c) */
16760 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16761 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16762
16763 /* Rear Pin: output 1 (0x0d) */
16764 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16765 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16766
16767 /* CLFE Pin: output 2 (0x0e) */
16768 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16769 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16770
16771 /* Mic (rear) pin: input vref at 80% */
16772 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16773 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16774 /* Front Mic pin: input vref at 80% */
16775 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16776 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16777 /* Line In pin: input */
16778 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16779 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16780 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16781 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16782 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16783 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16784 /* CD pin widget for input */
16785 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16786
16787 /* FIXME: use matrix-type input source selection */
16788 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
16789 /* Input mixer */
16790 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020016791 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016792
16793 /* always trun on EAPD */
16794 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16795 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16796
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016797 { }
16798};
16799
Kailang Yangcec27c82010-02-04 14:18:18 +010016800static struct hda_verb alc663_init_verbs[] = {
16801 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16802 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16803 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16804 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16805 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16806 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16807 { }
16808};
16809
16810static struct hda_verb alc272_init_verbs[] = {
16811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16813 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16814 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16815 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16816 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16817 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16818 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16819 { }
16820};
16821
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016822static struct hda_verb alc662_sue_init_verbs[] = {
16823 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16824 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020016825 {}
16826};
16827
16828static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
16829 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16830 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16831 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016832};
16833
Kailang Yang8c427222008-01-10 13:03:59 +010016834/* Set Unsolicited Event*/
16835static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
16836 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16837 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16838 {}
16839};
16840
Kailang Yang6dda9f42008-05-27 12:05:31 +020016841static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020016842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16843 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016844 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16845 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020016846 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16847 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16848 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020016849 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16850 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16851 {}
16852};
16853
Kailang Yangf1d4e282008-08-26 14:03:29 +020016854static struct hda_verb alc663_21jd_amic_init_verbs[] = {
16855 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16856 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16857 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16860 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16861 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16862 {}
16863};
16864
16865static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
16866 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16867 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16868 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16869 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16870 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16871 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16872 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16873 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16874 {}
16875};
16876
16877static struct hda_verb alc663_15jd_amic_init_verbs[] = {
16878 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16881 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16882 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16883 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16884 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16885 {}
16886};
16887
16888static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
16889 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16890 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16891 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16892 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16893 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16894 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16895 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
16896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16897 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16898 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16899 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16900 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16901 {}
16902};
16903
16904static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
16905 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16906 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16907 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16908 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16909 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16910 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16911 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16914 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16915 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16916 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16917 {}
16918};
16919
Kailang Yang6dda9f42008-05-27 12:05:31 +020016920static struct hda_verb alc663_g71v_init_verbs[] = {
16921 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16922 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
16923 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
16924
16925 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16926 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16927 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16928
16929 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
16930 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
16931 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
16932 {}
16933};
16934
16935static struct hda_verb alc663_g50v_init_verbs[] = {
16936 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16937 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16938 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
16939
16940 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16941 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16942 {}
16943};
16944
Kailang Yangf1d4e282008-08-26 14:03:29 +020016945static struct hda_verb alc662_ecs_init_verbs[] = {
16946 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
16947 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16948 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16949 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16950 {}
16951};
16952
Kailang Yang622e84c2009-04-21 07:39:04 +020016953static struct hda_verb alc272_dell_zm1_init_verbs[] = {
16954 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16955 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16956 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16957 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16958 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16959 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16960 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16963 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16964 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16965 {}
16966};
16967
16968static struct hda_verb alc272_dell_init_verbs[] = {
16969 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16970 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16971 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16973 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16974 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16975 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16976 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16977 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16978 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16979 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16980 {}
16981};
16982
Kailang Yangebb83ee2009-12-17 12:23:00 +010016983static struct hda_verb alc663_mode7_init_verbs[] = {
16984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16985 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16986 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16987 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16988 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16989 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16990 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
16991 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16992 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16993 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
16994 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16995 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
16996 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
16997 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16998 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16999 {}
17000};
17001
17002static struct hda_verb alc663_mode8_init_verbs[] = {
17003 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17007 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17008 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17009 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17010 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17011 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17012 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17013 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17014 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17015 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17016 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17017 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17018 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17019 {}
17020};
17021
Kailang Yangf1d4e282008-08-26 14:03:29 +020017022static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17023 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17024 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17025 { } /* end */
17026};
17027
Kailang Yang622e84c2009-04-21 07:39:04 +020017028static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17029 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17030 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17031 { } /* end */
17032};
17033
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017034static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17035{
17036 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017037 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017038
Wu Fengguang864f92b2009-11-18 12:38:02 +080017039 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017040 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017041
Takashi Iwai47fd8302007-08-10 17:11:07 +020017042 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17043 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017044}
17045
17046static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17047{
17048 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017049 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017050
Wu Fengguang864f92b2009-11-18 12:38:02 +080017051 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017052 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017053
Takashi Iwai47fd8302007-08-10 17:11:07 +020017054 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17055 HDA_AMP_MUTE, bits);
17056 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17057 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017058}
17059
17060static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17061 unsigned int res)
17062{
17063 if ((res >> 26) == ALC880_HP_EVENT)
17064 alc662_lenovo_101e_all_automute(codec);
17065 if ((res >> 26) == ALC880_FRONT_EVENT)
17066 alc662_lenovo_101e_ispeaker_automute(codec);
17067}
17068
Kailang Yang291702f2007-10-16 14:28:03 +020017069/* unsolicited event for HP jack sensing */
17070static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17071 unsigned int res)
17072{
Kailang Yang291702f2007-10-16 14:28:03 +020017073 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017074 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017075 else
17076 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017077}
17078
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017079static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017080{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017081 struct alc_spec *spec = codec->spec;
17082
17083 alc262_hippo1_setup(codec);
17084 spec->ext_mic.pin = 0x18;
17085 spec->ext_mic.mux_idx = 0;
17086 spec->int_mic.pin = 0x19;
17087 spec->int_mic.mux_idx = 1;
17088 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017089}
17090
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017091static void alc662_eeepc_inithook(struct hda_codec *codec)
17092{
17093 alc262_hippo_automute(codec);
17094 alc_mic_automute(codec);
17095}
17096
17097static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017098{
Takashi Iwai42171c12009-05-08 14:11:43 +020017099 struct alc_spec *spec = codec->spec;
17100
17101 spec->autocfg.hp_pins[0] = 0x14;
17102 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017103}
17104
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017105#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17106
Kailang Yang6dda9f42008-05-27 12:05:31 +020017107static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17108{
17109 unsigned int present;
17110 unsigned char bits;
17111
Wu Fengguang864f92b2009-11-18 12:38:02 +080017112 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017113 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017114 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17115 AMP_IN_MUTE(0), bits);
17116 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17117 AMP_IN_MUTE(0), bits);
17118}
17119
17120static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17121{
17122 unsigned int present;
17123 unsigned char bits;
17124
Wu Fengguang864f92b2009-11-18 12:38:02 +080017125 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017126 bits = present ? HDA_AMP_MUTE : 0;
17127 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17128 AMP_IN_MUTE(0), bits);
17129 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17130 AMP_IN_MUTE(0), bits);
17131 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17132 AMP_IN_MUTE(0), bits);
17133 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17134 AMP_IN_MUTE(0), bits);
17135}
17136
17137static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
17138{
17139 unsigned int present;
17140 unsigned char bits;
17141
Wu Fengguang864f92b2009-11-18 12:38:02 +080017142 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017143 bits = present ? HDA_AMP_MUTE : 0;
17144 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17145 AMP_IN_MUTE(0), bits);
17146 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17147 AMP_IN_MUTE(0), bits);
17148 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
17149 AMP_IN_MUTE(0), bits);
17150 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
17151 AMP_IN_MUTE(0), bits);
17152}
17153
17154static void alc662_f5z_speaker_automute(struct hda_codec *codec)
17155{
17156 unsigned int present;
17157 unsigned char bits;
17158
Wu Fengguang864f92b2009-11-18 12:38:02 +080017159 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017160 bits = present ? 0 : PIN_OUT;
17161 snd_hda_codec_write(codec, 0x14, 0,
17162 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
17163}
17164
17165static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
17166{
17167 unsigned int present1, present2;
17168
Wu Fengguang864f92b2009-11-18 12:38:02 +080017169 present1 = snd_hda_jack_detect(codec, 0x21);
17170 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017171
17172 if (present1 || present2) {
17173 snd_hda_codec_write_cache(codec, 0x14, 0,
17174 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17175 } else {
17176 snd_hda_codec_write_cache(codec, 0x14, 0,
17177 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17178 }
17179}
17180
17181static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
17182{
17183 unsigned int present1, present2;
17184
Wu Fengguang864f92b2009-11-18 12:38:02 +080017185 present1 = snd_hda_jack_detect(codec, 0x1b);
17186 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017187
17188 if (present1 || present2) {
17189 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17190 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17191 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17192 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
17193 } else {
17194 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
17195 AMP_IN_MUTE(0), 0);
17196 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
17197 AMP_IN_MUTE(0), 0);
17198 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020017199}
17200
Kailang Yangebb83ee2009-12-17 12:23:00 +010017201static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
17202{
17203 unsigned int present1, present2;
17204
17205 present1 = snd_hda_codec_read(codec, 0x1b, 0,
17206 AC_VERB_GET_PIN_SENSE, 0)
17207 & AC_PINSENSE_PRESENCE;
17208 present2 = snd_hda_codec_read(codec, 0x21, 0,
17209 AC_VERB_GET_PIN_SENSE, 0)
17210 & AC_PINSENSE_PRESENCE;
17211
17212 if (present1 || present2) {
17213 snd_hda_codec_write_cache(codec, 0x14, 0,
17214 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17215 snd_hda_codec_write_cache(codec, 0x17, 0,
17216 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17217 } else {
17218 snd_hda_codec_write_cache(codec, 0x14, 0,
17219 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17220 snd_hda_codec_write_cache(codec, 0x17, 0,
17221 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17222 }
17223}
17224
17225static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
17226{
17227 unsigned int present1, present2;
17228
17229 present1 = snd_hda_codec_read(codec, 0x21, 0,
17230 AC_VERB_GET_PIN_SENSE, 0)
17231 & AC_PINSENSE_PRESENCE;
17232 present2 = snd_hda_codec_read(codec, 0x15, 0,
17233 AC_VERB_GET_PIN_SENSE, 0)
17234 & AC_PINSENSE_PRESENCE;
17235
17236 if (present1 || present2) {
17237 snd_hda_codec_write_cache(codec, 0x14, 0,
17238 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17239 snd_hda_codec_write_cache(codec, 0x17, 0,
17240 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
17241 } else {
17242 snd_hda_codec_write_cache(codec, 0x14, 0,
17243 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17244 snd_hda_codec_write_cache(codec, 0x17, 0,
17245 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
17246 }
17247}
17248
Kailang Yang6dda9f42008-05-27 12:05:31 +020017249static void alc663_m51va_unsol_event(struct hda_codec *codec,
17250 unsigned int res)
17251{
17252 switch (res >> 26) {
17253 case ALC880_HP_EVENT:
17254 alc663_m51va_speaker_automute(codec);
17255 break;
17256 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017257 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017258 break;
17259 }
17260}
17261
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017262static void alc663_m51va_setup(struct hda_codec *codec)
17263{
17264 struct alc_spec *spec = codec->spec;
17265 spec->ext_mic.pin = 0x18;
17266 spec->ext_mic.mux_idx = 0;
17267 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010017268 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017269 spec->auto_mic = 1;
17270}
17271
Kailang Yang6dda9f42008-05-27 12:05:31 +020017272static void alc663_m51va_inithook(struct hda_codec *codec)
17273{
17274 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017275 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017276}
17277
Kailang Yangf1d4e282008-08-26 14:03:29 +020017278/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017279#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010017280
17281static void alc663_mode1_setup(struct hda_codec *codec)
17282{
17283 struct alc_spec *spec = codec->spec;
17284 spec->ext_mic.pin = 0x18;
17285 spec->ext_mic.mux_idx = 0;
17286 spec->int_mic.pin = 0x19;
17287 spec->int_mic.mux_idx = 1;
17288 spec->auto_mic = 1;
17289}
17290
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017291#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020017292
Kailang Yangf1d4e282008-08-26 14:03:29 +020017293/* ***************** Mode2 ******************************/
17294static void alc662_mode2_unsol_event(struct hda_codec *codec,
17295 unsigned int res)
17296{
17297 switch (res >> 26) {
17298 case ALC880_HP_EVENT:
17299 alc662_f5z_speaker_automute(codec);
17300 break;
17301 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017302 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017303 break;
17304 }
17305}
17306
Kailang Yangebb83ee2009-12-17 12:23:00 +010017307#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017308
Kailang Yangf1d4e282008-08-26 14:03:29 +020017309static void alc662_mode2_inithook(struct hda_codec *codec)
17310{
17311 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017312 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017313}
17314/* ***************** Mode3 ******************************/
17315static void alc663_mode3_unsol_event(struct hda_codec *codec,
17316 unsigned int res)
17317{
17318 switch (res >> 26) {
17319 case ALC880_HP_EVENT:
17320 alc663_two_hp_m1_speaker_automute(codec);
17321 break;
17322 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017323 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017324 break;
17325 }
17326}
17327
Kailang Yangebb83ee2009-12-17 12:23:00 +010017328#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017329
Kailang Yangf1d4e282008-08-26 14:03:29 +020017330static void alc663_mode3_inithook(struct hda_codec *codec)
17331{
17332 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017333 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017334}
17335/* ***************** Mode4 ******************************/
17336static void alc663_mode4_unsol_event(struct hda_codec *codec,
17337 unsigned int res)
17338{
17339 switch (res >> 26) {
17340 case ALC880_HP_EVENT:
17341 alc663_21jd_two_speaker_automute(codec);
17342 break;
17343 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017344 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017345 break;
17346 }
17347}
17348
Kailang Yangebb83ee2009-12-17 12:23:00 +010017349#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017350
Kailang Yangf1d4e282008-08-26 14:03:29 +020017351static void alc663_mode4_inithook(struct hda_codec *codec)
17352{
17353 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017354 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017355}
17356/* ***************** Mode5 ******************************/
17357static void alc663_mode5_unsol_event(struct hda_codec *codec,
17358 unsigned int res)
17359{
17360 switch (res >> 26) {
17361 case ALC880_HP_EVENT:
17362 alc663_15jd_two_speaker_automute(codec);
17363 break;
17364 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017365 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017366 break;
17367 }
17368}
17369
Kailang Yangebb83ee2009-12-17 12:23:00 +010017370#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017371
Kailang Yangf1d4e282008-08-26 14:03:29 +020017372static void alc663_mode5_inithook(struct hda_codec *codec)
17373{
17374 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017375 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017376}
17377/* ***************** Mode6 ******************************/
17378static void alc663_mode6_unsol_event(struct hda_codec *codec,
17379 unsigned int res)
17380{
17381 switch (res >> 26) {
17382 case ALC880_HP_EVENT:
17383 alc663_two_hp_m2_speaker_automute(codec);
17384 break;
17385 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017386 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017387 break;
17388 }
17389}
17390
Kailang Yangebb83ee2009-12-17 12:23:00 +010017391#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017392
Kailang Yangf1d4e282008-08-26 14:03:29 +020017393static void alc663_mode6_inithook(struct hda_codec *codec)
17394{
17395 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017396 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017397}
17398
Kailang Yangebb83ee2009-12-17 12:23:00 +010017399/* ***************** Mode7 ******************************/
17400static void alc663_mode7_unsol_event(struct hda_codec *codec,
17401 unsigned int res)
17402{
17403 switch (res >> 26) {
17404 case ALC880_HP_EVENT:
17405 alc663_two_hp_m7_speaker_automute(codec);
17406 break;
17407 case ALC880_MIC_EVENT:
17408 alc_mic_automute(codec);
17409 break;
17410 }
17411}
17412
17413#define alc663_mode7_setup alc663_mode1_setup
17414
17415static void alc663_mode7_inithook(struct hda_codec *codec)
17416{
17417 alc663_two_hp_m7_speaker_automute(codec);
17418 alc_mic_automute(codec);
17419}
17420
17421/* ***************** Mode8 ******************************/
17422static void alc663_mode8_unsol_event(struct hda_codec *codec,
17423 unsigned int res)
17424{
17425 switch (res >> 26) {
17426 case ALC880_HP_EVENT:
17427 alc663_two_hp_m8_speaker_automute(codec);
17428 break;
17429 case ALC880_MIC_EVENT:
17430 alc_mic_automute(codec);
17431 break;
17432 }
17433}
17434
17435#define alc663_mode8_setup alc663_m51va_setup
17436
17437static void alc663_mode8_inithook(struct hda_codec *codec)
17438{
17439 alc663_two_hp_m8_speaker_automute(codec);
17440 alc_mic_automute(codec);
17441}
17442
Kailang Yang6dda9f42008-05-27 12:05:31 +020017443static void alc663_g71v_hp_automute(struct hda_codec *codec)
17444{
17445 unsigned int present;
17446 unsigned char bits;
17447
Wu Fengguang864f92b2009-11-18 12:38:02 +080017448 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017449 bits = present ? HDA_AMP_MUTE : 0;
17450 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17451 HDA_AMP_MUTE, bits);
17452 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17453 HDA_AMP_MUTE, bits);
17454}
17455
17456static void alc663_g71v_front_automute(struct hda_codec *codec)
17457{
17458 unsigned int present;
17459 unsigned char bits;
17460
Wu Fengguang864f92b2009-11-18 12:38:02 +080017461 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017462 bits = present ? HDA_AMP_MUTE : 0;
17463 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17464 HDA_AMP_MUTE, bits);
17465}
17466
17467static void alc663_g71v_unsol_event(struct hda_codec *codec,
17468 unsigned int res)
17469{
17470 switch (res >> 26) {
17471 case ALC880_HP_EVENT:
17472 alc663_g71v_hp_automute(codec);
17473 break;
17474 case ALC880_FRONT_EVENT:
17475 alc663_g71v_front_automute(codec);
17476 break;
17477 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017478 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017479 break;
17480 }
17481}
17482
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017483#define alc663_g71v_setup alc663_m51va_setup
17484
Kailang Yang6dda9f42008-05-27 12:05:31 +020017485static void alc663_g71v_inithook(struct hda_codec *codec)
17486{
17487 alc663_g71v_front_automute(codec);
17488 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017489 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017490}
17491
17492static void alc663_g50v_unsol_event(struct hda_codec *codec,
17493 unsigned int res)
17494{
17495 switch (res >> 26) {
17496 case ALC880_HP_EVENT:
17497 alc663_m51va_speaker_automute(codec);
17498 break;
17499 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017500 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017501 break;
17502 }
17503}
17504
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017505#define alc663_g50v_setup alc663_m51va_setup
17506
Kailang Yang6dda9f42008-05-27 12:05:31 +020017507static void alc663_g50v_inithook(struct hda_codec *codec)
17508{
17509 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017510 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017511}
17512
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513static struct snd_kcontrol_new alc662_ecs_mixer[] = {
17514 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020017515 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017516
17517 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
17518 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
17519 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
17520
17521 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17522 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17523 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17524 { } /* end */
17525};
17526
Chris Pockelé9541ba12009-05-12 08:08:53 +020017527static struct snd_kcontrol_new alc272_nc10_mixer[] = {
17528 /* Master Playback automatically created from Speaker and Headphone */
17529 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17530 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17531 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17532 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17533
17534 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17535 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17536 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
17537
17538 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17539 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17540 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
17541 { } /* end */
17542};
17543
Takashi Iwaicb53c622007-08-10 17:21:45 +020017544#ifdef CONFIG_SND_HDA_POWER_SAVE
17545#define alc662_loopbacks alc880_loopbacks
17546#endif
17547
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017548
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017549/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017550#define alc662_pcm_analog_playback alc880_pcm_analog_playback
17551#define alc662_pcm_analog_capture alc880_pcm_analog_capture
17552#define alc662_pcm_digital_playback alc880_pcm_digital_playback
17553#define alc662_pcm_digital_capture alc880_pcm_digital_capture
17554
17555/*
17556 * configuration and preset
17557 */
17558static const char *alc662_models[ALC662_MODEL_LAST] = {
17559 [ALC662_3ST_2ch_DIG] = "3stack-dig",
17560 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
17561 [ALC662_3ST_6ch] = "3stack-6ch",
17562 [ALC662_5ST_DIG] = "6stack-dig",
17563 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020017564 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010017565 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017566 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020017567 [ALC663_ASUS_M51VA] = "m51va",
17568 [ALC663_ASUS_G71V] = "g71v",
17569 [ALC663_ASUS_H13] = "h13",
17570 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020017571 [ALC663_ASUS_MODE1] = "asus-mode1",
17572 [ALC662_ASUS_MODE2] = "asus-mode2",
17573 [ALC663_ASUS_MODE3] = "asus-mode3",
17574 [ALC663_ASUS_MODE4] = "asus-mode4",
17575 [ALC663_ASUS_MODE5] = "asus-mode5",
17576 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010017577 [ALC663_ASUS_MODE7] = "asus-mode7",
17578 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020017579 [ALC272_DELL] = "dell",
17580 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020017581 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017582 [ALC662_AUTO] = "auto",
17583};
17584
17585static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010017586 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020017587 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
17588 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017589 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
17590 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010017591 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017592 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
17593 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
17594 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
17595 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017596 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
17597 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017598 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017599 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
17600 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
17601 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
17602 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
17603 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017604 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017605 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
17606 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017607 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
17608 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
17609 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
17610 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010017611 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017612 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
17613 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
17614 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017615 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
17616 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
17617 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
17618 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017619 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017620 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
17621 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017622 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017623 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
17624 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
17625 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017626 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010017627 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020017628 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
17629 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017630 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
17631 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
17632 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017633 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017634 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
17635 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020017636 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017637 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020017638 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017639 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
17640 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
17641 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020017642 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017643 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
17644 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010017645 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020017646 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010017647 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017648 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030017649 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
17650 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010017651 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020017652 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030017653 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
17654 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010017655 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020017656 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020017657 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017658 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020017659 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020017660 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010017661 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
17662 ALC663_ASUS_H13),
David Santinoli7aee6742009-12-09 12:34:26 +010017663 SND_PCI_QUIRK(0x8086, 0xd604, "Intel mobo", ALC662_3ST_2ch_DIG),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017664 {}
17665};
17666
17667static struct alc_config_preset alc662_presets[] = {
17668 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017669 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017670 .init_verbs = { alc662_init_verbs },
17671 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17672 .dac_nids = alc662_dac_nids,
17673 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017674 .dig_in_nid = ALC662_DIGIN_NID,
17675 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17676 .channel_mode = alc662_3ST_2ch_modes,
17677 .input_mux = &alc662_capture_source,
17678 },
17679 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017680 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017681 .init_verbs = { alc662_init_verbs },
17682 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17683 .dac_nids = alc662_dac_nids,
17684 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017685 .dig_in_nid = ALC662_DIGIN_NID,
17686 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17687 .channel_mode = alc662_3ST_6ch_modes,
17688 .need_dac_fix = 1,
17689 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017690 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017691 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017692 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017693 .init_verbs = { alc662_init_verbs },
17694 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17695 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017696 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17697 .channel_mode = alc662_3ST_6ch_modes,
17698 .need_dac_fix = 1,
17699 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017700 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017701 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017702 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017703 .init_verbs = { alc662_init_verbs },
17704 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17705 .dac_nids = alc662_dac_nids,
17706 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017707 .dig_in_nid = ALC662_DIGIN_NID,
17708 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
17709 .channel_mode = alc662_5stack_modes,
17710 .input_mux = &alc662_capture_source,
17711 },
17712 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017713 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017714 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
17715 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17716 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017717 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17718 .channel_mode = alc662_3ST_2ch_modes,
17719 .input_mux = &alc662_lenovo_101e_capture_source,
17720 .unsol_event = alc662_lenovo_101e_unsol_event,
17721 .init_hook = alc662_lenovo_101e_all_automute,
17722 },
Kailang Yang291702f2007-10-16 14:28:03 +020017723 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017724 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020017725 .init_verbs = { alc662_init_verbs,
17726 alc662_eeepc_sue_init_verbs },
17727 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17728 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020017729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17730 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020017731 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017732 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020017733 .init_hook = alc662_eeepc_inithook,
17734 },
Kailang Yang8c427222008-01-10 13:03:59 +010017735 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017736 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010017737 alc662_chmode_mixer },
17738 .init_verbs = { alc662_init_verbs,
17739 alc662_eeepc_ep20_sue_init_verbs },
17740 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17741 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010017742 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17743 .channel_mode = alc662_3ST_6ch_modes,
17744 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020017745 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017746 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010017747 .init_hook = alc662_eeepc_ep20_inithook,
17748 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017749 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017750 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017751 .init_verbs = { alc662_init_verbs,
17752 alc662_ecs_init_verbs },
17753 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17754 .dac_nids = alc662_dac_nids,
17755 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17756 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017757 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017758 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017759 .init_hook = alc662_eeepc_inithook,
17760 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017761 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017762 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017763 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17764 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17765 .dac_nids = alc662_dac_nids,
17766 .dig_out_nid = ALC662_DIGOUT_NID,
17767 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17768 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017769 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017770 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017771 .init_hook = alc663_m51va_inithook,
17772 },
17773 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017774 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017775 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
17776 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17777 .dac_nids = alc662_dac_nids,
17778 .dig_out_nid = ALC662_DIGOUT_NID,
17779 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17780 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017781 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017782 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017783 .init_hook = alc663_g71v_inithook,
17784 },
17785 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017786 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017787 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
17788 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17789 .dac_nids = alc662_dac_nids,
17790 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17791 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017792 .unsol_event = alc663_m51va_unsol_event,
17793 .init_hook = alc663_m51va_inithook,
17794 },
17795 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017796 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020017797 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
17798 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17799 .dac_nids = alc662_dac_nids,
17800 .dig_out_nid = ALC662_DIGOUT_NID,
17801 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
17802 .channel_mode = alc662_3ST_6ch_modes,
17803 .input_mux = &alc663_capture_source,
17804 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017805 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020017806 .init_hook = alc663_g50v_inithook,
17807 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020017808 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017809 .mixers = { alc663_m51va_mixer },
17810 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017811 .init_verbs = { alc662_init_verbs,
17812 alc663_21jd_amic_init_verbs },
17813 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17814 .hp_nid = 0x03,
17815 .dac_nids = alc662_dac_nids,
17816 .dig_out_nid = ALC662_DIGOUT_NID,
17817 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17818 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017819 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017820 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017821 .init_hook = alc663_mode1_inithook,
17822 },
17823 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017824 .mixers = { alc662_1bjd_mixer },
17825 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017826 .init_verbs = { alc662_init_verbs,
17827 alc662_1bjd_amic_init_verbs },
17828 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17829 .dac_nids = alc662_dac_nids,
17830 .dig_out_nid = ALC662_DIGOUT_NID,
17831 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17832 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017833 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017834 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017835 .init_hook = alc662_mode2_inithook,
17836 },
17837 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017838 .mixers = { alc663_two_hp_m1_mixer },
17839 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017840 .init_verbs = { alc662_init_verbs,
17841 alc663_two_hp_amic_m1_init_verbs },
17842 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17843 .hp_nid = 0x03,
17844 .dac_nids = alc662_dac_nids,
17845 .dig_out_nid = ALC662_DIGOUT_NID,
17846 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17847 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017848 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017849 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017850 .init_hook = alc663_mode3_inithook,
17851 },
17852 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017853 .mixers = { alc663_asus_21jd_clfe_mixer },
17854 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017855 .init_verbs = { alc662_init_verbs,
17856 alc663_21jd_amic_init_verbs},
17857 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17858 .hp_nid = 0x03,
17859 .dac_nids = alc662_dac_nids,
17860 .dig_out_nid = ALC662_DIGOUT_NID,
17861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17862 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017863 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017864 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017865 .init_hook = alc663_mode4_inithook,
17866 },
17867 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017868 .mixers = { alc663_asus_15jd_clfe_mixer },
17869 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017870 .init_verbs = { alc662_init_verbs,
17871 alc663_15jd_amic_init_verbs },
17872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17873 .hp_nid = 0x03,
17874 .dac_nids = alc662_dac_nids,
17875 .dig_out_nid = ALC662_DIGOUT_NID,
17876 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17877 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017878 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017879 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017880 .init_hook = alc663_mode5_inithook,
17881 },
17882 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010017883 .mixers = { alc663_two_hp_m2_mixer },
17884 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017885 .init_verbs = { alc662_init_verbs,
17886 alc663_two_hp_amic_m2_init_verbs },
17887 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17888 .hp_nid = 0x03,
17889 .dac_nids = alc662_dac_nids,
17890 .dig_out_nid = ALC662_DIGOUT_NID,
17891 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17892 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017893 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017894 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020017895 .init_hook = alc663_mode6_inithook,
17896 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010017897 [ALC663_ASUS_MODE7] = {
17898 .mixers = { alc663_mode7_mixer },
17899 .cap_mixer = alc662_auto_capture_mixer,
17900 .init_verbs = { alc662_init_verbs,
17901 alc663_mode7_init_verbs },
17902 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17903 .hp_nid = 0x03,
17904 .dac_nids = alc662_dac_nids,
17905 .dig_out_nid = ALC662_DIGOUT_NID,
17906 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17907 .channel_mode = alc662_3ST_2ch_modes,
17908 .unsol_event = alc663_mode7_unsol_event,
17909 .setup = alc663_mode7_setup,
17910 .init_hook = alc663_mode7_inithook,
17911 },
17912 [ALC663_ASUS_MODE8] = {
17913 .mixers = { alc663_mode8_mixer },
17914 .cap_mixer = alc662_auto_capture_mixer,
17915 .init_verbs = { alc662_init_verbs,
17916 alc663_mode8_init_verbs },
17917 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
17918 .hp_nid = 0x03,
17919 .dac_nids = alc662_dac_nids,
17920 .dig_out_nid = ALC662_DIGOUT_NID,
17921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17922 .channel_mode = alc662_3ST_2ch_modes,
17923 .unsol_event = alc663_mode8_unsol_event,
17924 .setup = alc663_mode8_setup,
17925 .init_hook = alc663_mode8_inithook,
17926 },
Kailang Yang622e84c2009-04-21 07:39:04 +020017927 [ALC272_DELL] = {
17928 .mixers = { alc663_m51va_mixer },
17929 .cap_mixer = alc272_auto_capture_mixer,
17930 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
17931 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17932 .dac_nids = alc662_dac_nids,
17933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17934 .adc_nids = alc272_adc_nids,
17935 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
17936 .capsrc_nids = alc272_capsrc_nids,
17937 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017938 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017939 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017940 .init_hook = alc663_m51va_inithook,
17941 },
17942 [ALC272_DELL_ZM1] = {
17943 .mixers = { alc663_m51va_mixer },
17944 .cap_mixer = alc662_auto_capture_mixer,
17945 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
17946 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17947 .dac_nids = alc662_dac_nids,
17948 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17949 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017950 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020017951 .capsrc_nids = alc662_capsrc_nids,
17952 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020017953 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017954 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020017955 .init_hook = alc663_m51va_inithook,
17956 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020017957 [ALC272_SAMSUNG_NC10] = {
17958 .mixers = { alc272_nc10_mixer },
17959 .init_verbs = { alc662_init_verbs,
17960 alc663_21jd_amic_init_verbs },
17961 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
17962 .dac_nids = alc272_dac_nids,
17963 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
17964 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017965 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020017966 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017967 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020017968 .init_hook = alc663_mode4_inithook,
17969 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017970};
17971
17972
17973/*
17974 * BIOS auto configuration
17975 */
17976
Takashi Iwai7085ec12009-10-02 09:03:58 +020017977/* convert from MIX nid to DAC */
17978static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
17979{
17980 if (nid == 0x0f)
17981 return 0x02;
17982 else if (nid >= 0x0c && nid <= 0x0e)
17983 return nid - 0x0c + 0x02;
17984 else
17985 return 0;
17986}
17987
17988/* get MIX nid connected to the given pin targeted to DAC */
17989static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
17990 hda_nid_t dac)
17991{
17992 hda_nid_t mix[4];
17993 int i, num;
17994
17995 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
17996 for (i = 0; i < num; i++) {
17997 if (alc662_mix_to_dac(mix[i]) == dac)
17998 return mix[i];
17999 }
18000 return 0;
18001}
18002
18003/* look for an empty DAC slot */
18004static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18005{
18006 struct alc_spec *spec = codec->spec;
18007 hda_nid_t srcs[5];
18008 int i, j, num;
18009
18010 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18011 if (num < 0)
18012 return 0;
18013 for (i = 0; i < num; i++) {
18014 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18015 if (!nid)
18016 continue;
18017 for (j = 0; j < spec->multiout.num_dacs; j++)
18018 if (spec->multiout.dac_nids[j] == nid)
18019 break;
18020 if (j >= spec->multiout.num_dacs)
18021 return nid;
18022 }
18023 return 0;
18024}
18025
18026/* fill in the dac_nids table from the parsed pin configuration */
18027static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18028 const struct auto_pin_cfg *cfg)
18029{
18030 struct alc_spec *spec = codec->spec;
18031 int i;
18032 hda_nid_t dac;
18033
18034 spec->multiout.dac_nids = spec->private_dac_nids;
18035 for (i = 0; i < cfg->line_outs; i++) {
18036 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18037 if (!dac)
18038 continue;
18039 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18040 }
18041 return 0;
18042}
18043
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018044static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018045 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018046{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018047 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018048 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18049}
18050
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018051static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018052 hda_nid_t nid, unsigned int chs)
18053{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018054 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018055 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18056}
18057
18058#define alc662_add_stereo_vol(spec, pfx, nid) \
18059 alc662_add_vol_ctl(spec, pfx, nid, 3)
18060#define alc662_add_stereo_sw(spec, pfx, nid) \
18061 alc662_add_sw_ctl(spec, pfx, nid, 3)
18062
18063/* add playback controls from the parsed DAC table */
18064static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18065 const struct auto_pin_cfg *cfg)
18066{
18067 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018068 static const char *chname[4] = {
18069 "Front", "Surround", NULL /*CLFE*/, "Side"
18070 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018071 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018072 int i, err;
18073
18074 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018075 nid = spec->multiout.dac_nids[i];
18076 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018077 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018078 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18079 if (!mix)
18080 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018081 if (i == 2) {
18082 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018083 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018084 if (err < 0)
18085 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018086 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018087 if (err < 0)
18088 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018089 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018090 if (err < 0)
18091 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018092 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018093 if (err < 0)
18094 return err;
18095 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018096 const char *pfx;
18097 if (cfg->line_outs == 1 &&
18098 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018099 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018100 pfx = "Speaker";
18101 else
18102 pfx = "PCM";
18103 } else
18104 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018105 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018106 if (err < 0)
18107 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018108 if (cfg->line_outs == 1 &&
18109 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18110 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018111 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018112 if (err < 0)
18113 return err;
18114 }
18115 }
18116 return 0;
18117}
18118
18119/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018120/* return DAC nid if any new DAC is assigned */
18121static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018122 const char *pfx)
18123{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018124 struct alc_spec *spec = codec->spec;
18125 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018126 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018127
18128 if (!pin)
18129 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018130 nid = alc662_look_for_dac(codec, pin);
18131 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018132 /* the corresponding DAC is already occupied */
18133 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
18134 return 0; /* no way */
18135 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018136 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018137 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
18138 }
18139
18140 mix = alc662_dac_to_mix(codec, pin, nid);
18141 if (!mix)
18142 return 0;
18143 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
18144 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020018145 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018146 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
18147 if (err < 0)
18148 return err;
18149 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018150}
18151
18152/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020018153#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020018154 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018155
18156static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
18157 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018158 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018159{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018160 int i, num;
18161 hda_nid_t srcs[4];
18162
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018163 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018164 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018165 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
18166 if (num <= 1)
18167 return;
18168 for (i = 0; i < num; i++) {
18169 if (alc662_mix_to_dac(srcs[i]) != dac)
18170 continue;
18171 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
18172 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018173 }
18174}
18175
18176static void alc662_auto_init_multi_out(struct hda_codec *codec)
18177{
18178 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018179 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018180 int i;
18181
18182 for (i = 0; i <= HDA_SIDE; i++) {
18183 hda_nid_t nid = spec->autocfg.line_out_pins[i];
18184 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020018185 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018186 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018187 }
18188}
18189
18190static void alc662_auto_init_hp_out(struct hda_codec *codec)
18191{
18192 struct alc_spec *spec = codec->spec;
18193 hda_nid_t pin;
18194
18195 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018196 if (pin)
18197 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
18198 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018199 pin = spec->autocfg.speaker_pins[0];
18200 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020018201 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
18202 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018203}
18204
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018205#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
18206
18207static void alc662_auto_init_analog_input(struct hda_codec *codec)
18208{
18209 struct alc_spec *spec = codec->spec;
18210 int i;
18211
18212 for (i = 0; i < AUTO_PIN_LAST; i++) {
18213 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai05f5f472009-08-25 13:10:18 +020018214 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010018215 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010018216 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010018217 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018218 snd_hda_codec_write(codec, nid, 0,
18219 AC_VERB_SET_AMP_GAIN_MUTE,
18220 AMP_OUT_MUTE);
18221 }
18222 }
18223}
18224
Takashi Iwaif511b012008-08-15 16:46:42 +020018225#define alc662_auto_init_input_src alc882_auto_init_input_src
18226
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018227static int alc662_parse_auto_config(struct hda_codec *codec)
18228{
18229 struct alc_spec *spec = codec->spec;
18230 int err;
18231 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
18232
18233 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
18234 alc662_ignore);
18235 if (err < 0)
18236 return err;
18237 if (!spec->autocfg.line_outs)
18238 return 0; /* can't find valid BIOS pin config */
18239
Takashi Iwai7085ec12009-10-02 09:03:58 +020018240 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018241 if (err < 0)
18242 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018243 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018244 if (err < 0)
18245 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018246 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018247 spec->autocfg.speaker_pins[0],
18248 "Speaker");
18249 if (err < 0)
18250 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018251 if (err)
18252 spec->multiout.extra_out_nid[0] = err;
18253 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018254 "Headphone");
18255 if (err < 0)
18256 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018257 if (err)
18258 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020018259 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018260 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018261 return err;
18262
18263 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
18264
Takashi Iwai0852d7a2009-02-11 11:35:15 +010018265 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018266 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
18267
Takashi Iwai603c4012008-07-30 15:01:44 +020018268 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010018269 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018270
18271 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020018272 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020018273
Kailang Yangcec27c82010-02-04 14:18:18 +010018274 add_verb(spec, alc662_init_verbs);
18275 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18276 codec->vendor_id == 0x10ec0665)
18277 add_verb(spec, alc663_init_verbs);
18278
18279 if (codec->vendor_id == 0x10ec0272)
18280 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020018281
18282 err = alc_auto_add_mic_boost(codec);
18283 if (err < 0)
18284 return err;
18285
Kailang Yang6227cdc2010-02-25 08:36:52 +010018286 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
18287 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
18288 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
18289 else
18290 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020018291
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018292 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018293}
18294
18295/* additional initialization for auto-configuration model */
18296static void alc662_auto_init(struct hda_codec *codec)
18297{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018298 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018299 alc662_auto_init_multi_out(codec);
18300 alc662_auto_init_hp_out(codec);
18301 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020018302 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010018303 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020018304 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018305}
18306
18307static int patch_alc662(struct hda_codec *codec)
18308{
18309 struct alc_spec *spec;
18310 int err, board_config;
18311
18312 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
18313 if (!spec)
18314 return -ENOMEM;
18315
18316 codec->spec = spec;
18317
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020018318 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18319
Kailang Yang274693f2009-12-03 10:07:50 +010018320 if (alc_read_coef_idx(codec, 0)==0x8020){
18321 kfree(codec->chip_name);
18322 codec->chip_name = kstrdup("ALC661", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018323 if (!codec->chip_name) {
18324 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018325 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018326 }
Kailang Yang274693f2009-12-03 10:07:50 +010018327 }
18328
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018329 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18330 alc662_models,
18331 alc662_cfg_tbl);
18332 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020018333 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
18334 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018335 board_config = ALC662_AUTO;
18336 }
18337
18338 if (board_config == ALC662_AUTO) {
18339 /* automatic parse from the BIOS config */
18340 err = alc662_parse_auto_config(codec);
18341 if (err < 0) {
18342 alc_free(codec);
18343 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020018344 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018345 printk(KERN_INFO
18346 "hda_codec: Cannot set up configuration "
18347 "from BIOS. Using base mode...\n");
18348 board_config = ALC662_3ST_2ch_DIG;
18349 }
18350 }
18351
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090018352 err = snd_hda_attach_beep_device(codec, 0x1);
18353 if (err < 0) {
18354 alc_free(codec);
18355 return err;
18356 }
18357
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018358 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020018359 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018360
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018361 spec->stream_analog_playback = &alc662_pcm_analog_playback;
18362 spec->stream_analog_capture = &alc662_pcm_analog_capture;
18363
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018364 spec->stream_digital_playback = &alc662_pcm_digital_playback;
18365 spec->stream_digital_capture = &alc662_pcm_digital_capture;
18366
Takashi Iwaidd704692009-08-11 08:45:11 +020018367 if (!spec->adc_nids) {
18368 spec->adc_nids = alc662_adc_nids;
18369 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
18370 }
18371 if (!spec->capsrc_nids)
18372 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018373
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018374 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018375 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018376
Kailang Yangcec27c82010-02-04 14:18:18 +010018377 switch (codec->vendor_id) {
18378 case 0x10ec0662:
18379 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18380 break;
18381 case 0x10ec0272:
18382 case 0x10ec0663:
18383 case 0x10ec0665:
18384 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18385 break;
18386 case 0x10ec0273:
18387 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18388 break;
18389 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010018390 spec->vmaster_nid = 0x02;
18391
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018392 codec->patch_ops = alc_patch_ops;
18393 if (board_config == ALC662_AUTO)
18394 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020018395#ifdef CONFIG_SND_HDA_POWER_SAVE
18396 if (!spec->loopback.amplist)
18397 spec->loopback.amplist = alc662_loopbacks;
18398#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018399
18400 return 0;
18401}
18402
Kailang Yang274693f2009-12-03 10:07:50 +010018403static int patch_alc888(struct hda_codec *codec)
18404{
18405 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
18406 kfree(codec->chip_name);
18407 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018408 if (!codec->chip_name) {
18409 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018410 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018411 }
18412 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018413 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010018414 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010018415}
18416
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018417/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070018418 * patch entries
18419 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018420static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070018421 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018422 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018423 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020018424 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010018425 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018426 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020018427 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018428 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018429 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018430 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018431 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
18432 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
18433 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018434 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018435 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018436 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
18437 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018438 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010018439 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010018440 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010018441 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018442 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018443 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020018444 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018445 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020018446 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018447 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010018448 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018449 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020018450 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020018451 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018452 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020018453 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010018454 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070018455 {} /* terminator */
18456};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010018457
18458MODULE_ALIAS("snd-hda-codec-id:10ec*");
18459
18460MODULE_LICENSE("GPL");
18461MODULE_DESCRIPTION("Realtek HD-audio codec");
18462
18463static struct hda_codec_preset_list realtek_list = {
18464 .preset = snd_hda_preset_realtek,
18465 .owner = THIS_MODULE,
18466};
18467
18468static int __init patch_realtek_init(void)
18469{
18470 return snd_hda_add_codec_preset(&realtek_list);
18471}
18472
18473static void __exit patch_realtek_exit(void)
18474{
18475 snd_hda_delete_codec_preset(&realtek_list);
18476}
18477
18478module_init(patch_realtek_init)
18479module_exit(patch_realtek_exit)